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


C# EventAttributes类代码示例

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


EventAttributes类属于命名空间,在下文中一共展示了EventAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GeneralNegativeTest

        public void GeneralNegativeTest(string name, EventAttributes attrs, Type eventType, Type expected)
        {
            AssemblyName myAsmName =
                new AssemblyName("TypeBuilderGetFieldTest");
            AssemblyBuilder myAssembly = AssemblyBuilder.DefineDynamicAssembly(
                myAsmName, AssemblyBuilderAccess.Run);
            ModuleBuilder myModule = TestLibrary.Utilities.GetModuleBuilder(myAssembly, "Module1");


            TypeBuilder myType = myModule.DefineType("Sample",
                TypeAttributes.Class | TypeAttributes.Public);

            string[] typeParamNames = { "T" };
            GenericTypeParameterBuilder[] typeParams =
                myType.DefineGenericParameters(typeParamNames);

            if (expected != null)
            {
                Action test = () =>
                {
                    myType.DefineEvent(name, attrs, eventType);
                    Type t = myType.CreateTypeInfo().AsType();
                };

                Assert.Throws(expected, test);
            }
            else
            {
                Type t1 = myType.CreateTypeInfo().AsType();
            }
        }
开发者ID:timbarrass,项目名称:corefx,代码行数:31,代码来源:TypeBuilderDefineEvent.cs

示例2: EventBuilder

	// Constructor.
	internal EventBuilder(TypeBuilder type, String name,
						  EventAttributes attributes, Type eventType)
			{
				// Validate the parameters.
				if(name == null)
				{
					throw new ArgumentNullException("name");
				}
				else if(eventType == null)
				{
					throw new ArgumentNullException("eventType");
				}

				// Register this item to be detached later.
				type.module.assembly.AddDetach(this);

				// Create the event.
				lock(typeof(AssemblyBuilder))
				{
					this.type = type;
					this.privateData = ClrEventCreate
						(((IClrProgramItem)type).ClrHandle, name,
					 	SignatureHelper.CSToILType(type.module, eventType),
					 	attributes);
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:27,代码来源:EventBuilder.cs

示例3: EventToGenerate

		/// <summary>
		/// Initializes a new instance of the <see cref="EventToGenerate"/> class.
		/// </summary>
		/// <param name="emitter">The emitter.</param>
		/// <param name="addMethod">The add method.</param>
		/// <param name="removeMethod">The remove method.</param>
		/// <param name="attributes">The attributes.</param>
		public EventToGenerate(EventEmitter emitter, MethodInfo addMethod, MethodInfo removeMethod, EventAttributes attributes)
		{
			this.addMethod = addMethod;
			this.removeMethod = removeMethod;
			this.emitter = emitter;
			this.attributes = attributes;
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:14,代码来源:EventToGenerate.cs

示例4: DefineEvent

        public void DefineEvent(string name, EventAttributes attributes, Type eventType, string expectedName, EventAttributes expectedAttributes)
        {
            TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
            type.DefineGenericParameters("T");

            EventBuilder eventBuilder = type.DefineEvent(name, attributes, eventType);
            MethodBuilder addOnMethod = type.DefineMethod("addOnMethod", MethodAttributes.Public);
            addOnMethod.GetILGenerator().Emit(OpCodes.Ret);

            MethodBuilder removeOnMethod = type.DefineMethod("removeOnMethod", MethodAttributes.Public);
            removeOnMethod.GetILGenerator().Emit(OpCodes.Ret);

            eventBuilder.SetAddOnMethod(addOnMethod);
            eventBuilder.SetRemoveOnMethod(removeOnMethod);

            Type createdType = type.CreateTypeInfo().AsType();
            Assert.Equal(type.AsType().GetEvents(Helpers.AllFlags), createdType.GetEvents(Helpers.AllFlags));
            Assert.Equal(type.AsType().GetEvent(expectedName, Helpers.AllFlags), createdType.GetEvent(expectedName, Helpers.AllFlags));

            EventInfo eventInfo = createdType.GetEvent(expectedName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
            Assert.Equal(expectedName, eventInfo.Name);
            Assert.Equal(createdType, eventInfo.DeclaringType);
            Assert.Equal(expectedAttributes, eventInfo.Attributes);
            Assert.Equal((expectedAttributes & EventAttributes.SpecialName) != 0, eventInfo.IsSpecialName);
            Assert.Null(eventInfo.EventHandlerType);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:26,代码来源:TypeBuilderDefineEvent.cs

示例5: EventBuilder

#pragma warning restore 169, 414

		internal EventBuilder (TypeBuilder tb, string eventName, EventAttributes eventAttrs, Type eventType) {
			name = eventName;
			attrs = eventAttrs;
			type = eventType;
			typeb = tb;
			table_idx = get_next_table_index (this, 0x14, true);
		}
开发者ID:carrie901,项目名称:mono,代码行数:9,代码来源:EventBuilder.cs

示例6: EventBuilder

		internal EventBuilder(TypeBuilder typeBuilder, string name, EventAttributes attributes, Type eventtype)
		{
			this.typeBuilder = typeBuilder;
			this.name = name;
			this.attributes = attributes;
			this.eventtype = typeBuilder.ModuleBuilder.GetTypeTokenForMemberRef(eventtype);
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:7,代码来源:EventBuilder.cs

示例7: EventEmitter

		public EventEmitter(AbstractTypeEmitter typeEmitter, string name, EventAttributes attributes, Type type)
		{
			this.typeEmitter = typeEmitter;
			this.type = type;
			this.name = name;
			eventBuilder = typeEmitter.TypeBuilder.DefineEvent(name, attributes, type);
		}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:EventEmitter.cs

示例8: EventDefinition

 public EventDefinition(string name, TypeReference eventType,
     EventAttributes attrs)
     : base(name)
 {
     m_eventType = eventType;
     m_attributes = attrs;
 }
开发者ID:leftouterjoin,项目名称:loj-prj1,代码行数:7,代码来源:EventDefinition.cs

示例9: EventEmitter

		public EventEmitter(AbstractTypeEmitter typeEmitter, string name, EventAttributes attributes, Type type)
		{
			if (name == null) throw new ArgumentNullException("name");
			if (type == null) throw new ArgumentNullException("type");
			this.typeEmitter = typeEmitter;
			this.type = type;
			eventBuilder = typeEmitter.TypeBuilder.DefineEvent(name, attributes, type);
		}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:8,代码来源:EventEmitter.cs

示例10: EventBuilder

 internal EventBuilder(ModuleBuilder mod, string name, EventAttributes attr, TypeBuilder type, EventToken evToken)
 {
     this.m_name = name;
     this.m_module = mod;
     this.m_attributes = attr;
     this.m_evToken = evToken;
     this.m_type = type;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:EventBuilder.cs

示例11: EventBuilder

     // Constructs a EventBuilder.  
 	//
     internal EventBuilder(
 		Module			mod,					// the module containing this EventBuilder		
 		String			name,					// Event name
 		EventAttributes attr,					// event attribute such as Public, Private, and Protected defined above
 		int				eventType,				// event type
 		TypeBuilder     type,                   // containing type
         EventToken		evToken)
     {   		
         m_name = name;
         m_module = mod;
         m_attributes = attr;
 		m_evToken = evToken;
         m_type = type;
     }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:16,代码来源:eventbuilder.cs

示例12: SetCustomAttribute

		public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
		{
			Universe u = typeBuilder.ModuleBuilder.universe;
			if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute)
			{
				attributes |= EventAttributes.SpecialName;
			}
			else
			{
				if (lazyPseudoToken == 0)
				{
					lazyPseudoToken = typeBuilder.ModuleBuilder.AllocPseudoToken();
				}
				typeBuilder.ModuleBuilder.SetCustomAttribute(lazyPseudoToken, customBuilder);
			}
		}
开发者ID:koush,项目名称:mono,代码行数:16,代码来源:EventBuilder.cs

示例13: Event

        public ApiTypeBuilder Event(string name, Type eventType, EventAttributes attributes = EventAttributes.None, bool @static = false)
        {
            EventBuilder eventBuilder = _typeBuilder.DefineEvent(name, attributes, eventType);

              MethodBuilder addMethodBuilder = _typeBuilder.DefineMethod(string.Format("add_{0}", name),
            @static ? MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Static :
            MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Virtual
            , null, new[] { eventType });
              addMethodBuilder.GetILGenerator().Emit(OpCodes.Ret);

              MethodBuilder removeMethodBuilder = _typeBuilder.DefineMethod(string.Format("remove_{0}", name),
            @static ? MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Static :
            MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig | MethodAttributes.Virtual
            , null, new[] { eventType });
              removeMethodBuilder.GetILGenerator().Emit(OpCodes.Ret);

              eventBuilder.SetAddOnMethod(addMethodBuilder);
              eventBuilder.SetRemoveOnMethod(removeMethodBuilder);
              return this;
        }
开发者ID:gitter-badger,项目名称:ApiCheck,代码行数:20,代码来源:ApiTypeBuilder.cs

示例14: DefineEvent

 [System.Security.SecuritySafeCritical]  // auto-generated
 public EventBuilder DefineEvent(String name, EventAttributes attributes, Type eventtype)
 {
     lock(SyncRoot)
     {
         return DefineEventNoLock(name, attributes, eventtype);
     }
 }
开发者ID:uQr,项目名称:referencesource,代码行数:8,代码来源:typebuilder.cs

示例15: DefineEventNoLock

        [System.Security.SecurityCritical]  // auto-generated
        private EventBuilder DefineEventNoLock(String name, EventAttributes attributes, Type eventtype)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (name.Length == 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
            if (name[0] == '\0')
                throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), "name");
            Contract.EndContractBlock();

            int tkType;
            EventToken      evToken;
            
            CheckContext(eventtype);

            ThrowIfCreated();

            tkType = m_module.GetTypeTokenInternal( eventtype ).Token;

            // Internal helpers to define property records
            evToken = new EventToken(DefineEvent(
                m_module.GetNativeHandle(),
                m_tdType.Token,
                name,
                attributes,
                tkType));

            // create the property builder now.
            return new EventBuilder(
                    m_module,
                    name,
                    attributes,
                    //tkType,
                    this,
                    evToken);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:37,代码来源:typebuilder.cs


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