示例#1
0
 /// <summary>
 /// Initialize new instance of the data structure
 /// </summary>
 /// <param name="t">The identified type of the member (method or property)</param>
 /// <param name="n">Name of the member</param>
 /// <param name="a">Access modifier of the member</param>
 /// <param name="r">Type of the return object</param>
 /// <param name="p">Types of the parameters, if any</param>
 public InteropMemberInfo(InteropMemberType t, string n, bool a, InteropTypeInfo r, InteropParamInfo[] p)
 {
     type       = t;
     name       = n;
     accessmod  = a;
     returnType = r;
     paramTypes = p;
 }
示例#2
0
        /// <summary>
        /// Gathers further information on each type (class) within an assembly.
        /// </summary>
        /// <param name="types">Types contained within a type</param>
        /// <param name="typeConstants">FieldInfos related to the type</param>
        /// <param name="typeMembers">PropertyInfos related to the type</param>
        /// <param name="typeMethods">MethodInfos related to the type</param>
        /// <returns>InteropTypeInfo Array</returns>
        private static InteropTypeInfo[] CreateInteropTypeInfos(Type[] types, Dictionary <Type, FieldInfo[]> typeConstants, Dictionary <Type, PropertyInfo[]> typeMembers, Dictionary <Type, MethodInfo[]> typeMethods)
        {
            List <InteropTypeInfo> infos = new List <InteropTypeInfo>();
            List <Type>            st    = types.OrderBy(o => o.Name).ToList();

            foreach (Type t in st)
            {
                if (Regex.IsMatch(t.Name, @"^[a-zA-Z]+$") && (!t.Name.ToLower().Trim().Contains("event")))
                {
                    InteropTypeInfo          info      = new InteropTypeInfo(t.Name, t.Namespace, t, new InteropMemberInfo[0]);
                    List <InteropMemberInfo> constants = new List <InteropMemberInfo>();
                    List <InteropMemberInfo> members   = new List <InteropMemberInfo>();
                    List <InteropMemberInfo> methods   = new List <InteropMemberInfo>();

                    if (typeConstants.ContainsKey(t))
                    {
                        foreach (FieldInfo mi in typeConstants[t])
                        {
                            if (Regex.IsMatch(mi.Name, @"^[a-zA-Z0-9]+$") && Regex.IsMatch(mi.FieldType.Name, @"^[a-zA-Z0-9]+$") && (!IsBaseImplementation(mi.Name)))
                            {
                                constants.Add(new InteropMemberInfo(InteropMemberType.PROPERTY, mi.Name, mi.IsStatic, new InteropTypeInfo(mi.FieldType.Name, mi.FieldType.Namespace, mi.FieldType, new InteropMemberInfo[0]), new InteropParamInfo[0]));
                            }
                        }
                    }

                    if (typeMembers.ContainsKey(t))
                    {
                        foreach (PropertyInfo mi in typeMembers[t])
                        {
                            if (Regex.IsMatch(mi.Name, @"^[a-zA-Z0-9]+$") && Regex.IsMatch(mi.PropertyType.Name, @"^[a-zA-Z0-9]+$") && (!IsBaseImplementation(mi.Name)))
                            {
                                members.Add(new InteropMemberInfo(InteropMemberType.PROPERTY, mi.Name, mi.GetGetMethod().IsStatic, new InteropTypeInfo(mi.PropertyType.Name, mi.PropertyType.Namespace, mi.PropertyType, new InteropMemberInfo[0]), new InteropParamInfo[0]));
                            }
                        }
                    }

                    if (typeMethods.ContainsKey(t))
                    {
                        foreach (MethodInfo mi in typeMethods[t])
                        {
                            if (Regex.IsMatch(mi.Name, @"^[a-zA-Z0-9]+$") && (!IsBaseImplementation(mi.Name)) && Regex.IsMatch(mi.ReturnType.Name, @"^[a-zA-Z0-9]+$"))
                            {
                                methods.Add(new InteropMemberInfo(InteropMemberType.METHOD, mi.Name, mi.IsStatic, new InteropTypeInfo(mi.ReturnType.Name, mi.ReturnType.Namespace, mi.ReturnType, new InteropMemberInfo[0]), GetMethodParameters(mi)));
                            }
                        }
                    }

                    constants = constants.OrderBy(o => o.name).ToList();
                    members   = members.OrderBy(o => o.name).ToList();
                    methods   = methods.OrderBy(o => o.name).ToList();

                    constants.AddRange(members);
                    constants.AddRange(methods);

                    info.members = constants.ToArray();
                    if (info.members.Length > 0)
                    {
                        infos.Add(info);
                    }
                }
            }

            return(infos.ToArray());
        }