Esempio n. 1
0
        /// <summary>
        /// Identifies all RPC methods and adds to the methodDict.
        /// </summary>
        private void IdentifyRpcMethods(RpcDispatchInfo rpcDispatchInfo)
        {
            log.Debug("Begin Identify Rpc Methods");
            Type t = rpcDispatchInfo.RpcDispatchedObject.GetType();
            foreach(MethodInfo m in t.GetMethodsWithAttribute<RpcAttribute>())
            {
                RpcAttribute[] attrs = m.GetCustomAttributes<RpcAttribute>();

                Preconditions.IsTrue(1==attrs.Length,
                                     string.Format("Only expecting one RpcAttribute. Bad Method: {0}",m.ToString()));

                RpcAttribute rpc = attrs[0];
                RpcInfo rpcInfo = new RpcInfo(rpc.Id, rpc.ChunkSize, rpc.IsBroadcast, m);
                log.Debug(rpcInfo);
                rpcDispatchInfo.Add(rpcInfo);
            }

            log.Debug("End Identify Rpc Methods");
        }
Esempio n. 2
0
        /// <summary>
        ///  Test for presence of RpcDispatched attribute. 
        ///  If not present return else add to cache.
        /// </summary>
        private void Parse(object obj)
        {
            Type t = obj.GetType();
            RpcDispatchedAttribute[] attrs = t.GetCustomAttributes<RpcDispatchedAttribute>();
            if(0==attrs.Length) { return; }

            Preconditions.IsTrue(1==attrs.Length,"Only expecting 1 RpcDispatchedAttribute");
            RpcDispatchedAttribute rpcd = attrs[0];
            Preconditions.IsFalse(rpcDict.ContainsKey(rpcd.Id),
                                 string.Format("Already have an RpcDispatchedAttribute instance with id {0}.",rpcd.Id));

            RpcDispatchInfo rpcInfo = new RpcDispatchInfo(rpcd.Id, obj);
            IdentifyRpcMethods(rpcInfo);
            log.Debug("Before add to rpcDict");
            log.Debug(rpcInfo);
            rpcDict.Add(rpcd.Id, rpcInfo);
            log.Debug("Return from parse method.");
        }
Esempio n. 3
0
 internal void Add(string key, RpcDispatchInfo v)
 {
     ids.Add(key);
     rpcs.Add(v);
 }