コード例 #1
0
ファイル: MethodRunnable.cs プロジェクト: nhinze/rhodes
        public IMethodHodler convert(rho.protocol.client.IClientMethod serverData)
        {
            if (serverData == null)
            {
                return(null);
            }

            Type       type   = typeof(RunnableClass);
            MethodInfo method = type.GetMethod(serverData.Name);

            if (method == null)
            {
                return(null);
            }

            ParameterInfo[] methodTypesinfo = method.GetParameters();

            Type[] typeList = getTypesInNamespace(Assembly.GetExecutingAssembly(), nsNameForFactory);

            foreach (Type currType in typeList)
            {
                IMethodHodler holder      = (IMethodHodler)Activator.CreateInstance(currType);
                Type[]        holderTypes = holder.ParamsTypes;

                if (holderTypes.Length != methodTypesinfo.Length)
                {
                    continue;
                }

                bool isAllEqual = true;
                for (int i = 0; i < holderTypes.Length; ++i)
                {
                    string methodParamType = methodTypesinfo[i].ParameterType.AssemblyQualifiedName;
                    string holderParamType = holderTypes[i].AssemblyQualifiedName;

                    if (!methodParamType.Equals(holderParamType))
                    {
                        isAllEqual = false;
                    }
                }

                if (!isAllEqual)
                {
                    continue;
                }

                return(fillHolderFromClient(serverData, (IMethodHodlerFill)holder));
            }

            return(null);
        }
コード例 #2
0
ファイル: MethodRunnable.cs プロジェクト: nhinze/rhodes
 private IMethodHodler fillHolderFromClient(rho.protocol.client.IClientMethod clientMethod, IMethodHodlerFill holder)
 {
     holder.fill(clientMethod.Params);
     holder.Name = clientMethod.Name;
     return(holder);
 }