예제 #1
0
        void InitializeDispatchHandlers()
        {
            dispatchHandlers = new Dictionary <string, DispatchCallback>();

            Type taskType                 = typeof(Task);
            Type gatewayType              = typeof(Gateway);
            Type dispatchSynchronousType  = typeof(DispatchSynchronousCallback);
            Type dispatchAsynchronousType = typeof(DispatchAsynchronousCallback);

            foreach (MethodInfo method in gatewayType.GetTypeInfo().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic))
            {
                DispatchEventAttribute attr = method.GetCustomAttribute <DispatchEventAttribute>();
                if (attr != null)
                {
                    DispatchCallback dispatchCallback;
                    if (method.ReturnType == taskType)
                    {
                        Delegate callback = method.CreateDelegate(dispatchAsynchronousType, this);
                        dispatchCallback = new DispatchCallback((DispatchAsynchronousCallback)callback);
                    }
                    else
                    {
                        Delegate callback = method.CreateDelegate(dispatchSynchronousType, this);
                        dispatchCallback = new DispatchCallback((DispatchSynchronousCallback)callback);
                    }

                    dispatchHandlers[attr.EventName] = dispatchCallback;
                }
            }
        }
예제 #2
0
 public DispatchAttribute(DispatchAttribute attrib)
 {
     this.uid             = attrib.uid;
     this.vid             = attrib.vid;
     this.cid             = attrib.cid;
     this.type            = attrib.type;
     this.algorithm       = attrib.algorithm;
     this.data            = attrib.data;
     this.cbCallBack      = attrib.cbCallBack;
     this.cbCacheProcess  = attrib.cbCacheProcess;
     this.reloadDB        = attrib.reloadDB;
     this.discard_if_jam  = attrib.discard_if_jam;
     this.guid            = attrib.guid;
     this.alltype         = attrib.alltype;
     this.attached        = attrib.attached;
     this.operation       = attrib.operation;
     this.owner           = null;
     this._msgHandler     = attrib._msgHandler;
     this.block_no        = 0;
     this.dispatchPointer = -1;
     this.request         = "";
     this.tStart          = (long)Environment.TickCount;
 }
예제 #3
0
 public DispatchAttribute()
 {
     this.uid             = 0;
     this.vid             = 0;
     this.type            = 0;
     this.cid             = 0L;
     this.algorithm       = 1;
     this.data            = null;
     this.cbCallBack      = null;
     this.cbCacheProcess  = null;
     this.owner           = null;
     this.block_no        = 0;
     this.dispatchPointer = -1;
     this.request         = "";
     this.reloadDB        = 1;
     this.discard_if_jam  = 0;
     this.guid            = "";
     this.alltype         = "";
     this.attached        = "";
     this.operation       = "";
     this.tStart          = (long)Environment.TickCount;
     this._msgHandler     = null;
 }