當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。