當前位置: 首頁>>代碼示例>>C#>>正文


C# Type.GetEvent方法代碼示例

本文整理匯總了C#中System.Type.GetEvent方法的典型用法代碼示例。如果您正苦於以下問題:C# Type.GetEvent方法的具體用法?C# Type.GetEvent怎麽用?C# Type.GetEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Type的用法示例。


在下文中一共展示了Type.GetEvent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProcessEventParameters

        private static bool ProcessEventParameters(WorkflowParameterBindingCollection parameters, IMethodMessage message, Type interfaceType, string operation)
        {
            bool isKnownSignature = false;
            if (parameters == null)
                return isKnownSignature;

            EventInfo eventInfo = interfaceType.GetEvent(operation);
            MethodInfo methodInfo = eventInfo.EventHandlerType.GetMethod("Invoke");
            int index = 0;

            foreach (ParameterInfo formalParameter in methodInfo.GetParameters())
            {
                if ((typeof(ExternalDataEventArgs).IsAssignableFrom(formalParameter.ParameterType)))
                {
                    if (index == 1)
                        isKnownSignature = true;
                }

                if (parameters.Contains(formalParameter.Name))
                {
                    WorkflowParameterBinding binding = parameters[formalParameter.Name];
                    binding.Value = message.Args[index];
                }
                index++;
            }
            return isKnownSignature;
        }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:27,代碼來源:InboundActivityHelper.cs

示例2: SetMemberValue

 private static void SetMemberValue(object control, Type type, string member, object value)
 {
     PropertyInfo propertyInfo = type.GetProperty(member);
     if (propertyInfo != null)
     {
         SetPropertyValue(control, value, propertyInfo);
     }
     else
     {
         EventInfo eventInfo = type.GetEvent(member);
         if (eventInfo != null)
         {
             switch (eventInfo.EventHandlerType.FullName)
             {
                 case "System.EventHandler":
                     eventInfo.AddEventHandler(control, new EventHandler((sender, e) =>
                                                                         {
                                                                             (value as LuaFunc).Invoke(new LuaValue[] { new LuaUserdata(sender), new LuaUserdata(e) });
                                                                         }));
                     break;
                 case "System.Windows.Forms.TreeViewEventHandler":
                     eventInfo.AddEventHandler(control, new TreeViewEventHandler((sender, e) =>
                                                                                 {
                                                                                     (value as LuaFunc).Invoke(new LuaValue[] { new LuaUserdata(sender), new LuaUserdata(e) });
                                                                                 }));
                     break;
                 default:
                     throw new NotImplementedException(eventInfo.EventHandlerType.FullName + " type not implemented.");
             }
         }
     }
 }
開發者ID:chenzuo,項目名稱:SharpLua,代碼行數:32,代碼來源:ObjectToLua.cs

示例3: GetEventInfo

 private static EventInfo GetEventInfo(Type type, string name)
 {
     if ((s_cbmTdpBridge != null) && IsFrameworkType(type))
     {
         Type typeToUseForCBMBridge = GetTypeToUseForCBMBridge(type);
         if (s_cbmTdpBridge.HasEvent(typeToUseForCBMBridge, name))
         {
             return type.GetEvent(name);
         }
         return null;
     }
     if (GetReflectionType(type).GetEvent(name) != null)
     {
         return type.GetEvent(name);
     }
     return null;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:17,代碼來源:TargetFrameworkUtil.cs

示例4: Get

            public object Get(string name, object instance, Type type, params object[] arguments)
            {
                var ei = type.GetEvent(name, PropertyFilter);
                if (ei == null) return NoResult;
                return !CanBind(ei) ? NoResult : ei;

                //Type eventHelper = typeof(EventHelper<>);
                //Type actualHelper = eventHelper.MakeGenericType(ei.EventHandlerType);
            }
開發者ID:DenisVuyka,項目名稱:SSharp,代碼行數:9,代碼來源:ObjectBinding.Infrastructure.cs

示例5: ReflectionEventDescriptor

		public ReflectionEventDescriptor (Type componentType, EventDescriptor oldEventDescriptor, Attribute[] attrs) : base (oldEventDescriptor, attrs)
		{
			_componentType = componentType;
			_eventType = oldEventDescriptor.EventType;

			EventInfo event_info = componentType.GetEvent (oldEventDescriptor.Name);
			add_method = event_info.GetAddMethod ();
			remove_method = event_info.GetRemoveMethod ();
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:9,代碼來源:ReflectionEventDescriptor.cs

示例6: Get

            public object Get(string name, object instance, Type type, params object[] arguments)
            {
                EventInfo ei = type.GetEvent(name);
                if (ei == null) return NoResult;
                if (!CanBind(ei)) return NoResult;

                //Type eventHelper = typeof(EventHelper<>);
                //Type actualHelper = eventHelper.MakeGenericType(ei.EventHandlerType);
                return ei;
            }
開發者ID:kayateia,項目名稱:scriptdotnet,代碼行數:10,代碼來源:ObjectBinderHelpers.cs

示例7: GetEventInfo

        internal static EventInfo GetEventInfo(Type type, string eventName,
            DynamicFunction f, string scriptVirtualPath) {

            EventInfo eventInfo = type.GetEvent(eventName);

            // If it doesn't match an event name, just ignore it
            if (eventInfo == null)
                return null;

            return eventInfo;
        }
開發者ID:nieve,項目名稱:ironruby,代碼行數:11,代碼來源:EventHookupHelper.cs

示例8: FindEvent

		public static EventInfo FindEvent(Type instanceType, String eventName)
		{
			EventInfo info;

			do
			{
				info = instanceType.GetEvent(eventName, NuGenBinding.Instance);
				instanceType = instanceType.BaseType;
			} while (info == null && instanceType != _objectType);

			return info;
		}
開發者ID:xuchuansheng,項目名稱:GenXSource,代碼行數:12,代碼來源:MemberFinder.cs

示例9: Set

            public object Set(string name, object instance, Type type, object value, params object[] arguments)
            {
                EventInfo ei = type.GetEvent(name);
                if (ei == null) return NoResult;
                if (!CanBind(ei)) return NoResult;

                if (!(value is RemoveDelegate))
                  EventHelper.AssignEvent(ei, instance, (IInvokable)value);
                else
                  EventHelper.RemoveEvent(ei, instance, (IInvokable)value);

                return value;
            }
開發者ID:kayateia,項目名稱:scriptdotnet,代碼行數:13,代碼來源:ObjectBinderHelpers.cs

示例10: TeamFoundationHostWrapper

        public TeamFoundationHostWrapper(ITeamFoundationContextManager teamFoundationHostObject)
        {
            _teamFoundationHostObject = teamFoundationHostObject;
            _teamFoundationHostObject.ContextChanged += delegate(object sender, ContextChangedEventArgs args)
                {
                    if (ContextChanged != null)
                        ContextChanged(sender, args);
                };

            _teamFoundationHostObject.ContextChanging += delegate(object sender, ContextChangingEventArgs args)
                {
                    if (ContextChanging != null)
                        ContextChanging(sender, args);
                };

            _teamFoundationHostObjectType = _teamFoundationHostObject.GetType();
            _commandHandlerField = new Lazy<FieldInfo>(() => _teamFoundationHostObjectType.GetField("m_commandHandler", BindingFlags.NonPublic | BindingFlags.Instance));
            _promptForServerAndProjectsMethod = new Lazy<MethodInfo>(() => _teamFoundationHostObjectType.GetMethod("PromptForServerAndProjects", BindingFlags.Public | BindingFlags.Instance));

            var connectingEventInfo = _teamFoundationHostObjectType.GetEvent("Connecting", BindingFlags.Public | BindingFlags.Instance);
            var connectingEventHandlerConstructor = connectingEventInfo.EventHandlerType.GetConstructor(new[] { typeof(object), typeof(IntPtr) });
            var connectingEventHandler = (Delegate)connectingEventHandlerConstructor.Invoke(new object[]
                {
                    this, typeof (TeamFoundationHostWrapper).GetMethod("TeamFoundationHostConnecting", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle.GetFunctionPointer()
                });

            connectingEventInfo.AddEventHandler(_teamFoundationHostObject, connectingEventHandler);

            var connectionCompletedEventInfo = _teamFoundationHostObjectType.GetEvent("ConnectionCompleted", BindingFlags.Public | BindingFlags.Instance);
            var connectionCompletedEventHandlerConstructor = connectionCompletedEventInfo.EventHandlerType.GetConstructor(new[] { typeof(object), typeof(IntPtr) });
            var connectionCompletedEventHandler = (Delegate)connectionCompletedEventHandlerConstructor.Invoke(new object[]
                {
                    this, typeof (TeamFoundationHostWrapper).GetMethod("TeamFoundationHostConnectionCompleted", BindingFlags.NonPublic | BindingFlags.Instance).MethodHandle.GetFunctionPointer()
                });

            connectionCompletedEventInfo.AddEventHandler(_teamFoundationHostObject, connectionCompletedEventHandler);
        }
開發者ID:StanleyGoldman,項目名稱:TeamPilgrim,代碼行數:37,代碼來源:TeamFoundationHostWrapper.cs

示例11: WireToDefaultEvent

        private static void WireToDefaultEvent(Parameter parameter, Type type, DependencyObject source, PropertyInfo property)
        {
            var defaults = IoC.Get<IConventionManager>()
                .GetElementConvention(type);

            if (defaults == null)
                throw new CaliburnException(
                    "Insuficient information provided for wiring action parameters.  Please set interaction defaults for " + type.FullName
                    );

            var eventInfo = type.GetEvent(defaults.EventName);

            if (property == null)
                parameter.Wire(source, eventInfo, () => defaults.GetValue(source));
            else parameter.Wire(source, eventInfo, () => property.GetValue(source, null));
        }
開發者ID:ssethi,項目名稱:TestFrameworks,代碼行數:16,代碼來源:MessagingExtensions.cs

示例12: FindEvent

		static EventInfo FindEvent (Type wrapperType, Type objectType, string name)
		{
			EventInfo info;

			if (wrapperType != null) {
				info = wrapperType.GetEvent (name, flags);
				if (info != null)
					return info;
			}

			info = objectType.GetEvent (name, flags);
			if (info != null)
				return info;

			throw new ArgumentException ("Invalid event name " + objectType.Name + "." + name);
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:16,代碼來源:TypedSignalDescriptor.cs

示例13: ReflectionHelper

        public ReflectionHelper(Type workItemTestType)
        {
            enqueueWorkItemMethod = workItemTestType.GetMethod("EnqueueWorkItem");

            unitTestHarnessProperty = workItemTestType.GetProperty("UnitTestHarness");

            var unitTestHarnessType = unitTestHarnessProperty.PropertyType;

            dispatcherStackProperty = unitTestHarnessType.GetProperty("DispatcherStack");

            var dispatcherStackType = dispatcherStackProperty.PropertyType;

            pushWorkItemMethod = dispatcherStackType.GetMethod("Push");
            popWorkItemMethod = dispatcherStackType.GetMethod("Pop");

            compositeWorkItemType = pushWorkItemMethod.GetParameters()[0].ParameterType;
            compositeWorkItemExceptionEvent = compositeWorkItemType.GetEvent("UnhandledException");
        }
開發者ID:kenlefeb,項目名稱:SpecFlow,代碼行數:18,代碼來源:ReflectionHelper.cs

示例14: ProcessEventParameters

 private static bool ProcessEventParameters(WorkflowParameterBindingCollection parameters, IMethodMessage message, Type interfaceType, string operation)
 {
     bool flag = false;
     if (parameters != null)
     {
         MethodInfo method = interfaceType.GetEvent(operation).EventHandlerType.GetMethod("Invoke");
         int index = 0;
         foreach (ParameterInfo info3 in method.GetParameters())
         {
             if (typeof(ExternalDataEventArgs).IsAssignableFrom(info3.ParameterType) && (index == 1))
             {
                 flag = true;
             }
             if (parameters.Contains(info3.Name))
             {
                 WorkflowParameterBinding binding = parameters[info3.Name];
                 binding.Value = message.Args[index];
             }
             index++;
         }
     }
     return flag;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:23,代碼來源:InboundActivityHelper.cs

示例15: getEvent

 internal static EventInfo getEvent(Type type, string name)
 {
     return type.GetEvent(name, BindingFlags.Public | BindingFlags.Instance);
 }
開發者ID:Kerbas-ad-astra,項目名稱:ToadicusTools,代碼行數:4,代碼來源:ToolbarWrapper.cs


注:本文中的System.Type.GetEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。