示例#1
0
 internal PluginMethod(string name, Type discovery, ServerPlugin plugin, ResultConverter result, System.Reflection.MethodInfo method, DataExtractor[] extractors, Description description) : base(discovery, name, description == null ? "" : description.value())
 {
     this._plugin     = plugin;
     this._result     = result;
     this._method     = method;
     this._extractors = extractors;
 }
示例#2
0
        public override PluginPoint CreateFrom(ServerPlugin plugin, System.Reflection.MethodInfo method, Type discovery)
        {
            ResultConverter result = ResultConverter.Get(method.GenericReturnType);

            Type[]          types           = method.GenericParameterTypes;
            Annotation[][]  annotations     = method.ParameterAnnotations;
            SourceExtractor sourceExtractor = null;

            DataExtractor[] extractors = new DataExtractor[types.Length];
            for (int i = 0; i < types.Length; i++)
            {
                Description description = null;
                Parameter   param       = null;
                Source      source      = null;
                foreach (Annotation annotation in annotations[i])
                {
                    if (annotation is Description)
                    {
                        description = ( Description )annotation;
                    }
                    else if (annotation is Parameter)
                    {
                        param = ( Parameter )annotation;
                    }
                    else if (annotation is Source)
                    {
                        source = ( Source )annotation;
                    }
                }
                if (param != null && source != null)
                {
                    throw new System.InvalidOperationException(string.Format("Method parameter {0:D} of {1} cannot be retrieved as both Parameter and Source", Convert.ToInt32(i), method));
                }
                else if (source != null)
                {
                    if (types[i] != discovery)
                    {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                        throw new System.InvalidOperationException("Source parameter type (" + types[i] + ") must equal the discovery type (" + discovery.FullName + ").");
                    }
                    if (sourceExtractor != null)
                    {
                        throw new System.InvalidOperationException("Server Extension methods may have at most one Source parameter.");
                    }
                    extractors[i] = sourceExtractor = new SourceExtractor(source, description);
                }
                else if (param != null)
                {
                    extractors[i] = ParameterExtractor(types[i], param, description);
                }
                else
                {
                    throw new System.InvalidOperationException("Parameters of Server Extension methods must be annotated as either Source or Parameter.");
                }
            }
            return(new PluginMethod(NameOf(method), discovery, plugin, result, method, extractors, method.getAnnotation(typeof(Description))));
        }
示例#3
0
 internal ListResult(ResultConverter itemConverter)
 {
     this.ItemConverter = itemConverter;
 }