Пример #1
0
        internal JsonRpcMethod(JsonRpcMethodBuilder methodBuilder, JsonRpcServiceClass clazz)
        {
            Debug.Assert(methodBuilder != null);
            Debug.Assert(clazz != null);
            
            _name = methodBuilder.Name;
            _internalName = Mask.EmptyString(methodBuilder.InternalName, methodBuilder.Name);
            _resultType = methodBuilder.ResultType;
            _description = methodBuilder.Description;
            _dispatcher = methodBuilder.Dispatcher;
            _attributes = DeepCopy(methodBuilder.GetCustomAttributes());
            _class = clazz;
            
            JsonRpcParameterBuilder[] parameterBuilders = methodBuilder.GetParameters();
            _parameters = new JsonRpcParameter[parameterBuilders.Length];
            int paramIndex = 0;

            foreach (JsonRpcParameterBuilder parameterBuilder in parameterBuilders)
                _parameters[paramIndex++] = new JsonRpcParameter(parameterBuilder, this);
        }
Пример #2
0
        internal JsonRpcMethod(Builder methodBuilder, JsonRpcServiceClass clazz)
        {
            Debug.Assert(methodBuilder != null);
            Debug.Assert(clazz != null);
            
            _name = methodBuilder.Name;
            _internalName = Mask.EmptyString(methodBuilder.InternalName, methodBuilder.Name);
            _resultType = methodBuilder.ResultType;
            _isObsolete = methodBuilder.IsObsolete;
            _obsoletionMessage = methodBuilder.IsObsolete ? methodBuilder.ObsoletionMessage : string.Empty;
            _description = methodBuilder.Description;
            _dispatcher = methodBuilder.Dispatcher;
            _class = clazz;
            
            JsonRpcParameter.Builder[] parameterBuilders = methodBuilder.GetParameterBuilders();
            _parameters = new JsonRpcParameter[parameterBuilders.Length];
            int paramIndex = 0;

            foreach (JsonRpcParameter.Builder parameterBuilder in parameterBuilders)
                _parameters[paramIndex++] = new JsonRpcParameter(parameterBuilder, this);
        }
Пример #3
0
        internal JsonRpcMethod(JsonRpcMethodBuilder methodBuilder, JsonRpcServiceClass clazz)
        {
            Debug.Assert(methodBuilder != null);
            Debug.Assert(clazz != null);
            
            _name = methodBuilder.Name;
            _internalName = Mask.EmptyString(methodBuilder.InternalName, methodBuilder.Name);
            _resultType = methodBuilder.ResultType;
            _description = methodBuilder.Description;
            _dispatcher = methodBuilder.Dispatcher;
            _attributes = DeepCopy(methodBuilder.GetCustomAttributes());
            _class = clazz;
            
            //
            // Set up parameters and their names.
            //
            
            ICollection parameterBuilders = methodBuilder.Parameters;
            _parameters = new JsonRpcParameter[parameterBuilders.Count];
            _parameterNames = new string[parameterBuilders.Count];

            foreach (JsonRpcParameterBuilder parameterBuilder in parameterBuilders)
            {
                JsonRpcParameter parameter = new JsonRpcParameter(parameterBuilder, this);
                int position = parameter.Position;
                _parameters[position] = parameter;
                _parameterNames[position] = parameter.Name;
            }
            
            //
            // Keep a sorted list of parameters and their names so we can
            // do fast look ups using binary search.
            //
            
            _sortedParameters = (JsonRpcParameter[]) _parameters.Clone();
            Array.Sort(_parameterNames, _sortedParameters, Comparer.DefaultInvariant);
        }
        private static void BuildParameter(JsonRpcParameter.Builder builder, ParameterInfo parameter)
        {
            Debug.Assert(parameter != null);
            Debug.Assert(builder != null);
            
            builder.Name = parameter.Name;
            builder.ParameterType = parameter.ParameterType;
            builder.Position = parameter.Position;
            builder.IsParamArray = parameter.IsDefined(typeof(ParamArrayAttribute), true);

            //
            // Build via attributes.
            //
            
            object[] attributes = parameter.GetCustomAttributes(typeof(IParameterReflector), true);
            foreach (IParameterReflector reflector in attributes)
                reflector.Build(builder, parameter);
        }