Ejemplo n.º 1
0
        private void ReflectOutEvents()
        {
            //do events
            foreach (EventInfo ei in TypeInAssembly.GetEvents(RequiredBindings))
            {
                if (TypeInAssembly == ei.DeclaringType)
                {
                    //add all the event types to the associations List, so that
                    //the association lines for this class can be obtained, and
                    //possibly drawn on the container
                    string eName = GetGenericsForType(ei.EventHandlerType);
                    eName = LowerAndTrim(eName);
                    string association = ei.EventHandlerType.IsGenericType ? ei.EventHandlerType.GetGenericTypeDefinition().FullName : ei.EventHandlerType.FullName;
                    if (!Associations.Contains(association))
                    {
                        Associations.Add(association);
                    }
                    //do we want long or short event description displayed
                    if (ShowEvents)
                    {
                        Events.Add(eName + " " + ei.Name);
                    }
                    else
                    {
                        Events.Add(ei.Name);
                    }
                }
            }

            HasEvents = Events.Any();
        }
Ejemplo n.º 2
0
        private void ReflectOutConstructors()
        {
            //do constructors
            foreach (ConstructorInfo ci in TypeInAssembly.GetConstructors(RequiredBindings))
            {
                if (TypeInAssembly == ci.DeclaringType)
                {
                    string cDetail = TypeInAssembly.Name + "(";
                    string pDetail = "";

                    //add all the constructor param types to the associations List, so that
                    //the association lines for this class can be obtained, and
                    //possibly drawn on the container
                    ParameterInfo[] pif = ci.GetParameters();
                    foreach (ParameterInfo p in pif)
                    {
                        string pName = GetGenericsForType(p.ParameterType);
                        pName = LowerAndTrim(pName);

                        if (IncludeConstructorParametersAsAssociations)
                        {
                            string association = p.ParameterType.IsGenericType ? p.ParameterType.GetGenericTypeDefinition().FullName : p.ParameterType.FullName;

                            if (!Associations.Contains(association))
                            {
                                Associations.Add(association);
                            }
                        }
                        pDetail  = pName + " " + p.Name + ", ";
                        cDetail += pDetail;
                    }

                    if (cDetail.LastIndexOf(",") > 0)
                    {
                        cDetail = cDetail.Substring(0, cDetail.LastIndexOf(","));
                    }

                    cDetail += ")";
                    //do we want long or short field constructor displayed
                    if (ShowConstructorParameters)
                    {
                        Constructors.Add(cDetail);
                    }
                    else
                    {
                        Constructors.Add(TypeInAssembly.Name + "( )");
                    }
                }
            }

            HasConstructors = Constructors.Any();
        }
Ejemplo n.º 3
0
        private void ReflectOutInterfaces()
        {
            //do interfaces
            if (ShowInterfaces)
            {
                Type[] tiArray = TypeInAssembly.GetInterfaces();
                foreach (Type ii in tiArray)
                {
                    Interfaces.Add(ii.Name.ToString());
                }
            }

            HasInterfaces = Interfaces.Any();
        }
Ejemplo n.º 4
0
        private void ReflectOutProperties()
        {
            //do properties
            foreach (PropertyInfo pi in TypeInAssembly.GetProperties(RequiredBindings))
            {
                if (TypeInAssembly == pi.DeclaringType)
                {
                    // add read method if exists
                    if (pi.CanRead)
                    {
                        propGetters.Add(pi.GetGetMethod(true));
                    }
                    // add write method if exists
                    if (pi.CanWrite)
                    {
                        propSetters.Add(pi.GetSetMethod(true));
                    }

                    string pName = GetGenericsForType(pi.PropertyType);
                    //add all the property types to the associations List, so that
                    //the association lines for this class can be obtained, and
                    //possibly drawn on the container
                    pName = LowerAndTrim(pName);

                    if (IncludePropertyTypesAsAssociations)
                    {
                        string association = pi.PropertyType.IsGenericType ? pi.PropertyType.GetGenericTypeDefinition().FullName : pi.PropertyType.FullName;
                        if (!Associations.Contains(association))
                        {
                            Associations.Add(association);
                        }
                    }

                    //do we want long or short property description displayed
                    if (ShowPropertyTypes)
                    {
                        Properties.Add(pName + " " + pi.Name);
                    }
                    else
                    {
                        Properties.Add(pi.Name);
                    }
                }
            }

            HasProperties = Properties.Any();
        }
Ejemplo n.º 5
0
        private void ReflectOutFields()
        {
            //do fields
            foreach (FieldInfo fi in TypeInAssembly.GetFields(RequiredBindings))
            {
                if (TypeInAssembly == fi.DeclaringType)
                {
                    //add all the field types to the associations List, so that
                    //the association lines for this class can be obtained, and
                    //possibly drawn on the container
                    string fName = GetGenericsForType(fi.FieldType);
                    fName = LowerAndTrim(fName);

                    if (IncludeFieldTypesAsAssociations)
                    {
                        string association = fi.FieldType.IsGenericType ? fi.FieldType.GetGenericTypeDefinition().FullName : fi.FieldType.FullName;

                        if (!Associations.Contains(association))
                        {
                            Associations.Add(association);
                        }
                    }

                    //do we want long or short field description displayed
                    if (ShowFieldTypes)
                    {
                        Fields.Add(fName + " " + fi.Name);
                    }
                    else
                    {
                        Fields.Add(fi.Name);
                    }
                }
            }


            HasFields = Fields.Any();
        }
Ejemplo n.º 6
0
        private void ReflectOutMethods()
        {
            //do methods
            foreach (MethodInfo mi in TypeInAssembly.GetMethods(RequiredBindings))
            {
                if (TypeInAssembly == mi.DeclaringType)
                {
                    string mDetail = mi.Name + "( ";
                    string pDetail = "";
                    //do we want to display method arguments, if we do create the
                    //appopraiate string
                    if (ShowMethodArguments)
                    {
                        ParameterInfo[] pif = mi.GetParameters();
                        foreach (ParameterInfo p in pif)
                        {
                            //add all the parameter types to the associations List, so that
                            //the association lines for this class can be obtained, and
                            //possibly drawn on the container
                            string pName = GetGenericsForType(p.ParameterType);
                            pName = LowerAndTrim(pName);

                            if (IncludeMethodArgumentAsAssociations)
                            {
                                string association = p.ParameterType.IsGenericType ? p.ParameterType.GetGenericTypeDefinition().FullName : p.ParameterType.FullName;
                                if (!Associations.Contains(association))
                                {
                                    Associations.Add(association);
                                }
                            }

                            pDetail  = pName + " " + p.Name + ", ";
                            mDetail += pDetail;
                        }
                        if (mDetail.LastIndexOf(",") > 0)
                        {
                            mDetail = mDetail.Substring(0, mDetail.LastIndexOf(","));
                        }
                    }
                    mDetail += " )";
                    //add the return type to the associations List, so that
                    //the association lines for this class can be obtained, and
                    //possibly drawn on the container
                    string rName = GetGenericsForType(mi.ReturnType);
                    //dont want to include void as an association type
                    if (!string.IsNullOrEmpty(rName))
                    {
                        rName = GetGenericsForType(mi.ReturnType);
                        rName = LowerAndTrim(rName);
                        string association = mi.ReturnType.IsGenericType ? mi.ReturnType.GetGenericTypeDefinition().FullName : mi.ReturnType.FullName;
                        if (!Associations.Contains(association))
                        {
                            Associations.Add(association);
                        }
                        //do we want to display method return types
                        if (ShowMethodReturnValues)
                        {
                            mDetail += " : " + rName;
                        }
                    }
                    else
                    {
                        //do we want to display method return types
                        if (ShowMethodReturnValues)
                        {
                            mDetail += " : void";
                        }
                    }

                    //work out whether this is a normal method, in which case add it
                    //or if its a property get/set method, should it be added
                    if (!ShowGetMethodForProperty && propGetters.Contains(mi))
                    {
                        /* hidden get method */
                    }
                    else if (!ShowSetMethodForProperty && propSetters.Contains(mi))
                    {
                        /* hidden set method */
                    }
                    else
                    {
                        if (ParseMethodBodyIL)
                        {
                            Methods.Add(new SerializableMethodData(mDetail, ReadMethodBodyAndAddAssociations(mi)));
                        }
                        else
                        {
                            Methods.Add(new SerializableMethodData(mDetail, ""));
                        }
                    }
                }
            }
            HasMethods = Methods.Any();
        }