當前位置: 首頁>>代碼示例>>C#>>正文


C# Type.TypeName方法代碼示例

本文整理匯總了C#中System.Type.TypeName方法的典型用法代碼示例。如果您正苦於以下問題:C# Type.TypeName方法的具體用法?C# Type.TypeName怎麽用?C# Type.TypeName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Type的用法示例。


在下文中一共展示了Type.TypeName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetAttribute

        public static EntityKindAttribute GetAttribute(Type type)
        {
            var attr = TryGetAttribute(type);

            if (attr == null)
                throw new InvalidOperationException("{0} does not define an EntityKindAttribute".Formato(type.TypeName()));

            return attr;
        }
開發者ID:nuub666,項目名稱:framework,代碼行數:9,代碼來源:TypeAttributes.cs

示例2: NoRegistrationForTypeFound

 internal static string NoRegistrationForTypeFound(Type serviceType, bool containerHasRegistrations,
     bool containerHasRelatedOneToOneMapping, bool containerHasRelatedCollectionMapping,
     Type[] skippedDecorators) =>
     string.Format(CultureInfo.InvariantCulture,
         "No registration for type {0} could be found.{1}{2}{3}{4}",
         serviceType.TypeName(),
         ContainerHasNoRegistrationsAddition(containerHasRegistrations),
         DidYouMeanToCallGetInstanceInstead(containerHasRelatedOneToOneMapping, serviceType),
         DidYouMeanToCallGetAllInstancesInstead(containerHasRelatedCollectionMapping, serviceType),
         NoteThatSkippedDecoratorsWereFound(serviceType, skippedDecorators));
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:10,代碼來源:StringResources.cs

示例3: ExtensionToken

        public ExtensionToken(QueryToken parent, string key, Type type, bool isProjection,
            string unit, string format, 
            Implementations? implementations,
            string isAllowed, PropertyRoute propertyRoute)
            : base(parent)
        {
            var shouldHaveImplementations = typeof(IEntity).IsAssignableFrom((isProjection ? type.ElementType() : type).CleanType());

            if (shouldHaveImplementations && implementations == null)
                throw new ArgumentException("Extension token '{0}' (of type {1}) registered on type {2} has no implementations".FormatWith(key, type.TypeName(), parent.Type.CleanType().TypeName()));

            this.key= key;
            this.type = type;
            this.isProjection = isProjection;
            this.unit = unit;
            this.format = format;
            this.implementations = implementations;
            this.isAllowed = isAllowed;
            this.propertyRoute = propertyRoute;
        }
開發者ID:rondoo,項目名稱:framework,代碼行數:20,代碼來源:ExtensionToken.cs

示例4: DidYouMeanToCallGetAllInstancesInstead

 private static string DidYouMeanToCallGetAllInstancesInstead(bool hasCollection, Type serviceType) =>
     hasCollection
         ? string.Format(CultureInfo.InvariantCulture,
             " There is, however, a registration for {0}; Did you mean to call " +
             "GetAllInstances<{1}>() or depend on {0}?",
             typeof(IEnumerable<>).MakeGenericType(serviceType).TypeName(),
             serviceType.TypeName())
         : string.Empty;
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:8,代碼來源:StringResources.cs

示例5: OpenGenericTypesCanNotBeResolved

 internal static string OpenGenericTypesCanNotBeResolved(Type serviceType) =>
     string.Format(CultureInfo.InvariantCulture,
         "The request for type {0} is invalid because it is an open generic type: it is only " +
         "possible to instantiate instances of closed generic types. A generic type is closed if " +
         "all of its type parameters have been substituted with types that are recognized by the " +
         "compiler.",
         serviceType.TypeName());
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:7,代碼來源:StringResources.cs

示例6: PrintType

 public void PrintType(string prefix, Type ty) {
   Contract.Requires(prefix != null);
   Contract.Requires(ty != null);
   string s = ty.TypeName(null, true);
   if (s != "?" && !s.StartsWith("_")) {
     wr.Write("{0}{1}", prefix, s);
   }
 }
開發者ID:ggrov,項目名稱:tacny,代碼行數:8,代碼來源:Printer.cs

示例7: DelegateForTypeReturnedNull

 internal static string DelegateForTypeReturnedNull(Type serviceType) =>
     string.Format(CultureInfo.InvariantCulture,
         "The registered delegate for type {0} returned null.", serviceType.TypeName());
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:3,代碼來源:StringResources.cs

示例8: ArgumentNullException

 public static Exception ArgumentNullException(Type argumentType, string argumentName)
 {
     return new ArgumentNullException(argumentName, $"The argument '{argumentName}' of type '{argumentType.TypeName()}' is null. Are you missing an [AutoInit] attribute?");
 }
開發者ID:signumsoftware,項目名稱:framework,代碼行數:4,代碼來源:TypeAttributes.cs

示例9: LiteReferenceExpression

        public readonly Expression CustomToStr; //Not readonly

        public LiteReferenceExpression(Type type, Expression reference, Expression customToStr) :
            base(DbExpressionType.LiteReference, type)
        {
            Type cleanType = Lite.Extract(type);

            if (cleanType != reference.Type)
                throw new ArgumentException("The type {0} is not the Lite version of {1}".Formato(type.TypeName(), reference.Type.TypeName()));

            this.Reference = reference;

            this.CustomToStr = customToStr;
        }
開發者ID:nuub666,項目名稱:framework,代碼行數:14,代碼來源:DbExpressions.Signum.cs

示例10: AnOverlappingRegistrationExists

        internal static string AnOverlappingRegistrationExists(Type openGenericServiceType,
            Type overlappingImplementationType, bool isExistingRegistrationConditional,
            Type implementationTypeOfNewRegistration, bool isNewRegistrationConditional)
        {
            string solution = "Either remove one of the registrations or make them both conditional.";

            if (isExistingRegistrationConditional && isNewRegistrationConditional &&
                overlappingImplementationType == implementationTypeOfNewRegistration)
            {
                solution =
                    "You can merge both registrations into a single conditional registration and combine " +
                    "both predicates into one single predicate.";
            }

            return string.Format(CultureInfo.InvariantCulture,
                "There is already a {0}registration for {1} (with implementation {2}) that " +
                "overlaps with the {3}registration for {4} that you are trying to make. This new " +
                "registration would cause ambiguity, because both registrations would be used for the " +
                "same closed service types. {5}",
                isExistingRegistrationConditional ? "conditional " : string.Empty,
                openGenericServiceType.TypeName(),
                overlappingImplementationType.TypeName(),
                isNewRegistrationConditional ? "conditional " : string.Empty,
                implementationTypeOfNewRegistration.TypeName(),
                solution);
        }
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:26,代碼來源:StringResources.cs

示例11: PrintType

 public void PrintType(string prefix, Type ty)
 {
     Contract.Requires(prefix != null);
       Contract.Requires(ty != null);
       if (DafnyOptions.O.DafnyPrintResolvedFile != null) {
     ty = ty.Normalize();
       }
       string s = ty.TypeName(null, true);
       if (!(ty is TypeProxy) && !s.StartsWith("_")) {
     wr.Write("{0}{1}", prefix, s);
       }
 }
開發者ID:Chris-Hawblitzel,項目名稱:dafny,代碼行數:12,代碼來源:Printer.cs

示例12: RegistrationForClosedServiceTypeOverlapsWithOpenGenericRegistration

 internal static string RegistrationForClosedServiceTypeOverlapsWithOpenGenericRegistration(
     Type closedServiceType, Type overlappingGenericImplementationType) =>
     string.Format(CultureInfo.InvariantCulture,
         "There is already an open generic registration for {0} (with implementation {1}) that " +
         "overlaps with the registration of {2} that you are trying to make. If your intention is " +
         "to use {1} as fallback registration, please instead call: " +
         "{5}(typeof({3}), typeof({4}), c => !c.Handled).",
         closedServiceType.GetGenericTypeDefinition().TypeName(),
         overlappingGenericImplementationType.TypeName(),
         closedServiceType.TypeName(),
         CSharpFriendlyName(closedServiceType.GetGenericTypeDefinition()),
         CSharpFriendlyName(overlappingGenericImplementationType),
         nameof(Container.RegisterConditional));
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:13,代碼來源:StringResources.cs

示例13: ErrorWhileBuildingDelegateFromExpression

 internal static string ErrorWhileBuildingDelegateFromExpression(Type serviceType,
     Expression expression, Exception exception) =>
     string.Format(CultureInfo.InvariantCulture,
         "Error occurred while trying to build a delegate for type {0} using the expression \"{1}\". " +
         "{2}", serviceType.TypeName(), expression, exception.Message);
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:5,代碼來源:StringResources.cs

示例14: ServiceTypeCannotBeAPartiallyClosedType

 internal static string ServiceTypeCannotBeAPartiallyClosedType(Type openGenericServiceType,
     string serviceTypeParamName, string implementationTypeParamName) =>
     string.Format(CultureInfo.InvariantCulture,
         "The supplied type '{0}' is a partially-closed generic type, which is not supported as " +
         "value of the {1} parameter. Instead, please supply the open generic type '{2}' and make " +
         "the type supplied to the {3} parameter partially-closed instead.",
         openGenericServiceType.TypeName(),
         serviceTypeParamName,
         CSharpFriendlyName(openGenericServiceType.GetGenericTypeDefinition()),
         implementationTypeParamName);
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:10,代碼來源:StringResources.cs

示例15: TypeFactoryReturnedIncompatibleType

 internal static string TypeFactoryReturnedIncompatibleType(Type serviceType, Type implementationType) =>
     string.Format(CultureInfo.InvariantCulture,
         "The registered type factory returned type {0} which does not implement {1}.",
         implementationType.TypeName(), serviceType.TypeName());
開發者ID:abatishchev,項目名稱:SimpleInjector,代碼行數:4,代碼來源:StringResources.cs


注:本文中的System.Type.TypeName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。