本文整理汇总了C#中TypeAttributes类的典型用法代码示例。如果您正苦于以下问题:C# TypeAttributes类的具体用法?C# TypeAttributes怎么用?C# TypeAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeAttributes类属于命名空间,在下文中一共展示了TypeAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RuntimeType
internal RuntimeType(RuntimeTypeHandle handle)
{
this.handle = handle;
typeStruct = (MetadataTypeStruct*)((uint**)&handle)[0];
assemblyQualifiedName = Mosa.Runtime.Internal.InitializeMetadataString(typeStruct->Name); // TODO
name = Mosa.Runtime.Internal.InitializeMetadataString(typeStruct->Name); // TODO
@namespace = Mosa.Runtime.Internal.InitializeMetadataString(typeStruct->Name); // TODO
fullname = Mosa.Runtime.Internal.InitializeMetadataString(typeStruct->Name);
typeCode = (TypeCode)(typeStruct->Attributes >> 24);
attributes = (TypeAttributes)(typeStruct->Attributes & 0x00FFFFFF);
// Declaring Type
if (typeStruct->DeclaringType != null)
{
RuntimeTypeHandle declaringHandle = new RuntimeTypeHandle();
((uint**)&declaringHandle)[0] = (uint*)typeStruct->DeclaringType;
declaringTypeHandle = declaringHandle;
}
// Element Type
if ((*typeStruct).ElementType != null)
{
RuntimeTypeHandle elementHandle = new RuntimeTypeHandle();
((uint**)&elementHandle)[0] = (uint*)typeStruct->ElementType;
elementTypeHandle = elementHandle;
}
}
示例2: GetRTypeAttributes
public static RTypeAttributes GetRTypeAttributes(TypeAttributes attrs, bool isValueType)
{
RTypeAttributes rAttrs = 0;
TypeAttributes visibility = attrs & TypeAttributes.VisibilityMask;
if (visibility == TypeAttributes.NotPublic)
{
rAttrs |= RTypeAttributes.Private;
}
else if (visibility == TypeAttributes.Public)
{
rAttrs |= RTypeAttributes.Public;
}
TypeAttributes classSemantics = attrs & TypeAttributes.ClassSemanticsMask;
if (classSemantics == TypeAttributes.Class && !isValueType)
{
rAttrs |= RTypeAttributes.Class;
}
else if (classSemantics == TypeAttributes.Interface)
{
rAttrs |= RTypeAttributes.Interface;
}
if ((attrs & TypeAttributes.Sealed) != 0)
{
rAttrs |= RTypeAttributes.Sealed;
}
return rAttrs;
}
示例3: CreateTypeBuilder
private static TypeBuilder CreateTypeBuilder(AbstractTypeEmitter maintype, string name, TypeAttributes attributes, Type baseType, Type[] interfaces)
{
return maintype.TypeBuilder.DefineNestedType(
name,
attributes,
baseType, interfaces);
}
示例4: MakeArrayType_Int_Three
public void MakeArrayType_Int_Three(TypeAttributes attributes)
{
TypeBuilder type = Helpers.DynamicType(attributes);
Type arrayType = type.MakeArrayType(3);
Assert.Equal(typeof(Array), arrayType.GetTypeInfo().BaseType);
Assert.Equal("TestType[,,]", arrayType.Name);
}
示例5: TypeDefinition
public TypeDefinition(string @namespace, string name, TypeAttributes attributes, TypeReference baseType, uint fieldList, uint methodList)
: base(new MetaDataRow((uint)attributes, 0U, 0U, 0U, fieldList, methodList))
{
this._namespace = @namespace;
this._name = name;
this._baseType = baseType;
}
示例6: Type
private static Type Type(
string name, Type[] interfaces, MemberDefinition[] memberDefinitions,
TypeAttributes typeAttributes, Type baseType = null)
{
if (name == null) throw new ArgumentNullException("name");
if (interfaces == null) throw new ArgumentNullException("interfaces");
if (memberDefinitions == null) throw new ArgumentNullException("memberDefinitions");
var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
new AssemblyName(name), AssemblyBuilderAccess.Run);
var moduleBuilder = assemblyBuilder.DefineDynamicModule("MainModule");
var typeBuilder = moduleBuilder.DefineType(name, typeAttributes, baseType, interfaces);
var fields = new List<FieldBuilder>();
foreach (var definition in memberDefinitions.OrderBy(d => d is ConstructorDefinition))
{
definition.EmitTo(typeBuilder, fields);
}
if (baseType != typeof(ValueType)
&& !memberDefinitions.Any(d => d is ConstructorDefinition))
{
Define.Constructor().EmitTo(typeBuilder, fields);
}
return typeBuilder.CreateType();
}
示例7: MakePointerType
public void MakePointerType(TypeAttributes attributes)
{
TypeBuilder type = Helpers.DynamicType(attributes);
Type arrayType = type.MakePointerType();
Assert.Equal(typeof(Array), arrayType.GetTypeInfo().BaseType);
Assert.Equal("TestType*", arrayType.Name);
}
示例8: StructureBuilder
public StructureBuilder (NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr)
: base (BundleManagerBase.DefaultStructureClass, ns, loc, attr)
{
BaseClass = new UserType (typeof (StructureTemplate));
ns.SetUserParams (this);
}
示例9: Class
public static CodeTypeDeclaration Class(string className, TypeAttributes attributes)
{
return new CodeTypeDeclaration(className)
{
TypeAttributes = attributes
};
}
示例10: DefineNestedType
public void DefineNestedType(string name, TypeAttributes attributes, Type parent, PackingSize packingSize, int typesize, Type[] implementedInterfaces)
{
bool isDefaultImplementedInterfaces = implementedInterfaces?.Length == 0;
bool isDefaultPackingSize = packingSize == PackingSize.Unspecified;
bool isDefaultSize = typesize == 0;
bool isDefaultParent = parent == null;
bool isDefaultAttributes = attributes == TypeAttributes.NestedPrivate;
Action<TypeBuilder, TypeBuilder> verify = (type, declaringType) =>
{
bool allowsNullParent = attributes.HasFlag(TypeAttributes.Abstract) && attributes.HasFlag(TypeAttributes.ClassSemanticsMask);
Type baseType = allowsNullParent ? parent : (parent ?? typeof(object));
Helpers.VerifyType(type, declaringType.Module, declaringType, name, attributes, baseType, typesize, packingSize, implementedInterfaces);
};
if (isDefaultImplementedInterfaces)
{
if (isDefaultSize && isDefaultPackingSize)
{
if (isDefaultParent)
{
if (isDefaultAttributes)
{
// Use DefineNestedType(string)
TypeBuilder type1 = Helpers.DynamicType(TypeAttributes.Public);
verify(type1.DefineNestedType(name), type1);
}
// Use DefineNestedType(string, TypeAttributes)
TypeBuilder type2 = Helpers.DynamicType(TypeAttributes.Public);
verify(type2.DefineNestedType(name, attributes), type2);
}
// Use DefineNestedType(string, TypeAttributes, Type)
TypeBuilder type3 = Helpers.DynamicType(TypeAttributes.Public);
verify(type3.DefineNestedType(name, attributes, parent), type3);
}
else if (isDefaultSize)
{
// Use DefineNestedType(string, TypeAttributes, Type, PackingSize)
TypeBuilder type4 = Helpers.DynamicType(TypeAttributes.Public);
verify(type4.DefineNestedType(name, attributes, parent, packingSize), type4);
}
else if (isDefaultPackingSize)
{
// Use DefineNestedType(string, TypeAttributes, Type, int)
TypeBuilder type5 = Helpers.DynamicType(TypeAttributes.Public);
verify(type5.DefineNestedType(name, attributes, parent, typesize), type5);
}
// Use DefineNestedType(string, TypeAttributes, Type, PackingSize, int);
TypeBuilder type6 = Helpers.DynamicType(TypeAttributes.Public);
verify(type6.DefineNestedType(name, attributes, parent, packingSize, typesize), type6);
}
else
{
// Use DefineNestedType(string, TypeAttributes, Type, Type[])
Assert.True(isDefaultSize && isDefaultPackingSize); // Sanity check
TypeBuilder type7 = Helpers.DynamicType(TypeAttributes.Public);
verify(type7.DefineNestedType(name, attributes, parent, implementedInterfaces), type7);
}
}
示例11: TheResult
public TheResult (string name, NamespaceBuilder ns, string ename, CodeLinePragma loc, TypeAttributes attr)
: base (name, ns, loc, attr)
{
etype = new UserType (ename);
BaseClass = new UserType (typeof (EnumResult<>));
BaseClass.AddTypeArgument (etype);
}
示例12: EnumResultBuilder
public EnumResultBuilder (string name, NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr)
{
if (name == null)
throw new ArgumentNullException ();
enumer = new TheEnum (name, ns, loc, attr);
result = new TheResult (name + "Result", ns, name, loc, attr);
}
示例13: InitializeType
private void InitializeType(XmlNode ruleInstance)
{
string modifierstring = ruleInstance.Attributes["modifiers"].Value;
foreach (string s in modifierstring.Split(','))
this.typeAttributes =
this.typeAttributes
| (TypeAttributes)Enum.Parse(typeof(TypeAttributes), s.Trim(), true);
}
示例14: Initialize
public void Initialize(string name, TypeAttributes attr, BlockStructure block = null, Type info = null)
{
Name = name;
Attributes = attr;
Block = block;
AppendChild(Block);
Info = info;
}
示例15: CreateType
public void CreateType(TypeAttributes attributes)
{
TypeBuilder type = Helpers.DynamicType(attributes);
Type createdType = type.CreateTypeInfo().AsType();
Assert.Equal(type.Name, createdType.Name);
Assert.Equal(type.CreateTypeInfo(), type.CreateTypeInfo());
}