本文整理汇总了C#中CodeGenerationContext.GetPrefixedFullName方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerationContext.GetPrefixedFullName方法的具体用法?C# CodeGenerationContext.GetPrefixedFullName怎么用?C# CodeGenerationContext.GetPrefixedFullName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenerationContext
的用法示例。
在下文中一共展示了CodeGenerationContext.GetPrefixedFullName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetClrTypeName
/// <summary>
/// Gets the clr type name from the give type reference.
/// </summary>
/// <param name="edmTypeReference">The type reference in question.</param>
/// <param name="useDataServiceCollection">true to use the DataServicCollection type for entity collections and the ObservableCollection type for non-entity collections,
/// false to use Collection for collections.</param>
/// <param name="clientTemplate">ODataClientTemplate instance that call this method.</param>
/// <param name="context">CodeGenerationContext instance in the clientTemplate.</param>
/// <param name="addNullableTemplate">This flag indicates whether to return the type name in nullable format</param>
/// <param name="needGlobalPrefix">The flag indicates whether the namespace need to be added by global prefix</param>
/// <param name="isOperationParameter">This flag indicates whether the edmTypeReference is for an operation parameter</param>
/// <returns>The clr type name of the type reference.</returns>
internal static string GetClrTypeName(IEdmTypeReference edmTypeReference, bool useDataServiceCollection, ODataClientTemplate clientTemplate, CodeGenerationContext context, bool addNullableTemplate = true, bool needGlobalPrefix = true, bool isOperationParameter = false)
{
string clrTypeName;
var edmType = edmTypeReference.Definition;
var edmPrimitiveType = edmType as IEdmPrimitiveType;
if (edmPrimitiveType != null)
{
clrTypeName = GetClrTypeName(edmPrimitiveType, clientTemplate);
if (edmTypeReference.IsNullable && !clientTemplate.ClrReferenceTypes.Contains(edmPrimitiveType.PrimitiveKind) && addNullableTemplate)
{
clrTypeName = string.Format(clientTemplate.SystemNullableStructureTemplate, clrTypeName);
}
}
else
{
var edmComplexType = edmType as IEdmComplexType;
if (edmComplexType != null)
{
clrTypeName = context.GetPrefixedFullName(edmComplexType,
context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmComplexType.Name)) : clientTemplate.GetFixedName(edmComplexType.Name), clientTemplate);
}
else
{
var edmEnumType = edmType as IEdmEnumType;
if (edmEnumType != null)
{
clrTypeName = context.GetPrefixedFullName(edmEnumType,
context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEnumType.Name)) : clientTemplate.GetFixedName(edmEnumType.Name), clientTemplate, needGlobalPrefix);
if (edmTypeReference.IsNullable && addNullableTemplate)
{
clrTypeName = string.Format(clientTemplate.SystemNullableStructureTemplate, clrTypeName);
}
}
else
{
var edmEntityType = edmType as IEdmEntityType;
if (edmEntityType != null)
{
clrTypeName = context.GetPrefixedFullName(edmEntityType,
context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(edmEntityType.Name)) : clientTemplate.GetFixedName(edmEntityType.Name), clientTemplate);
}
else
{
var edmCollectionType = (IEdmCollectionType)edmType;
var elementTypeReference = edmCollectionType.ElementType;
var primitiveElementType = elementTypeReference.Definition as IEdmPrimitiveType;
if (primitiveElementType != null)
{
clrTypeName = GetClrTypeName(primitiveElementType, clientTemplate);
}
else
{
var schemaElement = (IEdmSchemaElement)elementTypeReference.Definition;
clrTypeName = context.GetPrefixedFullName(schemaElement,
context.EnableNamingAlias ? clientTemplate.GetFixedName(Customization.CustomizeNaming(schemaElement.Name)) : clientTemplate.GetFixedName(schemaElement.Name), clientTemplate);
}
var collectionTypeName = isOperationParameter
? clientTemplate.CollectionOfTStructureTemplate
: (useDataServiceCollection
? (elementTypeReference.TypeKind() == EdmTypeKind.Entity
? clientTemplate.DataServiceCollectionStructureTemplate
: clientTemplate.ObservableCollectionStructureTemplate)
: clientTemplate.ObjectModelCollectionStructureTemplate);
clrTypeName = string.Format(collectionTypeName, clrTypeName);
}
}
}
}
return clrTypeName;
}