当前位置: 首页>>代码示例>>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;未经允许,请勿转载。