本文整理汇总了C#中System.Delegate类的典型用法代码示例。如果您正苦于以下问题:C# Delegate类的具体用法?C# Delegate怎么用?C# Delegate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Delegate类属于System命名空间,在下文中一共展示了Delegate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Remove
public static Delegate Remove(Delegate source, Delegate value)
{
if (source == null) {
return null;
}
return source.RemoveImpl(value);
}
开发者ID:memsom,项目名称:dotNetAnywhere-wb,代码行数:7,代码来源:Delegate.cs
示例2: AddTaskDelay
private static void AddTaskDelay(Delegate ev, object[] paramArray, int time)
{
System.Threading.Thread.Sleep(time);
bool bFired;
if (ev != null)
{
foreach (Delegate singleCast in ev.GetInvocationList())
{
bFired = false;
try
{
ISynchronizeInvoke syncInvoke = (ISynchronizeInvoke)singleCast.Target;
if (syncInvoke != null && syncInvoke.InvokeRequired)
{
bFired = true;
syncInvoke.BeginInvoke(singleCast, paramArray);
}
else
{
bFired = true;
singleCast.DynamicInvoke(paramArray);
}
}
catch (Exception)
{
if (!bFired)
singleCast.DynamicInvoke(paramArray);
}
}
}
}
开发者ID:Xileck,项目名称:tibiaapi,代码行数:32,代码来源:Scheduler.cs
示例3: BeginInvoke
/// <summary>
/// Forwards the BeginInvoke to the current application's <see cref="Dispatcher"/>.
/// </summary>
/// <param name="method">Method to be invoked.</param>
/// <param name="arg">Arguments to pass to the invoked method.</param>
public void BeginInvoke(Delegate method, object arg)
{
if (Application.Current != null)
{
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, method, arg);
}
}
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:12,代码来源:DefaultDispatcher.cs
示例4: AddDelegate
public void AddDelegate(Type key, Delegate value)
{
if (key == firstKey)
{
throw new ArgumentException("An element with the same key already exists in the dictionary.");
}
if (firstKey == null && bindTo == null) // nothing
{
firstKey = key;
firstValue = value;
}
else if (firstKey != null && bindTo == null) // one key existed
{
bindTo = new Dictionary<Type, Delegate>();
bindTo.Add(firstKey, firstValue);
firstKey = null;
firstValue = null;
bindTo.Add(key, value);
}
else
{
bindTo.Add(key, value);
}
}
开发者ID:yb199478,项目名称:CatLib,代码行数:25,代码来源:DelegateBridge.cs
示例5: EnsureFunctionCode
protected FunctionCode EnsureFunctionCode(Delegate/*!*/ dlg) {
Debug.Assert(dlg != null);
if (_code == null) {
Interlocked.CompareExchange(
ref _code,
new FunctionCode(
(PythonContext)SourceUnit.LanguageContext,
dlg,
null,
"<module>",
"",
ArrayUtils.EmptyStrings,
GetCodeAttributes(),
SourceSpan.None,
SourceUnit.Path,
false,
true,
ArrayUtils.EmptyStrings,
ArrayUtils.EmptyStrings,
ArrayUtils.EmptyStrings,
ArrayUtils.EmptyStrings,
0,
null,
null
),
null
);
}
return _code;
}
开发者ID:techarch,项目名称:ironruby,代码行数:31,代码来源:RunnableScriptCode.cs
示例6: Execute
public void Execute(Delegate method, DispatcherPriority priority)
{
if (application == null)
{
ExecuteDirectlyOrDuringATest(method);
return;
}
var dispatcher = application.Dispatcher;
if ((application != null) && isAsync)
{
dispatcher.BeginInvoke(method);
return;
}
var notRequireUiThread = dispatcher.CheckAccess();
if (notRequireUiThread)
{
ExecuteDirectlyOrDuringATest(method);
return;
}
if (isAsync)
{
dispatcher.BeginInvoke(method, priority);
return;
}
dispatcher.Invoke(method, priority);
}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:32,代码来源:Execution.cs
示例7: MapListener
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
public void MapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
{
if (eventClass == null)
{
eventClass = typeof(Event);
}
List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;
EventMapConfig config;
int i = currentListeners.Count;
while (i-- > 0)
{
config = currentListeners [i];
if (config.Equals (dispatcher, type, listener, eventClass))
return;
}
Delegate callback = eventClass == typeof(Event) ? listener : (Action<IEvent>)delegate(IEvent evt){
RouteEventToListener(evt, listener, eventClass);
};
config = new EventMapConfig (dispatcher, type, listener, eventClass, callback);
currentListeners.Add (config);
if (!_suspended)
{
dispatcher.AddEventListener (type, callback);
}
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:37,代码来源:EventMap.cs
示例8: ConnectListener
public void ConnectListener(EventType eventType, Delegate listener)
{
if (disposed) { return; }
var ex = events[eventType].CheckListener(listener);
if (ex != null)
{
throw ex;
}
if (!ConnectedListeners.ContainsKey(eventType))
{
ConnectedListeners[eventType] = new ConcurrentDictionary<int, Delegate>();
}
else if (ConnectedListeners[eventType].Values.Contains(listener))
{
throw new ArgumentException("'listener' has already been connected to this event type.", "listener");
}
if (ConnectedListeners[eventType].Count == 0)
{
ConnectedListeners[eventType][0] = listener;
}
else
{
var index = ConnectedListeners[eventType].Keys.Max() + 1;
ConnectedListeners[eventType][index] = listener;
}
}
开发者ID:thebecwar,项目名称:ChatExchange.Net,代码行数:28,代码来源:EventManager.cs
示例9: EventOperation
public EventOperation(Delegate assignation)
{
_delegateMethod = assignation.Method;
MethodBody body = _delegateMethod.GetMethodBody();
_stream = new MemoryStream(body.GetILAsByteArray());
_module = _delegateMethod.Module;
}
开发者ID:dgg,项目名称:testing-commons,代码行数:7,代码来源:EventOperation.cs
示例10: Configure
private Ptr<RPC_SERVER_INTERFACE> Configure(RpcHandle handle, Ptr<MIDL_SERVER_INFO> me, Guid iid,
Byte[] formatTypes, Byte[] formatProc, ushort[] formatProcOffsets,
Delegate[] funcs)
{
Ptr<RPC_SERVER_INTERFACE> svrIface = handle.CreatePtr(new RPC_SERVER_INTERFACE(handle, me, iid));
Ptr<MIDL_STUB_DESC> stub = handle.CreatePtr(new MIDL_STUB_DESC(handle, svrIface.Handle, formatTypes, true));
pStubDesc = stub.Handle;
var dispatches = new IntPtr[funcs.Length];
for (var i = 0; i < funcs.Length; ++i)
{
dispatches[i] = handle.PinFunction(funcs[i]);
}
DispatchTable = handle.Pin(dispatches);
ProcString = handle.Pin(formatProc);
FmtStringOffset = handle.Pin(formatProcOffsets.Clone());
ThunkTable = IntPtr.Zero;
pTransferSyntax = IntPtr.Zero;
nCount = IntPtr.Zero;
pSyntaxInfo = IntPtr.Zero;
//Copy us back into the pinned address
Marshal.StructureToPtr(this, me.Handle, false);
return svrIface;
}
开发者ID:terryfan1109,项目名称:win32-test,代码行数:27,代码来源:MIDL_SERVER_INFO.cs
示例11: Call5
public string Call5(Delegate callback)
{
var thisArg = JsValue.Undefined;
var arguments = new JsValue[] { 1, "foo" };
return callback.DynamicInvoke(thisArg, arguments).ToString();
}
开发者ID:Willy-Kimura,项目名称:jint,代码行数:7,代码来源:A.cs
示例12: CreateThunk
public static unsafe IntPtr CreateThunk(Delegate @delegate, IntPtr methodTarget)
{
lock (thunkAllocatorLock)
{
int thunkEntry = thunkNextEntry;
Delegate thunkDelegate;
while ((thunkDelegate = delegates[thunkEntry]) != null)
{
// TODO: Use WeakReference<Delegate> instead, and check if it has been GC
if (++thunkEntry >= ThunkCount)
thunkEntry = 0;
// We looped, which means nothing was found
// TODO: We should give it another try after performing GC
if (thunkEntry == thunkNextEntry)
{
throw new InvalidOperationException("No thunk available");
}
}
// Setup delegate and thunk target
// TODO: We probably want a struct instead of 2 separate arrays
delegates[thunkEntry] = @delegate;
GetThunkTargets()[thunkEntry] = methodTarget;
// Return our thunk redirect function pointer
return GetThunkPointers()[thunkEntry];
}
}
开发者ID:RainsSoft,项目名称:SharpLang,代码行数:29,代码来源:MarshalHelper.cs
示例13: AddHandler
public static void AddHandler(object target, RoutedEvent routedEvent, Delegate handler, bool handledEventsToo) {
if (null == target)
throw new ArgumentNullException("target");
if (null == routedEvent)
throw new ArgumentNullException("routedEvent");
if (null == handler)
throw new ArgumentNullException("handler");
//
RoutedEventKey key = routedEvent.Key;
if (!routedEvents.ContainsKey(key))
throw new ArgumentException("Specified routed event is not registered.", "routedEvent");
RoutedEventInfo routedEventInfo = routedEvents[key];
bool needAddTarget = true;
if (routedEventInfo.targetsList != null) {
RoutedEventTargetInfo targetInfo = routedEventInfo.targetsList.FirstOrDefault(info => info.target == target);
if (null != targetInfo) {
if (targetInfo.handlersList == null)
targetInfo.handlersList = new List<DelegateInfo>();
targetInfo.handlersList.Add(new DelegateInfo(handler, handledEventsToo));
needAddTarget = false;
}
}
if (needAddTarget) {
RoutedEventTargetInfo targetInfo = new RoutedEventTargetInfo(target);
targetInfo.handlersList = new List<DelegateInfo>();
targetInfo.handlersList.Add(new DelegateInfo(handler, handledEventsToo));
if (routedEventInfo.targetsList == null)
routedEventInfo.targetsList = new List<RoutedEventTargetInfo>();
routedEventInfo.targetsList.Add(targetInfo);
}
}
开发者ID:CxSoftware,项目名称:consoleframework,代码行数:31,代码来源:EventManager.cs
示例14: InterestCalculatorClass
public InterestCalculatorClass(decimal money, float interest, int years, Delegate del)
{
this.Money = money;
this.Interest = interest;
this.Years = years;
this.dele = del;
}
开发者ID:mgulubov,项目名称:SoftUniCourse-OOP,代码行数:7,代码来源:InterestCalculatorClass.cs
示例15: DelegateTestCase
public DelegateTestCase(string fixtureName, Delegate testDelegate, params object[] args)
: base(fixtureName)
{
this.testDelegate = testDelegate;
foreach (Object arg in args)
this.Parameters.Add(new TestCaseParameter(arg));
}
开发者ID:buptkang,项目名称:QuickGraph,代码行数:7,代码来源:DelegateTestCase.cs
示例16: GetCreateItemHelper
static Delegate GetCreateItemHelper()
{
if (cb_CreateItem == null)
cb_CreateItem = JNINativeWrapper.CreateDelegate((Func<IntPtr, IntPtr, int, IntPtr>)_CreateItem);
return cb_CreateItem;
}
开发者ID:Cheesebaron,项目名称:MonoDroid.GoogleMapsDemo,代码行数:7,代码来源:MyItemizedOverlay.cs
示例17: SetJob
public void SetJob(Delegate function,
object functionParameter,
Delegate assignResult = null,
JobPriority priority = JobPriority.High)
{
this.SetJob(new Job(function, new []{functionParameter}, assignResult), priority);
}
开发者ID:CApplications,项目名称:MangaViewer,代码行数:7,代码来源:BaseJobExecuter.cs
示例18: IsLegalHandler
// Check to see if the given delegate is a legal handler for this type.
// It either needs to be a type that the registering class knows how to
// handle, or a RoutedEventHandler which we can handle without the help
// of the registering class.
internal bool IsLegalHandler(Delegate handler)
{
Type handlerType = handler.GetType();
return ((handlerType == HandlerType) ||
(handlerType == typeof(RoutedEventHandler)));
}
开发者ID:prabby,项目名称:miniclr,代码行数:11,代码来源:RoutedEvent.cs
示例19: ConnectDynamicSlot
public unsafe bool ConnectDynamicSlot(QObject sender, string signal, Delegate slot)
{
this.slots.Add(slot);
int signalId = sender.MetaObject.IndexOfSignal(QMetaObject.NormalizedSignature(signal));
void* connection = QMetaObject.Connect(sender, signalId, this, this.slots.Count - 1 + MetaObject.MethodCount, 0, null);
return connection != null;
}
开发者ID:RodolpheFouquet,项目名称:QtSharp,代码行数:7,代码来源:DynamicQObject.cs
示例20: UnmapListener
public void UnmapListener(IEventDispatcher dispatcher, Enum type, Delegate listener, Type eventClass = null)
{
if (eventClass == null)
{
eventClass = typeof(Event);
}
List<EventMapConfig> currentListeners = _suspended ? _suspendedListeners : _listeners;
EventMapConfig config;
int i = currentListeners.Count;
while (i-- > 0)
{
config = currentListeners [i];
if (config.Equals (dispatcher, type, listener, eventClass))
{
if (!_suspended)
{
dispatcher.RemoveEventListener (type, config.callback);
}
currentListeners.RemoveAt (i);
return;
}
}
}
开发者ID:mikecann,项目名称:robotlegs-sharp-framework,代码行数:27,代码来源:EventMap.cs
注:本文中的System.Delegate类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论