예제 #1
0
        GetVersionatedMethods(PluginVersioning.memberType memberType)
        {
            var result = new List <Tuple <MethodInfo, ParameterInfo[]> >();

            //get the methods list of the plugin
            MethodInfo[] meth = _pluginType.GetMethods(BindingFlags.Instance | BindingFlags.Public);
            //browse the method list
            foreach (MethodInfo mInfo in meth)
            {
                //get the custom attributes for the method
                Object[] attr = mInfo.GetCustomAttributes(typeof(VersionAttribute), true);
                //if there are custom attributes for it
                if (attr.Length > 0)
                {   //browse the attribute
                    foreach (Object obj in attr)
                    {
                        VersionAttribute vers = obj as VersionAttribute;    //cast as VersionAttribute
                        //if it is a VersionAttribute type
                        if (vers != null)
                        {
                            if (vers.MemberType == memberType)  //if type is the same of given parameter
                            {
                                result.Add(
                                    new Tuple <MethodInfo, ParameterInfo[]>(mInfo, mInfo.GetParameters())
                                    );
                            }
                        }
                    }
                }
            }
            return(result);
        }
예제 #2
0
        VersionatedMemberCandidates(PluginVersioning.memberType memberType)
        {
            //prepare the sorted list of candidates to output
            var selMeth = new SortedList <float, VersionMemberInfo>();
            //get the versionated methods of the plugin
            List <Tuple <MethodInfo, ParameterInfo[]> > meth = GetVersionatedMethods(memberType);

            //browse the method list
            foreach (Tuple <MethodInfo, ParameterInfo[]> tupleInfo in meth)
            {
                //get the custom attributes for the method
                Object[] attr = tupleInfo.Item1.GetCustomAttributes(typeof(VersionAttribute), true);
                //if there are custom attributes for it
                if (attr.Length > 0)
                {   //browse the attribute
                    foreach (Object obj in attr)
                    {
                        VersionAttribute vers = obj as VersionAttribute;    //cast as VersionAttribute
                        //if it is a VersionAttribute type
                        if (vers != null)
                        {
                            //create a entry on the sorted list
                            selMeth.Add(
                                vers.VersionFrom,
                                new VersionMemberInfo(
                                    vers.VersionFrom,                               //VersionLow
                                    tupleInfo.Item1,                                //MethodInfo
                                    //does it is instanciated here, so not in base class?
                                    (tupleInfo.Item1.DeclaringType == _pluginType), //IsInherited
                                    vers.IsMandatory,                               //IsMandatory
                                    tupleInfo.Item2                                 //parameter list of the method
                                    )
                                );
                        }
                    }
                }
            }
            return(selMeth);
        }