当前位置: 首页>>代码示例>>C#>>正文


C# ITypeDefinition.TryGetDescriptor方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:29,代码来源:Resolver.cs

示例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);
        }
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:21,代码来源:ColumnSchema.cs

示例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);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:33,代码来源:IndexDefinitionResolver.cs


注:本文中的ITypeDefinition.TryGetDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。