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


C# Cecil.EventDefinition类代码示例

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


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

示例1: AnalyzedEventOverridesTreeNode

		public AnalyzedEventOverridesTreeNode(EventDefinition analyzedEvent)
		{
			if (analyzedEvent == null)
				throw new ArgumentNullException("analyzedEvent");

			this.analyzedEvent = analyzedEvent;
		}
开发者ID:FaceHunter,项目名称:ILSpy,代码行数:7,代码来源:AnalyzedEventOverridesTreeNode.cs

示例2: CheckSupport

    private void CheckSupport(EventDefinition eventInfo, MethodAttributes methodAttributes)
    {
      EventAttributes eventAttributes = eventInfo.Attributes;

      string warningTemplate = "Event '" + name + "' has unsupported attribute: '{0}'.";

      // in order to reduce output we warn only about important attributes which are not currently
      // supported:

      // EventDefinition properties

      // EventAttributes
      //if ((eventAttributes & EventAttributes.RTSpecialName) != 0) { Logger.Warning(warningTemplate, "RTSpecialName"); }
      //if ((eventAttributes & EventAttributes.SpecialName) != 0) { Logger.Warning(warningTemplate, "SpecialName"); }

      // MethodAttributes
      //if ((methodAttributes & MethodAttributes.CheckAccessOnOverride) != 0) { Logger.Warning(warningTemplate, "CheckAccessOnOverride"); }
      //if ((methodAttributes & MethodAttributes.FamANDAssem) != 0) { Logger.Warning(warningTemplate, "FamANDAssem"); }
      // TODO: support this: if ((methodAttributes & MethodAttributes.HasSecurity) != 0) { Logger.Warning(warningTemplate, "HasSecurity"); }
      //if ((methodAttributes & MethodAttributes.HideBySig) != 0) { Logger.Warning(warningTemplate, "HideBySig"); }
      //if ((methodAttributes & MethodAttributes.NewSlot) != 0) { Logger.Warning(warningTemplate, "NewSlot"); }
      // TODO: support this: if ((methodAttributes & MethodAttributes.PinvokeImpl) != 0) { Logger.Warning(warningTemplate, "PinvokeImpl"); }
      //if ((methodAttributes & MethodAttributes.PrivateScope) != 0) { Logger.Warning(warningTemplate, "PrivateScope"); }
      // TODO: support this: if ((methodAttributes & MethodAttributes.RequireSecObject) != 0) { Logger.Warning(warningTemplate, "RequiresSecObject"); }
      //if ((methodAttributes & MethodAttributes.ReuseSlot) != 0) { Logger.Warning(warningTemplate, "ReuseSlot"); }
      //if ((methodAttributes & MethodAttributes.RTSpecialName) != 0) { Logger.Warning(warningTemplate, "RTSpecialName"); }
      //if ((methodAttributes & MethodAttributes.SpecialName) != 0) { Logger.Warning(warningTemplate, "SpecialName"); }
      // TODO: support this: if ((methodAttributes & MethodAttributes.UnmanagedExport) != 0) { Logger.Warning(warningTemplate, "UnmanagedExport"); }
    }
开发者ID:PrintFleet,项目名称:ImmDoc.NET,代码行数:29,代码来源:MyEventInfo.cs

示例3: ProcessEvent

        public void ProcessEvent(EventDefinition eventt)
        {
            _logger.LogDebug("Beginning processing event " + eventt.Name);

            FieldReference eventDelegate = eventt.GetEventDelegate();

            if (eventDelegate != null)
            {
                if (eventDelegate.FieldType.IsValidEventDelegate())
                {
                    WeakEventWeaver weakEventWeaver = new WeakEventWeaver(eventDelegate, _moduleImporter);
                    ProcessAddMethod(eventt.AddMethod, weakEventWeaver);
                    ProcessRemoveMethod(eventt.RemoveMethod, weakEventWeaver);
                }
                else
                {
                    _logger.LogInfo("Skipping event " + eventt + ", incompatible event delegate type");
                }
            }
            else
            {
                _logger.LogInfo("Skipping event " + eventt + ", could not determine the event delegate field");
            }

            _logger.LogDebug("Finished processing event " + eventt.Name);
        }
开发者ID:adbancroft,项目名称:WeakEvents.Fody,代码行数:26,代码来源:EventWeaver.cs

示例4: EventKey

		public EventKey (TypeKey typeKey, string type, string name, EventDefinition eventDefinition)
		{
			this.typeKey = typeKey;
			this.type = type;
			this.name = name;
			this.eventDefinition = eventDefinition;
		}
开发者ID:alexzhaosheng,项目名称:obfuscar,代码行数:7,代码来源:EventKey.cs

示例5: CreateSourceEventMethodFor

        private static MethodDefinition CreateSourceEventMethodFor(EventDefinition eventDefinition)
        {
            var eventField = eventDefinition.DeclaringType.Fields.Single(x => x.FullName == eventDefinition.FullName);
            var domainEventType = ((GenericInstanceType) eventField.FieldType).GenericArguments[0];
            var invokeMethod = eventField.FieldType.Resolve().Methods.Single(x => x.Name == "Invoke").MakeGenericMethod(domainEventType);
            var eventDelegate = eventDefinition.DeclaringType.Module.ImportReference(invokeMethod);

            var noReturnValue = eventDefinition.DeclaringType.Module.TypeSystem.Void;
            var eventSourcingMethod = new MethodDefinition("<Ichnaea>SourceEvent", SourceEventMethodAttributes, noReturnValue);
            eventSourcingMethod.Parameters.Add(new ParameterDefinition("domainEvent", ParameterAttributes.None, domainEventType));
            eventSourcingMethod.Body.Variables.Add(new VariableDefinition("eventSource", eventField.FieldType));
            eventSourcingMethod.Body.MaxStackSize = 3;
            eventSourcingMethod.Body.InitLocals = true;

            var il = eventSourcingMethod.Body.GetILProcessor();
            il.Emit(OpCodes.Ldarg_0);
            il.Emit(OpCodes.Ldfld, eventField);
            il.Emit(OpCodes.Stloc_0);
            il.Emit(OpCodes.Ldloc_0);

            var nullCheckPlaceholder = il.Create(OpCodes.Nop);
            il.Append(nullCheckPlaceholder);
            il.Emit(OpCodes.Ret);

            var startOfCallSequence = il.Create(OpCodes.Ldloc_0);
            il.Append(startOfCallSequence);
            il.Replace(nullCheckPlaceholder, il.Create(OpCodes.Brtrue_S, startOfCallSequence));

            il.Emit(OpCodes.Ldarg_0);
            il.Emit(OpCodes.Ldarg_1);
            il.Emit(OpCodes.Callvirt, eventDelegate);
            il.Emit(OpCodes.Ret);

            return eventSourcingMethod;
        }
开发者ID:pete-restall,项目名称:Ichnaea,代码行数:35,代码来源:EventSourcingMethod.cs

示例6: GetEventArgsTypeForEvent

        private static string GetEventArgsTypeForEvent(EventDefinition ei)
        {
            // Find the EventArgs type parameter of the event via digging around via reflection
            var type = ei.EventType.Resolve();
            var invoke = type.Methods.First(x => x.Name == "Invoke");
            if (invoke.Parameters.Count < 2) return null;

            var param = invoke.Parameters[1];
            var ret = RenameBogusWinRTTypes(param.ParameterType.FullName);

            var generic = ei.EventType as GenericInstanceType;
            if (generic != null)
            {
                foreach (
                    var kvp in
                        type.GenericParameters.Zip(generic.GenericArguments, (name, actual) => new {name, actual}))
                {
                    var realType = GetRealTypeName(kvp.actual);

                    ret = ret.Replace(kvp.name.FullName, realType);
                }
            }

            // NB: Inner types in Mono.Cecil get reported as 'Foo/Bar'
            return ret.Replace('/', '.');
        }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:26,代码来源:EventTemplateInformation.cs

示例7: Write

        protected override void Write(EventDefinition @event)
        {
            WriteEventDeclaration(@event);

            int startIndex = formatter.CurrentPosition;

            WriteStartBlock();

            WriteAttributes(@event.CustomAttributes);

            WriteNestedMethod(".addon", @event.AddMethod);

            WriteLine();

            WriteNestedMethod(".removeon", @event.RemoveMethod);

            WriteNestedMethod(".fire", @event.InvokeMethod);

            foreach (var method in @event.OtherMethods)
            {
                WriteNestedMethod(".other", method);
            }
            WriteEndBlock();

            this.currentWritingInfo.MemberDefinitionToFoldingPositionMap[@event] = new OffsetSpan(startIndex, formatter.CurrentPosition - 1);
        }
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:26,代码来源:IntermediateLanguageWriter.cs

示例8: UnattachedEvent

		public void UnattachedEvent ()
		{
			var int32 = typeof (int).ToDefinition ();
			var evt = new EventDefinition ("Event", EventAttributes.None, int32);

			Assert.AreEqual (null, evt.AddMethod);
		}
开发者ID:hhariri,项目名称:cecil,代码行数:7,代码来源:EventTests.cs

示例9: Add

        public void Add(EventDefinition value)
        {
            if (!Contains (value))
                Attach (value);

            List.Add (value);
        }
开发者ID:KenMacD,项目名称:deconfuser,代码行数:7,代码来源:EventDefinitionCollection.cs

示例10: ProcessEvent

		public override void ProcessEvent (EventDefinition @event)
		{
			foreach (var attribute in GetPreserveAttributes (@event)) {
				MarkMethod (@event.AddMethod, attribute);
				MarkMethod (@event.InvokeMethod, attribute);
				MarkMethod (@event.RemoveMethod, attribute);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:ApplyPreserveAttributeBase.cs

示例11: AnalyzedEventTreeNode

		public AnalyzedEventTreeNode(EventDefinition analyzedEvent, string prefix = "")
		{
			if (analyzedEvent == null)
				throw new ArgumentNullException("analyzedEvent");
			this.analyzedEvent = analyzedEvent;
			this.prefix = prefix;
			this.LazyLoading = true;
		}
开发者ID:rmattuschka,项目名称:ILSpy,代码行数:8,代码来源:AnalyzedEventTreeNode.cs

示例12: CopyEvent

 /// <summary>
 /// Creates an event like the specified event, but doesn't add it anywhere.
 /// </summary>
 /// <param name="yourEvent"></param>
 /// <param name="newName"></param>
 /// <returns></returns>
 private EventDefinition CopyEvent(EventDefinition yourEvent, string newName)
 {
     var targetEventType = FixTypeReference(yourEvent.EventType);
     var targetEvent = new EventDefinition(newName,
         yourEvent.Attributes,
         targetEventType);
     return targetEvent;
 }
开发者ID:GregRos,项目名称:Patchwork,代码行数:14,代码来源:CreateNew.cs

示例13: AnalyzedInterfaceEventImplementedByTreeNode

		public AnalyzedInterfaceEventImplementedByTreeNode(EventDefinition analyzedEvent)
		{
			if (analyzedEvent == null)
				throw new ArgumentNullException("analyzedEvent");

			this.analyzedEvent = analyzedEvent;
			this.analyzedMethod = this.analyzedEvent.AddMethod ?? this.analyzedEvent.RemoveMethod;
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:8,代码来源:AnalyzedInterfaceEventImplementedByTreeNode.cs

示例14: GetIcon

		public static ImageSource GetIcon(EventDefinition eventDef)
		{
			MethodDefinition accessor = eventDef.AddMethod ?? eventDef.RemoveMethod;
			if (accessor != null)
				return Images.GetIcon(MemberIcon.Event, GetOverlayIcon(eventDef.AddMethod.Attributes), eventDef.AddMethod.IsStatic);
			else
				return Images.GetIcon(MemberIcon.Event, AccessOverlayIcon.Public, false);
		}
开发者ID:x-strong,项目名称:ILSpy,代码行数:8,代码来源:EventTreeNode.cs

示例15: Create

 public static string Create(EventDefinition evt)
 {
     var method = evt.InvokeMethod ?? evt.AddMethod ?? evt.RemoveMethod;
     if (method.IsPublic) return "event";
     if (method.IsAssembly) return "event internal";
     if (method.IsFamily) return "event protected";
     if (method.IsFamilyOrAssembly) return "event protected_internal";
     return "event private";
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:9,代码来源:Icon.cs


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