本文整理汇总了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;
}
示例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));
示例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;
}
示例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;
示例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());
示例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);
}
}
示例7: DelegateForTypeReturnedNull
internal static string DelegateForTypeReturnedNull(Type serviceType) =>
string.Format(CultureInfo.InvariantCulture,
"The registered delegate for type {0} returned null.", serviceType.TypeName());
示例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?");
}
示例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;
}
示例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);
}
示例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);
}
}
示例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));
示例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);
示例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);
示例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());