示例#1
0
        private void AddProperty(XmlNode objectNode, TLI.MemberInfo methodInfo, string componentKey)
        {
            int     optionalParameterCount = methodInfo.Parameters.OptionalCount;
            XmlNode methodsNode            = objectNode.SelectSingleNode("Properties");

            XmlNode methodNode = LookForProperty(methodsNode, methodInfo, false);

            if (null == methodNode)
            {
                methodNode = AddPropertyNodeToObject(methodsNode, methodInfo, componentKey, false);
            }

            AddInvokeKindToPropertyNode(methodNode, methodInfo.InvokeKind);
            AddComponentKeyToPropertyNode(methodNode, componentKey);

            if (optionalParameterCount > 0)
            {
                methodNode = LookForProperty(methodsNode, methodInfo, true);
                if (null == methodNode)
                {
                    AddPropertyNodeToObject(methodsNode, methodInfo, componentKey, true);
                }
                else
                {
                    AddInvokeKindToPropertyNode(methodNode, methodInfo.InvokeKind);
                    AddComponentKeyToPropertyNode(methodNode, componentKey);
                }
            }
        }
        private bool IsClassMethod(TLI.MemberInfo memberInfo)
        {
            bool isImpliedComMethod = _parent.IsIDispatchOrIUnkownMethod(memberInfo);

            if (true == isImpliedComMethod)
            {
                return(false);
            }

            if (memberInfo.DescKind == DescKinds.DESCKIND_FUNCDESC)
            {
                if ((memberInfo.InvokeKind != InvokeKinds.INVOKE_PROPERTYGET) &&
                    (memberInfo.InvokeKind != InvokeKinds.INVOKE_PROPERTYPUT) &&
                    (memberInfo.InvokeKind != InvokeKinds.INVOKE_PROPERTYPUTREF))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (memberInfo.InvokeKind == InvokeKinds.INVOKE_FUNC)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
示例#3
0
        private bool IsInterfaceProperty(TLI.MemberInfo memberInfo)
        {
            if (memberInfo.DescKind == DescKinds.DESCKIND_FUNCDESC)
            {
                if ((memberInfo.InvokeKind == InvokeKinds.INVOKE_PROPERTYGET) ||
                    (memberInfo.InvokeKind == InvokeKinds.INVOKE_PROPERTYPUT) ||
                    (memberInfo.InvokeKind == InvokeKinds.INVOKE_PROPERTYPUTREF))
                {
                    if (memberInfo.InvokeKind == InvokeKinds.INVOKE_PROPERTYPUTREF)
                    {
                    }

                    if ((memberInfo.Parameters.Count > 0) && (memberInfo.Name == "HasAxis"))
                    {
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        private bool MethodHasReturnValue(TLI.MemberInfo methodInfo)
        {
            switch (methodInfo.ReturnType.VarType)
            {
            case TliVarType.VT_VOID:
                return(false);

            default:
                return(true);
            }
        }
        private void AddDispIdMethodNode(XmlNode componentNode, XmlNode methodNode, TLI.MemberInfo methodInfo)
        {
            string  key            = componentNode.Attributes["Key"].InnerText;
            XmlNode refDipsIdsNode = methodNode.SelectSingleNode("DispIds");
            XmlNode refIdNode      = refDipsIdsNode.SelectSingleNode("DispId[@ComponentKey = '" + key + "']");

            if (null == refIdNode)
            {
                refIdNode = _parent.Document.CreateElement("DispId");
                Utils.AddAtrributeToNode(refIdNode, "ComponentKey", key);
                Utils.AddAtrributeToNode(refIdNode, "Id", methodInfo.MemberId.ToString());
                refDipsIdsNode.AppendChild(refIdNode);
            }
        }
        private List <XmlNode> GetParametersList(XmlNode methodNode, TLI.MemberInfo propertyInfo, int targetParamsCount)
        {
            List <XmlNode> returnList  = new List <XmlNode>();
            XmlNodeList    paramsNodes = methodNode.SelectNodes("Parameters");

            foreach (XmlNode paramNode in paramsNodes)
            {
                XmlNodeList paramNodes = paramNode.SelectNodes("Parameter");
                if (paramNodes.Count == targetParamsCount)
                {
                    returnList.Add(paramNode);
                }
            }

            return(returnList);
        }
        private XmlNode GetParametersNode(XmlNode propertyNode, TLI.MemberInfo propertyInfo, bool withOptionals)
        {
            int targetParamsCount = propertyInfo.Parameters.Count;

            if (false == withOptionals)
            {
                targetParamsCount -= propertyInfo.Parameters.OptionalCount;
            }

            List <XmlNode> listNodes = GetParametersList(propertyNode, propertyInfo, targetParamsCount);

            if ((targetParamsCount == 0) && (listNodes.Count == 1))
            {
                return(listNodes[0]);
            }

            if (listNodes.Count == 0)
            {
                return(null);
            }

            for (int i = 0; i < propertyInfo.Parameters.Count; i++)
            {
                ParameterInfo paramInfo      = propertyInfo.Parameters[(short)(i + 1)];
                XmlNode       parametersNode = listNodes[i];
                if ((withOptionals == false) && (paramInfo.Optional == true))
                {
                    Marshal.ReleaseComObject(paramInfo);
                    return(null);
                }

                XmlNode x = parametersNode.SelectSingleNode("Parameter[@Name='" + paramInfo.Name + "'" + " and " +
                                                            "@Type='" + _parent.GetParameterType(paramInfo) + "']");
                if (null != x)
                {
                    Marshal.ReleaseComObject(paramInfo);
                    return(parametersNode);
                }

                Marshal.ReleaseComObject(paramInfo);
            }

            return(null);
        }
        private void AddReturnValueToParametersNode(XmlNode parametersNode, TLI.MemberInfo methodInfo)
        {
            XmlNode methodReturnNode = parametersNode.SelectSingleNode("ReturnValue");

            Utils.AddAtrributeToNode(methodReturnNode, "IsComProxy", _parent.IsComProxy(methodInfo.ReturnType).ToString());
            Utils.AddAtrributeToNode(methodReturnNode, "IsExternal", methodInfo.ReturnType.IsExternalType.ToString());
            Utils.AddAtrributeToNode(methodReturnNode, "IsArray", "False");
            Utils.AddAtrributeToNode(methodReturnNode, "Type", _parent.GetReturnType(methodInfo));

            string typeKind = "";

            if (null != methodInfo.ReturnType.TypeInfo)
            {
                typeKind = methodInfo.ReturnType.TypeInfo.TypeKind.ToString();
            }
            Utils.AddAtrributeToNode(methodReturnNode, "TypeKind", typeKind);

            Utils.AddAtrributeToNode(methodReturnNode, "SourceKey", _parent.GetSourceKey(methodInfo.ReturnType));
        }
示例#9
0
 private bool IsClassProperty(TLI.MemberInfo memberInfo)
 {
     if (memberInfo.DescKind == DescKinds.DESCKIND_FUNCDESC)
     {
         if ((memberInfo.InvokeKind == InvokeKinds.INVOKE_PROPERTYGET) ||
             (memberInfo.InvokeKind == InvokeKinds.INVOKE_PROPERTYPUT) ||
             (memberInfo.InvokeKind == InvokeKinds.INVOKE_PROPERTYPUTREF))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
        private void AddInvokeKindToPropertyNode(XmlNode propertyNode, TLI.MemberInfo propertyInfo)
        {
            InvokeKinds kinds = propertyInfo.InvokeKind;

            string kindExists = propertyNode.Attributes["InvokeKind"].InnerText;

            switch (kinds)
            {
            case InvokeKinds.INVOKE_PROPERTYGET:
                if ((kindExists != "INVOKE_PROPERTYPUT") && (kindExists != "INVOKE_PROPERTYPUTREF"))
                {
                    propertyNode.Attributes["InvokeKind"].InnerText = kinds.ToString();
                }
                break;

            case InvokeKinds.INVOKE_PROPERTYPUT:
            case InvokeKinds.INVOKE_PROPERTYPUTREF:
                propertyNode.Attributes["InvokeKind"].InnerText = kinds.ToString();
                break;
            }
        }
 private XmlNode GetPropertyNode(XmlNode propertiesNode, TLI.MemberInfo propertyInfo)
 {
     return(propertiesNode.SelectSingleNode("Property[@Name ='" + propertyInfo.Name + "']"));
 }
        private void AddParametersToMethodNode(XmlNode componentNode, XmlNode methodNode, TLI.MemberInfo methodInfo, bool withOptionals)
        {
            XmlNode parametersNode = GetParametersNode(methodNode, methodInfo, withOptionals);

            if (null == parametersNode)
            {
                parametersNode = _parent.Document.CreateElement("Parameters");
                Utils.AddChildToNode(parametersNode, "RefComponents");
                Utils.AddChildToNode(parametersNode, "ReturnValue");
                methodNode.AppendChild(parametersNode);

                foreach (ParameterInfo paramInfo in methodInfo.Parameters)
                {
                    if ((false == withOptionals) && (paramInfo.Optional == true))
                    {
                        break;
                    }

                    XmlNode paramNode = parametersNode.OwnerDocument.CreateElement("Parameter");
                    parametersNode.AppendChild(paramNode);

                    Utils.AddAtrributeToNode(paramNode, "Name", paramInfo.Name);
                    Utils.AddAtrributeToNode(paramNode, "Caption", paramInfo.Name);
                    Utils.AddAtrributeToNode(paramNode, "IsExternal", paramInfo.VarTypeInfo.IsExternalType.ToString());
                    Utils.AddAtrributeToNode(paramNode, "IsComProxy", _parent.IsComProxy(paramInfo.VarTypeInfo).ToString());
                    Utils.AddAtrributeToNode(paramNode, "IsOptional", paramInfo.Optional.ToString());
                    Utils.AddAtrributeToNode(paramNode, "IsRef", "false");
                    Utils.AddAtrributeToNode(paramNode, "IsArray", "false");
                    Utils.AddAtrributeToNode(paramNode, "Type", _parent.GetParameterType(paramInfo));

                    string typeKind = "";
                    if (null != paramInfo.VarTypeInfo.TypeInfo)
                    {
                        typeKind = paramInfo.VarTypeInfo.TypeInfo.TypeKind.ToString();
                    }
                    Utils.AddAtrributeToNode(paramNode, "TypeKind", typeKind);

                    Utils.AddAtrributeToNode(paramNode, "SourceKey", _parent.GetSourceKey(paramInfo.VarTypeInfo));
                }
            }
            AddReturnValueToParametersNode(parametersNode, methodInfo);
            AddComponentRefToParametersNode(componentNode, parametersNode);
        }
 private XmlNode GetMethodNode(XmlNode methodsNode, TLI.MemberInfo methodInfo)
 {
     return(methodsNode.SelectSingleNode("Method[@Name ='" + methodInfo.Name + "']"));
 }
        private XmlNode AddNewMethodNodeToObject(XmlNode componentNode, XmlNode methodsNode, TLI.MemberInfo methodInfo)
        {
            XmlNode methodNode = _parent.Document.CreateElement("Method");

            methodsNode.AppendChild(methodNode);

            Utils.AddAtrributeToNode(methodNode, "Name", methodInfo.Name);
            Utils.AddAtrributeToNode(methodNode, "Caption", methodInfo.Name);
            Utils.AddAtrributeToNode(methodNode, "Key", XmlConvert.EncodeName(Guid.NewGuid().ToString()));
            Utils.AddAtrributeToNode(methodNode, "HasReturnType", MethodHasReturnValue(methodInfo).ToString());

            Utils.AddChildToNode(methodNode, "DispIds");
            Utils.AddChildToNode(methodNode, "RefComponents");

            return(methodNode);
        }
        internal void AddProperty(XmlNode componentNode, XmlNode projectNode, XmlNode objectNode, TLI.MemberInfo propertyInfo)
        {
            int     optionalParameterCount = propertyInfo.Parameters.OptionalCount;
            XmlNode propertiesNode         = objectNode.SelectSingleNode("Properties");

            XmlNode propertyNode = GetPropertyNode(propertiesNode, propertyInfo);

            if (null == propertyNode)
            {
                propertyNode = AddNewPropertyNodeToObject(componentNode, propertiesNode, propertyInfo);
            }

            AddInvokeKindToPropertyNode(propertyNode, propertyInfo);
            AddDispIdPropertyNode(componentNode, propertyNode, propertyInfo);
            AddComponentRefToPropertyNode(componentNode, propertyNode);

            AddParametersToPropertyNode(componentNode, propertyNode, propertyInfo, false);
            AddParametersToPropertyNode(componentNode, propertyNode, propertyInfo, true);
        }
示例#16
0
        private void AddParametersToPropertyNode(XmlNode methodNode, TLI.MemberInfo methodInfo, bool withOptional)
        {
            XmlNode parametersNode = methodNode.SelectSingleNode("Parameters");

            foreach (ParameterInfo paramInfo in methodInfo.Parameters)
            {
                if (false == withOptional)
                {
                    if (paramInfo.Optional == true)
                    {
                        break;
                    }
                }

                XmlNode paramNode = parametersNode.OwnerDocument.CreateElement("Param");
                parametersNode.AppendChild(paramNode);

                XmlAttribute attribute = _parent.COMTree.CreateAttribute("Name");
                attribute.InnerText = paramInfo.Name;
                paramNode.Attributes.Append(attribute);

                attribute           = _parent.COMTree.CreateAttribute("Type");
                attribute.InnerText = _parent.GetParameterType(paramInfo);
                paramNode.Attributes.Append(attribute);

                attribute           = _parent.COMTree.CreateAttribute("ReturnTypeKind");
                attribute.InnerText = "";
                paramNode.Attributes.Append(attribute);
                if (null != paramInfo.VarTypeInfo.TypeInfo)
                {
                    attribute.InnerText = paramInfo.VarTypeInfo.TypeInfo.TypeKind.ToString();
                }

                attribute           = _parent.COMTree.CreateAttribute("Optional");
                attribute.InnerText = paramInfo.Optional.ToString();
                paramNode.Attributes.Append(attribute);

                attribute           = _parent.COMTree.CreateAttribute("IsExternalType");
                attribute.InnerText = paramInfo.VarTypeInfo.IsExternalType.ToString();
                paramNode.Attributes.Append(attribute);

                XmlNode definitionNode = _parent.COMTree.CreateElement("Definition");
                paramNode.AppendChild(definitionNode);
                _parent.AddAtrributeToNode(definitionNode, "GUID", "");
                if (false == paramInfo.VarTypeInfo.IsExternalType)
                {
                    if (null != paramInfo.VarTypeInfo.TypeInfo)
                    {
                        definitionNode.Attributes["GUID"].InnerText = XmlConvert.EncodeName(paramInfo.VarTypeInfo.TypeInfo.Parent.GUID);
                    }
                }
                else
                {
                    definitionNode.Attributes["GUID"].InnerText = XmlConvert.EncodeName(paramInfo.VarTypeInfo.TypeLibInfoExternal.GUID);
                }

                attribute           = _parent.COMTree.CreateAttribute("IsRef");
                attribute.InnerText = "False";
                paramNode.Attributes.Append(attribute);

                attribute           = _parent.COMTree.CreateAttribute("IsArray");
                attribute.InnerText = "False";
                paramNode.Attributes.Append(attribute);
            }
        }
示例#17
0
        private XmlNode LookForProperty(XmlNode methodsNode, TLI.MemberInfo methodInfo, bool withOptionals)
        {
            XmlNode returnNode = null;

            foreach (XmlNode nodeMethod in methodsNode.ChildNodes)
            {
                string methodName  = methodInfo.Name;
                string methodName2 = nodeMethod.Attributes["Name"].InnerText;

                if (methodName == methodName2)
                {
                    XmlNode    paramsNode = nodeMethod.SelectSingleNode("Parameters");
                    Parameters paramInfos = methodInfo.Parameters;

                    int methodInfoParametersCount = methodInfo.Parameters.Count;
                    if (withOptionals == false)
                    {
                        methodInfoParametersCount -= methodInfo.Parameters.OptionalCount;
                    }

                    if (paramsNode.ChildNodes.Count == methodInfoParametersCount)
                    {
                        for (int i = 1; i <= methodInfoParametersCount; i++)
                        {
                            ParameterInfo paramInfo = methodInfo.Parameters[(short)i];
                            if ((paramInfo.Optional == true) && (withOptionals == true))
                            {
                                Marshal.ReleaseComObject(paramInfo);
                                break;
                            }

                            #region check properties
                            XmlNode paramNode  = paramsNode.ChildNodes[i - 1];
                            string  paramType  = paramInfo.VarTypeInfo.VarType.ToString();
                            string  paramType2 = paramNode.Attributes["Type"].InnerText;
                            string  paramName  = paramInfo.Name;
                            string  paramName2 = paramNode.Attributes["Name"].InnerText;

                            string paramOptional  = paramInfo.Optional.ToString();
                            string paramOptional2 = paramNode.Attributes["Optional"].InnerText;

                            if ((paramType != paramType2) || (paramName != paramName2) || (paramOptional != paramOptional2))
                            {
                                Marshal.ReleaseComObject(paramInfo);
                                break;
                            }
                            #endregion

                            Marshal.ReleaseComObject(paramInfo);
                        }

                        Marshal.ReleaseComObject(paramInfos);
                        returnNode = nodeMethod;
                        return(nodeMethod);
                    }

                    Marshal.ReleaseComObject(paramInfos);
                }
            }

            return(returnNode);
        }
        internal void AddMethod(XmlNode componentNode, XmlNode projectNode, XmlNode objectNode, TLI.MemberInfo methodInfo)
        {
            int     optionalParameterCount = methodInfo.Parameters.OptionalCount;
            XmlNode methodsNode            = objectNode.SelectSingleNode("Methods");

            XmlNode methodNode = GetMethodNode(methodsNode, methodInfo);

            if (null == methodNode)
            {
                methodNode = AddNewMethodNodeToObject(componentNode, methodsNode, methodInfo);
            }

            AddDispIdMethodNode(componentNode, methodNode, methodInfo);
            AddComponentRefToMethodNode(componentNode, methodNode);

            AddParametersToMethodNode(componentNode, methodNode, methodInfo, false);
            AddParametersToMethodNode(componentNode, methodNode, methodInfo, true);
        }
示例#19
0
        private XmlNode AddPropertyNodeToObject(XmlNode methodsNode, TLI.MemberInfo methodInfo, string componentKey, bool withOptional)
        {
            XmlNode methodNode = _parent.COMTree.CreateElement("Property");

            methodsNode.AppendChild(methodNode);

            XmlAttribute attribute = _parent.COMTree.CreateAttribute("Name");

            attribute.InnerText = methodInfo.Name;
            methodNode.Attributes.Append(attribute);

            attribute           = _parent.COMTree.CreateAttribute("IsExternalType");
            attribute.InnerText = methodInfo.ReturnType.IsExternalType.ToString();
            methodNode.Attributes.Append(attribute);

            XmlNode definitionNode = _parent.COMTree.CreateElement("Definition");

            methodNode.AppendChild(definitionNode);
            _parent.AddAtrributeToNode(definitionNode, "GUID", "");
            if (false == methodInfo.ReturnType.IsExternalType)
            {
                if (null != methodInfo.ReturnType.TypeInfo)
                {
                    definitionNode.Attributes["GUID"].InnerText = XmlConvert.EncodeName(methodInfo.ReturnType.TypeInfo.Parent.GUID);
                }
            }
            else
            {
                definitionNode.Attributes["GUID"].InnerText = XmlConvert.EncodeName(methodInfo.ReturnType.TypeLibInfoExternal.GUID);
            }

            attribute           = _parent.COMTree.CreateAttribute("ReturnType");
            attribute.InnerText = _parent.GetReturnType(methodInfo);
            methodNode.Attributes.Append(attribute);

            attribute           = _parent.COMTree.CreateAttribute("ReturnTypeKind");
            attribute.InnerText = "";
            methodNode.Attributes.Append(attribute);
            if (null != methodInfo.ReturnType.TypeInfo)
            {
                attribute.InnerText = methodInfo.ReturnType.TypeInfo.TypeKind.ToString();
            }

            attribute           = _parent.COMTree.CreateAttribute("IsRef");
            attribute.InnerText = "False";
            methodNode.Attributes.Append(attribute);

            attribute           = _parent.COMTree.CreateAttribute("IsArray");
            attribute.InnerText = "False";
            methodNode.Attributes.Append(attribute);

            attribute           = _parent.COMTree.CreateAttribute("INVOKE_PROPERTYGET");
            attribute.InnerText = "false";
            methodNode.Attributes.Append(attribute);

            attribute           = _parent.COMTree.CreateAttribute("INVOKE_PROPERTYPUT");
            attribute.InnerText = "false";
            methodNode.Attributes.Append(attribute);

            attribute           = _parent.COMTree.CreateAttribute("INVOKE_PROPERTYPUTREF");
            attribute.InnerText = "false";
            methodNode.Attributes.Append(attribute);
            methodNode.Attributes[methodInfo.InvokeKind.ToString()].InnerText = "true";

            XmlNode componentsNode = _parent.COMTree.CreateElement("Components");

            methodNode.AppendChild(componentsNode);
            AddComponentKeyToMethodNode(methodNode, componentKey);

            XmlNode paramsNode = _parent.COMTree.CreateElement("Parameters");

            methodNode.AppendChild(paramsNode);

            AddParametersToPropertyNode(methodNode, methodInfo, withOptional);

            return(methodNode);
        }
        private XmlNode AddNewPropertyNodeToObject(XmlNode componentNode, XmlNode propertiesNode, TLI.MemberInfo propertyInfo)
        {
            XmlNode propertyNode = _parent.Document.CreateElement("Property");

            propertiesNode.AppendChild(propertyNode);

            Utils.AddChildToNode(propertyNode, "DispIds");
            Utils.AddChildToNode(propertyNode, "RefComponents");

            Utils.AddAtrributeToNode(propertyNode, "Name", propertyInfo.Name);
            Utils.AddAtrributeToNode(propertyNode, "Caption", propertyInfo.Name);
            Utils.AddAtrributeToNode(propertyNode, "Key", XmlConvert.EncodeName(Guid.NewGuid().ToString()));
            Utils.AddAtrributeToNode(propertyNode, "InvokeKind", propertyInfo.InvokeKind.ToString());
            Utils.AddAtrributeToNode(propertyNode, "SourceKey", _parent.GetSourceKey(propertyInfo.ReturnType));

            string typeKind = "";

            if (null != propertyInfo.ReturnType.TypeInfo)
            {
                typeKind = propertyInfo.ReturnType.TypeInfo.TypeKind.ToString();
            }
            Utils.AddAtrributeToNode(propertyNode, "TypeKind", typeKind);

            return(propertyNode);
        }