本文整理汇总了C#中ITypeDefinition.TryGetDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefinition.TryGetDescriptor方法的具体用法?C# ITypeDefinition.TryGetDescriptor怎么用?C# ITypeDefinition.TryGetDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDefinition
的用法示例。
在下文中一共展示了ITypeDefinition.TryGetDescriptor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractSchemaFromTypeDefinition
/// <summary>
/// Extracts schema info from <paramref name="type"/>.
/// </summary>
/// <param name="context"></param>
/// <param name="type"></param>
/// <param name="schema"></param>
private static void ExtractSchemaFromTypeDefinition(IMansionContext context, ITypeDefinition type, Schema schema)
{
// check if this type has a table declaration
TypeTableDescriptor tableDescriptor;
if (type.TryGetDescriptor(out tableDescriptor))
{
var table = tableDescriptor.Create(context, type);
// add the table to schema
schema.Add(table);
}
// check if the type has property table declaration
foreach (var property in type.Properties)
{
PropertyTableDescriptor propertyTableDescriptor;
if (!property.TryGetDescriptor(out propertyTableDescriptor))
continue;
// create the table
propertyTableDescriptor.Create(context, schema, property);
}
}
示例2: GetSchema
/// <summary>
/// Gets the <see cref="ColumnSchema"/> of <paramref name="type"/>.
/// </summary>
/// <param name="context">The request context.</param>
/// <param name="type">The <see cref="ITypeDefinition" /> of the type from which to get the column scheme.</param>
/// <returns>Returns the <see cref="ColumnSchema"/>.</returns>
public static ColumnSchema GetSchema(IMansionContext context, ITypeDefinition type)
{
// validate arguments
if (context == null)
throw new ArgumentNullException("context");
if (type == null)
throw new ArgumentNullException("type");
// get the schema descriptor
ColumnSchemaDescriptor descriptor;
if (!type.TryGetDescriptor(out descriptor))
throw new InvalidOperationException(string.Format("The type '{0}' does not provide a schema", type.Name));
return descriptor.GetSchema(context);
}
示例3: MapType
/// <summary>
/// Maps the given <paramref name="type"/> in <paramref name="typeMapping"/>.
/// </summary>
/// <param name="context">The <see cref="IMansionContext"/>.</param>
/// <param name="definition">The <see cref="IndexDefinition"/>.</param>
/// <param name="type">The <see cref="ITypeDefinition"/>.</param>
/// <param name="typeMapping">The <see cref="TypeMapping"/>.</param>
private static void MapType(IMansionContext context, IndexDefinition definition, ITypeDefinition type, TypeMapping typeMapping)
{
// map the type descriptor, if any
TypeMapping.TypeMappingDescriptor descriptor;
if (type.TryGetDescriptor(out descriptor))
descriptor.UpdateMapping(context, typeMapping);
// map all the properties of this type
MapProperties(context, type, typeMapping);
// map all the analysis components defined on this type
MapAnalysisComponents(context, type, definition);
// loop over all the children of this type
foreach (var childType in type.GetChildTypes(context))
{
// clone the parent mapping, children should include the properties of the parent
var childMapping = typeMapping.Clone(childType);
// map the the child
MapType(context, definition, childType, childMapping);
}
// append the mapping to the index definition
definition.Add(typeMapping);
}