• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TypeAttributes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TypeAttributes的典型用法代码示例。如果您正苦于以下问题:C# TypeAttributes类的具体用法?C# TypeAttributes怎么用?C# TypeAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TypeAttributes类属于命名空间,在下文中一共展示了TypeAttributes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
            }
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:29,代码来源:RuntimeType.cs


示例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;
        }
开发者ID:dubik,项目名称:csharprpp,代码行数:30,代码来源:RTypeUtils.cs


示例3: CreateTypeBuilder

		private static TypeBuilder CreateTypeBuilder(AbstractTypeEmitter maintype, string name, TypeAttributes attributes, Type baseType, Type[] interfaces)
		{
			return maintype.TypeBuilder.DefineNestedType(
				name,
				attributes,
				baseType, interfaces);
		}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:7,代码来源:NestedClassEmitter.cs


示例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);
 }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:TypeBuilderMakeArrayType.cs


示例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;
 }
开发者ID:Rex-Hays,项目名称:GNIDA,代码行数:7,代码来源:TypeDefinition.cs


示例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();
        }
开发者ID:RockFramework,项目名称:Rock.Core,代码行数:30,代码来源:Create.cs


示例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);
 }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:TypeBuilderMakePointerType.cs


示例8: StructureBuilder

	public StructureBuilder (NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr) 
	    : base (BundleManagerBase.DefaultStructureClass, ns, loc, attr)
	{
	    BaseClass = new UserType (typeof (StructureTemplate));

	    ns.SetUserParams (this);
	}
开发者ID:emtees,项目名称:old-code,代码行数:7,代码来源:StructureBuilder.cs


示例9: Class

 public static CodeTypeDeclaration Class(string className, TypeAttributes attributes)
 {
     return new CodeTypeDeclaration(className)
     {
         TypeAttributes = attributes
     };
 }
开发者ID:laymain,项目名称:CodeDomUtils,代码行数:7,代码来源:Class.cs


示例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);
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:59,代码来源:TypeBuilderDefineNestedType.cs


示例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);
	    }
开发者ID:emtees,项目名称:old-code,代码行数:8,代码来源:EnumResultBuilder.cs


示例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);
	}
开发者ID:emtees,项目名称:old-code,代码行数:8,代码来源:EnumResultBuilder.cs


示例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);
		}
开发者ID:codetuner,项目名称:Arebis.Common,代码行数:8,代码来源:ModifierMatchingRule.cs


示例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;
 }
开发者ID:B-head,项目名称:Dreit-prototype,代码行数:8,代码来源:TypeStructure.cs


示例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());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:TypeBuilderCreateType.cs


示例16: MetaRuleBuilder

	public MetaRuleBuilder (string name, NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr)
	{
	    rb = new RuleBuilder (name, ns, loc, attr);
	    tmpl = new RuleTemplateBuilder (name + "RTemplate", rb, ns, loc, attr);

	    ns.AddMetaRule (this);
	    BaseClass = RuleType;
	}
开发者ID:emtees,项目名称:old-code,代码行数:8,代码来源:MetaRuleBuilder.cs


示例17: Read

 public void Read(ClrModuleReader reader)
 {
     this.Flags = (TypeAttributes)reader.Binary.ReadUInt32();
     this.TypeDefId = reader.Binary.ReadUInt32();
     this.TypeName = reader.ReadString();
     this.TypeNamespace = reader.ReadString();
     this.Implementation = reader.ReadCodedIndex<Implementation>();
 }
开发者ID:BGCX261,项目名称:zoompe-git,代码行数:8,代码来源:ExportedTypeEntry.cs


示例18: Initialize

 internal void Initialize(string name, TypeAttributes attr, IReadOnlyList<GenericParameterStructure> gnr, TypeStructure bt, IReadOnlyList<TypeStructure> imp, BlockStructure block = null, Type info = null)
 {
     Generics = gnr;
     BaseType = bt;
     Implements = imp;
     AppendChild(Generics);
     base.Initialize(name, attr, block, info);
 }
开发者ID:B-head,项目名称:Dreit-prototype,代码行数:8,代码来源:PureTypeStructure.cs


示例19: GetILGenerator_NoMethodBody_ThrowsInvalidOperationException

        public void GetILGenerator_NoMethodBody_ThrowsInvalidOperationException(TypeAttributes typeAttributes, MethodAttributes methodAttributes)
        {
            TypeBuilder type = Helpers.DynamicType(typeAttributes);
            MethodBuilder method = type.DefineMethod("TestMethod", methodAttributes);

            Assert.Throws<InvalidOperationException>(() => method.GetILGenerator());
            Assert.Throws<InvalidOperationException>(() => method.GetILGenerator(10));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:8,代码来源:MethodBuilderGetILGenerator.cs


示例20: DefineType

        public void DefineType(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.NotPublic;

            Action<TypeBuilder, Module> verify = (type, module) =>
            {
                Type baseType = attributes.HasFlag(TypeAttributes.Abstract) && parent == null ? null : (parent ?? typeof(object));
                Helpers.VerifyType(type, module, null, name, attributes, baseType, typesize, packingSize, implementedInterfaces);
            };

            if (isDefaultImplementedInterfaces)
            {
                if (isDefaultSize && isDefaultPackingSize)
                {
                    if (isDefaultParent)
                    {
                        if (isDefaultAttributes)
                        {
                            // Use DefineType(string)
                            ModuleBuilder module1 = Helpers.DynamicModule();
                            verify(module1.DefineType(name), module1);
                        }
                        // Use DefineType(string, TypeAttributes)
                        ModuleBuilder module2 = Helpers.DynamicModule();
                        verify(module2.DefineType(name, attributes), module2);
                    }
                    // Use DefineType(string, TypeAttributes, Type)
                    ModuleBuilder module3 = Helpers.DynamicModule();
                    verify(module3.DefineType(name, attributes, parent), module3);
                }
                else if (isDefaultSize)
                {
                    // Use DefineType(string, TypeAttributes, Type, PackingSize)
                    ModuleBuilder module4 = Helpers.DynamicModule();
                    verify(module4.DefineType(name, attributes, parent, packingSize), module4);
                }
                else if (isDefaultPackingSize)
                {
                    // Use DefineType(string, TypeAttributes, Type, int)
                    ModuleBuilder module5 = Helpers.DynamicModule();
                    verify(module5.DefineType(name, attributes, parent, typesize), module5);
                }
                // Use DefineType(string, TypeAttributes, Type, PackingSize, int)
                ModuleBuilder module6 = Helpers.DynamicModule();
                verify(module6.DefineType(name, attributes, parent, packingSize, typesize), module6);
            }
            else
            {
                // Use DefineType(string, TypeAttributes, Type, Type[])
                Assert.True(isDefaultSize && isDefaultPackingSize); // Sanity check
                ModuleBuilder module7 = Helpers.DynamicModule();
                verify(module7.DefineType(name, attributes, parent, implementedInterfaces), module7);
            }
        }
开发者ID:Corillian,项目名称:corefx,代码行数:58,代码来源:ModuleBuilderDefineType.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TypeBase类代码示例发布时间:2022-05-24
下一篇:
C# Type类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap