本文整理汇总了C#中Type.IsAbstract方法的典型用法代码示例。如果您正苦于以下问题:C# Type.IsAbstract方法的具体用法?C# Type.IsAbstract怎么用?C# Type.IsAbstract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type.IsAbstract方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsStructuralTypeConfiguration
private static bool IsStructuralTypeConfiguration(Type type, Type structuralTypeConfiguration)
{
DebugCheck.NotNull(type);
DebugCheck.NotNull(structuralTypeConfiguration);
return !type.IsAbstract() && type.TryGetElementType(structuralTypeConfiguration) != null;
}
示例2: ClrEntityType
// <summary>
// Initializes a new instance of Complex Type with properties from the type.
// </summary>
// <param name="type"> The CLR type to construct from </param>
internal ClrEntityType(Type type, string cspaceNamespaceName, string cspaceTypeName)
: base(Check.NotNull(type, "type").Name, type.NestingNamespace() ?? string.Empty,
DataSpace.OSpace)
{
DebugCheck.NotEmpty(cspaceNamespaceName);
DebugCheck.NotEmpty(cspaceTypeName);
_type = type;
_cspaceNamespaceName = cspaceNamespaceName;
_cspaceTypeName = cspaceNamespaceName + "." + cspaceTypeName;
Abstract = type.IsAbstract();
}
示例3: CreateColumnMapFromReaderAndClrType
internal virtual CollectionColumnMap CreateColumnMapFromReaderAndClrType(
DbDataReader reader, Type type, MetadataWorkspace workspace)
{
DebugCheck.NotNull(reader);
DebugCheck.NotNull(type);
DebugCheck.NotNull(workspace);
// we require a default constructor
var constructor = type.GetDeclaredConstructor();
if (type.IsAbstract()
|| (null == constructor && !type.IsValueType()))
{
throw new InvalidOperationException(Strings.ObjectContext_InvalidTypeForStoreQuery(type));
}
// build a LINQ expression used by result assembly to create results
var memberInfo = new List<Tuple<MemberAssignment, int, EdmProperty>>();
foreach (var prop in type.GetInstanceProperties()
.Select(p => p.GetPropertyInfoForSet()))
{
// for enums unwrap the type if nullable
var propertyUnderlyingType = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
var propType = propertyUnderlyingType.IsEnum() ? propertyUnderlyingType.GetEnumUnderlyingType() : prop.PropertyType;
EdmType modelType;
int ordinal;
if (TryGetColumnOrdinalFromReader(reader, prop.Name, out ordinal)
&& workspace.TryDetermineCSpaceModelType(propType, out modelType)
&& (Helper.IsScalarType(modelType))
&& prop.CanWriteExtended()
&& prop.GetIndexParameters().Length == 0
&& null != prop.Setter())
{
memberInfo.Add(
Tuple.Create(
Expression.Bind(prop, Expression.Parameter(prop.PropertyType, "placeholder")),
ordinal,
new EdmProperty(prop.Name, TypeUsage.Create(modelType))));
}
}
// initialize members in the order in which they appear in the reader
var members = new MemberInfo[memberInfo.Count];
var memberBindings = new MemberBinding[memberInfo.Count];
var propertyMaps = new ColumnMap[memberInfo.Count];
var modelProperties = new EdmProperty[memberInfo.Count];
var i = 0;
foreach (var memberGroup in memberInfo.GroupBy(tuple => tuple.Item2).OrderBy(tuple => tuple.Key))
{
// make sure that a single column isn't contributing to multiple properties
if (memberGroup.Count() != 1)
{
throw new InvalidOperationException(
Strings.ObjectContext_TwoPropertiesMappedToSameColumn(
reader.GetName(memberGroup.Key),
String.Join(", ", memberGroup.Select(tuple => tuple.Item3.Name).ToArray())));
}
var member = memberGroup.Single();
var assignment = member.Item1;
var ordinal = member.Item2;
var modelProp = member.Item3;
members[i] = assignment.Member;
memberBindings[i] = assignment;
propertyMaps[i] = new ScalarColumnMap(modelProp.TypeUsage, modelProp.Name, 0, ordinal);
modelProperties[i] = modelProp;
i++;
}
var newExpr = null == constructor ? Expression.New(type) : Expression.New(constructor);
var init = Expression.MemberInit(newExpr, memberBindings);
var initMetadata = InitializerMetadata.CreateProjectionInitializer(
(EdmItemCollection)workspace.GetItemCollection(DataSpace.CSpace), init);
// column map (a collection of rows with InitializerMetadata markup)
var rowType = new RowType(modelProperties, initMetadata);
var rowMap = new RecordColumnMap(
TypeUsage.Create(rowType),
"DefaultTypeProjection", propertyMaps, null);
CollectionColumnMap collectionMap = new SimpleCollectionColumnMap(
rowType.GetCollectionType().TypeUsage,
rowType.Name, rowMap, null, null);
return collectionMap;
}
示例4: ClrComplexType
// <summary>
// Initializes a new instance of Complex Type with properties from the type.
// </summary>
// <param name="clrType"> The CLR type to construct from </param>
internal ClrComplexType(Type clrType, string cspaceNamespaceName, string cspaceTypeName)
: base(Check.NotNull(clrType, "clrType").Name, clrType.NestingNamespace() ?? string.Empty,
DataSpace.OSpace)
{
DebugCheck.NotEmpty(cspaceNamespaceName);
DebugCheck.NotEmpty(cspaceTypeName);
_type = clrType;
_cspaceTypeName = cspaceNamespaceName + "." + cspaceTypeName;
Abstract = clrType.IsAbstract();
}