本文整理汇总了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;
}
示例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.");
}
}
}
}
示例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;
}
示例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);
}
示例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 ();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
示例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");
}
示例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;
}
示例15: getEvent
internal static EventInfo getEvent(Type type, string name)
{
return type.GetEvent(name, BindingFlags.Public | BindingFlags.Instance);
}