Ejemplo n.º 1
0
        private static bool AnalyzeField(FieldDefinition fieldDefinition, XElement newElement)
        {
            bool result = false;

            string[] supportByLibrary = _netOfficeSupportTable.GetTypeSupport(fieldDefinition.FieldType.FullName);
            if (fieldDefinition.FieldType.FullName.StartsWith(_apiName, StringComparison.InvariantCultureIgnoreCase) &&
                !fieldDefinition.FieldType.FullName.Equals(_apiName + ".dll", StringComparison.InvariantCultureIgnoreCase) && CountOf(fieldDefinition.FieldType.FullName, ".") > 1 && (null != supportByLibrary))
            {
                result = true;
                string   typeName      = NetOfficeSupportTable.GetName(fieldDefinition.FieldType.FullName);
                string   componentName = NetOfficeSupportTable.GetLibrary(fieldDefinition.FieldType.FullName);
                XElement fields        = newElement.Element("Fields");
                XElement newField      = new XElement(new XElement("Entity",
                                                                   new XAttribute("Type", fieldDefinition.FieldType.FullName),
                                                                   new XAttribute("Name", fieldDefinition.Name),
                                                                   new XAttribute("IsPublic", fieldDefinition.IsPublic.ToString()),
                                                                   new XAttribute("Static", fieldDefinition.IsStatic)));

                XElement supportByNode = new XElement("SupportByLibrary", new XAttribute("Api", componentName));
                newField.Add(supportByNode);
                if (null != supportByLibrary)
                {
                    fields.Add(newField);
                    supportByNode.Add(new XAttribute("Name", typeName));
                    foreach (string item in supportByLibrary)
                    {
                        supportByNode.Add(new XElement("Version", item));
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        private static bool AnalyzeMethodVariables(MethodDefinition methodDefinition, XElement entity, XElement newMethodNode)
        {
            XElement variablesNode = null;

            bool result = false;

            Mono.Cecil.Cil.MethodBody body = methodDefinition.Body;
            if (null != body)
            {
                // local variables
                foreach (VariableDefinition itemVariable in body.Variables)
                {
                    if (itemVariable.VariableType.FullName.StartsWith(_apiName) && CountOf(itemVariable.VariableType.FullName, ".") > 1 && !itemVariable.VariableType.FullName.Equals(_apiName + ".dll", StringComparison.InvariantCultureIgnoreCase))
                    {
                        string componentName = NetOfficeSupportTable.GetLibrary(itemVariable.VariableType.FullName);
                        string typeName      = NetOfficeSupportTable.GetName(itemVariable.VariableType.FullName);

                        if (null == variablesNode)
                        {
                            variablesNode = new XElement("Variables");
                            newMethodNode.Add(variablesNode);
                        }

                        result = true;

                        XElement newVar = new XElement("Entity",
                                                       new XAttribute("Type", itemVariable.VariableType.FullName),
                                                       new XAttribute("Name", itemVariable.ToString()),
                                                       new XAttribute("Api", componentName));

                        variablesNode.Add(newVar);

                        XElement supportByNode = new XElement("SupportByLibrary", new XAttribute("Api", componentName));
                        newVar.Add(supportByNode);
                        string[] supportByLibrary = _netOfficeSupportTable.GetTypeSupport(itemVariable.VariableType.FullName);
                        if (null != supportByLibrary)
                        {
                            supportByNode.Add(new XAttribute("Name", typeName));
                            foreach (string item in supportByLibrary)
                            {
                                supportByNode.Add(new XElement("Version", item));
                            }
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        private static bool AnalyzeMethod(MethodDefinition methodDefinition, XElement entity)
        {
            bool result = false;

            bool isProperty = methodDefinition.IsGetter || methodDefinition.IsSetter;

            XElement newMethodNode  = new XElement("Method", new XAttribute("Name", methodDefinition.Name), new XAttribute("IsProperty", isProperty.ToString()), new XAttribute("IsPublic", methodDefinition.IsPublic.ToString()), new XElement("FieldSets"), new XElement("LocalFieldSets"));
            XElement parametersNode = null;

            // parameter
            foreach (ParameterDefinition paramDefintion in methodDefinition.Parameters)
            {
                string[] supportByLibrary = _netOfficeSupportTable.GetTypeSupport(paramDefintion.ParameterType.FullName);
                if (paramDefintion.ParameterType.FullName.StartsWith(_apiName) && (!paramDefintion.ParameterType.FullName.StartsWith("NetOffice.DeveloperToolbox")) &&
                    !paramDefintion.ParameterType.FullName.Equals(_apiName + ".dll", StringComparison.InvariantCultureIgnoreCase) && CountOf(paramDefintion.ParameterType.FullName, ".") > 1 && (null != supportByLibrary))
                {
                    if (null == parametersNode)
                    {
                        parametersNode = new XElement("Parameters");
                        newMethodNode.Add(parametersNode);
                    }
                    string componentName = NetOfficeSupportTable.GetLibrary(paramDefintion.ParameterType.FullName);
                    string typeName      = NetOfficeSupportTable.GetName(paramDefintion.ParameterType.FullName);
                    result = true;
                    XElement newParam = new XElement("Entity",
                                                     new XAttribute("Type", paramDefintion.ParameterType.FullName),
                                                     new XAttribute("Name", paramDefintion.Name),
                                                     new XAttribute("Api", componentName));

                    parametersNode.Add(newParam);

                    XElement supportByNode = new XElement("SupportByLibrary", new XAttribute("Api", componentName));
                    newParam.Add(supportByNode);
                    if (null != supportByLibrary)
                    {
                        supportByNode.Add(new XAttribute("Name", typeName));
                        foreach (string item in supportByLibrary)
                        {
                            supportByNode.Add(new XElement("Version", item));
                        }
                    }
                }
            }

            // returnvalue
            if ((methodDefinition.ReturnType.FullName.StartsWith(_apiName) &&
                 !methodDefinition.ReturnType.FullName.Equals(_apiName + ".dll", StringComparison.InvariantCultureIgnoreCase) &&
                 CountOf(methodDefinition.ReturnType.FullName, ".") > 1 &&
                 (!methodDefinition.ReturnType.FullName.StartsWith("NetOffice.DeveloperToolbox"))))
            {
                result = true;
                string   componentName   = NetOfficeSupportTable.GetLibrary(methodDefinition.ReturnType.FullName);
                string   typeName        = NetOfficeSupportTable.GetName(methodDefinition.ReturnType.FullName);
                XElement returnValueNode = new XElement("ReturnValue");
                XElement returnValue     = new XElement("Entity", new XAttribute("Type", typeName), new XAttribute("FullType", methodDefinition.ReturnType.FullName),
                                                        new XAttribute("Api", componentName));

                XElement supportByNode = new XElement("SupportByLibrary", new XAttribute("Api", componentName));
                returnValue.Add(supportByNode);
                string[] supportByLibrary = _netOfficeSupportTable.GetTypeSupport(methodDefinition.ReturnType.FullName);
                if (null != supportByLibrary)
                {
                    supportByNode.Add(new XAttribute("Name", typeName));
                    foreach (string item in supportByLibrary)
                    {
                        supportByNode.Add(new XElement("Version", item));
                    }
                }

                returnValueNode.Add(returnValue);
                newMethodNode.Add(returnValueNode);
            }

            bool resultVariables    = AnalyzeMethodVariables(methodDefinition, entity, newMethodNode);
            bool resultNewObjects   = AnalyzeMethodCreateNewObjects(methodDefinition, entity, newMethodNode);
            bool resultCalls        = AnalyzeMethodCalls(methodDefinition, entity, newMethodNode);
            bool fieldSetCalls      = AnalyzeMethodFieldSets(methodDefinition, entity, newMethodNode);
            bool fieldSetLocalCalls = AnalyzeMethodLocalFieldSets(methodDefinition, entity, newMethodNode);

            if ((result) || (resultVariables) || (resultNewObjects) || (resultCalls) || (fieldSetCalls) || (fieldSetCalls))
            {
                entity.Element("Methods").Add(newMethodNode);
                result = true;
            }

            return(result);
        }