本文整理汇总了C#中System.Type.ToFriendlyName方法的典型用法代码示例。如果您正苦于以下问题:C# Type.ToFriendlyName方法的具体用法?C# Type.ToFriendlyName怎么用?C# Type.ToFriendlyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Type
的用法示例。
在下文中一共展示了Type.ToFriendlyName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NoRegistrationForTypeFound
internal static string NoRegistrationForTypeFound(Type serviceType, bool containerHasRegistrations)
{
return string.Format(CultureInfo.InvariantCulture,
"No registration for type {0} could be found.{1}",
serviceType.ToFriendlyName(),
ContainsHasNoRegistrationsAddition(containerHasRegistrations));
}
示例2: MakeTypePartiallyGenericUpToLevel
// This method takes generic type and returns a 'partially' generic type definition of that same type,
// where all generic arguments up to the given nesting level. This allows us to group generic types
// by their partial generic type definition, which allows a much nicer user experience.
internal static Type MakeTypePartiallyGenericUpToLevel(Type type, int nestingLevel)
{
if (nestingLevel > 100)
{
// Stack overflow prevention
throw new ArgumentException("nesting level bigger than 100 too high. Type: " +
type.ToFriendlyName(), nameof(nestingLevel));
}
// example given type: IEnumerable<IQueryProcessor<MyQuery<Alpha>, int[]>>
// nestingLevel 4 returns: IEnumerable<IQueryHandler<MyQuery<Alpha>, int[]>
// nestingLevel 3 returns: IEnumerable<IQueryHandler<MyQuery<Alpha>, int[]>
// nestingLevel 2 returns: IEnumerable<IQueryHandler<MyQuery<T>, int[]>
// nestingLevel 1 returns: IEnumerable<IQueryHandler<TQuery, TResult>>
// nestingLevel 0 returns: IEnumerable<T>
if (!type.IsGenericType)
{
return type;
}
if (nestingLevel == 0)
{
return type.GetGenericTypeDefinition();
}
return MakeTypePartiallyGeneric(type, nestingLevel);
}
示例3: ErrorWhileBuildingDelegateFromExpression
internal static string ErrorWhileBuildingDelegateFromExpression(Type serviceType,
Expression expression, Exception exception)
{
return string.Format(CultureInfo.InvariantCulture,
"Error occurred while trying to build a delegate for type {0} using the expression \"{1}\". " +
"{2}", serviceType.ToFriendlyName(), expression, exception.Message);
}
示例4: GetDebugValue
private static DebuggerViewItem[] GetDebugValue(Type implementationType, InstanceProducer[] dependencies)
{
return new[]
{
new DebuggerViewItem("ImplementationType", implementationType.ToFriendlyName(), implementationType),
new DebuggerViewItem("Dependencies", dependencies.Length + " dependencies.", dependencies),
};
}
开发者ID:MichaelSagalovich,项目名称:SimpleInjector,代码行数:8,代码来源:SingleResponsibilityViolationDiagnosticResult.cs
示例5: 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.ToFriendlyName(),
ContainerHasNoRegistrationsAddition(containerHasRegistrations),
DidYouMeanToCallGetInstanceInstead(containerHasRelatedOneToOneMapping, serviceType),
DidYouMeanToCallGetAllInstancesInstead(containerHasRelatedCollectionMapping, serviceType),
NoteThatSkippedDecoratorsWereFound(serviceType, skippedDecorators));
示例6: CreateMessage
static string CreateMessage(Type messageType, IEnumerable<Exception> exceptions)
{
SendException sendException = exceptions
.Where(x => x.GetType() == typeof(SendException))
.Cast<SendException>()
.FirstOrDefault();
if (sendException != null)
{
return string.Format("At least one exception occurred publishing {0} to {1}",
sendException.MessageType.ToFriendlyName(), sendException.Uri);
}
return string.Format("At least one exception occurred publishing {0}",
messageType.ToFriendlyName());
}
示例7: CreateDebugValue
private static DebuggerViewItem[] CreateDebugValue(Type implementationType, Lifestyle lifestyle,
InstanceProducer[] affectedRegistrations)
{
return new[]
{
new DebuggerViewItem(
name: "ImplementationType",
description: implementationType.ToFriendlyName(),
value: implementationType),
new DebuggerViewItem(
name: "Lifestyle",
description: lifestyle.Name,
value: lifestyle),
new DebuggerViewItem(
name: "Affected Registrations",
description: ToCommaSeparatedText(affectedRegistrations),
value: affectedRegistrations)
};
}
示例8: CreateDebugValue
private static DebuggerViewItem[] CreateDebugValue(Type implementationType, Lifestyle[] lifestyles,
InstanceProducer[] conflictingRegistrations)
{
return new[]
{
new DebuggerViewItem(
name: "ImplementationType",
description: implementationType.ToFriendlyName(),
value: implementationType),
new DebuggerViewItem(
name: "Lifestyles",
description: ToCommaSeparatedText(lifestyles),
value: lifestyles),
new DebuggerViewItem(
name: "Conflicting Registrations",
description: ToCommaSeparatedText(conflictingRegistrations),
value: conflictingRegistrations)
};
}
示例9: 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).ToFriendlyName(),
serviceType.ToFriendlyName())
: string.Empty;
示例10: DelegateForTypeThrewAnException
internal static string DelegateForTypeThrewAnException(Type serviceType) =>
string.Format(CultureInfo.InvariantCulture,
"The registered delegate for type {0} threw an exception.", serviceType.ToFriendlyName());
示例11: 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 registration for {3} that you are trying to make. This new " +
"registration would cause ambiguity, because both registrations would be used for the " +
"same closed service types. {4}",
isExistingRegistrationConditional ? "conditional " : string.Empty,
openGenericServiceType.ToFriendlyName(),
overlappingImplementationType.ToFriendlyName(),
implementationTypeOfNewRegistration.ToFriendlyName(),
solution);
}
示例12: 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.ToFriendlyName(),
serviceTypeParamName,
Helpers.ToCSharpFriendlyName(openGenericServiceType.GetGenericTypeDefinition()),
implementationTypeParamName);
示例13: 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.ToFriendlyName(), serviceType.ToFriendlyName());
示例14: OpenGenericTypeContainsUnresolvableTypeArguments
internal static string OpenGenericTypeContainsUnresolvableTypeArguments(Type openGenericImplementation) =>
string.Format(CultureInfo.InvariantCulture,
"The supplied type {0} contains unresolvable type arguments. " +
"The type would never be resolved and is therefore not suited to be used.",
openGenericImplementation.ToFriendlyName());
示例15: TheConstructorOfTypeMustContainASingleInstanceOfTheServiceTypeAsArgument
internal static string TheConstructorOfTypeMustContainASingleInstanceOfTheServiceTypeAsArgument(
Type decoratorType, Type serviceType) =>
string.Format(CultureInfo.InvariantCulture,
"For the container to be able to use {0} as a decorator, its constructor must include a " +
"single parameter of type {1} (or Func<{1}>) - i.e. the type of the instance that is being " +
"decorated. The parameter type {1} is defined multiple times in the constructor of class {0}.",
decoratorType.ToFriendlyName(), serviceType.ToFriendlyName());