Ejemplo n.º 1
0
        public bool SearchDynVar(string ns, string classId, string varId)
        {
            VarPath path = new VarPath();

            path.NamespaceName = ns;
            path.ClassName     = classId;
            path.VarName       = varId;
            return(IsDynamic(path));
        }
Ejemplo n.º 2
0
        public void SetDynamic(VarPath path)
        {
            //Get/Create nodes until parent element is reached
            XmlNode node = getOrCreateUntilParent(path);

            //Set dynamic (field or variable)
            if (path.VarName != null)
            {
                getOrCreateNode(node, DynVarTag, NameAtt, path.VarName);
            }
            //Set dynamic (method return)
            else if (path.MethodName != null && node.Name.Equals(MethodTag) && node is XmlElement)
            {
                (node as XmlElement).SetAttribute(DynReturnAtt, true.ToString());
            }
        }
Ejemplo n.º 3
0
        //*
        // * Extended interface with new SearchDynVar overloading (unnecessary since IsDynamic accepts VarPath)
        // *  - Dynamic method return managing
        // *  - Interface members managing
        // *

        #region SearchDynVar

        public bool SearchDynVar(string ns, string classOrInterfaceId, string methodId, bool isClassId)
        {
            VarPath path = new VarPath();

            path.NamespaceName = ns;
            if (isClassId)
            {
                path.ClassName = classOrInterfaceId;
            }
            else
            {
                path.InterfaceName = classOrInterfaceId;
            }
            path.MethodName = methodId;
            return(IsDynamic(path));
        }
Ejemplo n.º 4
0
        private XmlNode getOrCreateUntilParent(VarPath path)
        {
            XmlNode node = document.DocumentElement;

            if (path.NamespaceName != null)
            {
                node = getOrCreateNode(node, NamespaceTag, NameAtt, path.NamespaceName);
            }
            if (path.ClassName != null)
            {
                node = getOrCreateNode(node, ClassTag, NameAtt, path.ClassName);
            }
            else if (path.InterfaceName != null)
            {
                node = getOrCreateNode(node, InterfaceTag, NameAtt, path.InterfaceName);
            }
            if (path.MethodName != null)
            {
                node = getOrCreateNode(node, MethodTag, NameAtt, path.MethodName);
            }
            // * "block" element is not used anymore.
            // *
            // *
            //if (path.Blocks.Count > 0)
            //{
            //    XmlNodeList nodeList;
            //    XmlNode blockNode;
            //    for (int blockLevel = 0; blockLevel < path.Blocks.Count; blockLevel++)
            //    {
            //        nodeList = node.SelectNodes("block");
            //        blockNode = null;
            //        for (int i = 0; i <= path.Blocks[blockLevel] - nodeList.Count; i++)
            //        {
            //            blockNode = document.CreateElement("block");
            //            node.AppendChild(blockNode);
            //        }
            //        node = blockNode == null ? nodeList[path.Blocks[blockLevel]] : blockNode;
            //    }
            //}
            return(node);
        }
Ejemplo n.º 5
0
        private XmlNode getOrCreateUntilParent(VarPath path)
        {
            XmlNode node = document.DocumentElement;

            if (path.NamespaceName != null)
            {
                node = getOrCreateNode(node, NamespaceTag, NameAtt, path.NamespaceName);
            }
            if (path.ClassName != null)
            {
                node = getOrCreateNode(node, ClassTag, NameAtt, path.ClassName);
            }
            else if (path.InterfaceName != null)
            {
                node = getOrCreateNode(node, InterfaceTag, NameAtt, path.InterfaceName);
            }
            if (path.MethodName != null)
            {
                node = getOrCreateNode(node, MethodTag, NameAtt, path.MethodName);
            }
            return(node);
        }
Ejemplo n.º 6
0
        public bool IsDynamic(VarPath path)
        {
            //Get/Create nodes until parent element is reached
            XmlNode node = getOrCreateUntilParent(path);

            //Check dynamic (field or variable)
            if (path.VarName != null)
            {
                node = node.SelectSingleNode(
                    DynVarTag + "[@" + NameAtt + "= '" + path.VarName + "']");
                //Var is dynamic if and only if node exists
                return(node != null);
            }
            //Check dynamic (method return)
            else if (path.MethodName != null && node.Name.Equals(MethodTag) && node is XmlElement)
            {
                XmlElement methodElement = node as XmlElement;
                return(true.ToString().Equals(methodElement.GetAttribute(DynReturnAtt)));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        public void SetStatic(VarPath path)
        {
            //Get/Create nodes until parent element is reached
            XmlNode node = getOrCreateUntilParent(path);

            //Set static (field or variable)
            if (path.VarName != null)
            {
                XmlNode varNode = node.SelectSingleNode(
                    DynVarTag + "[@" + NameAtt + "= '" + path.VarName + "']");
                node.RemoveChild(varNode);
            }
            //Set static (method return)
            else if (path.MethodName != null)
            {
                XmlNode methodNode = node.SelectSingleNode(
                    MethodTag + "[@" + NameAtt + "= '" + path.MethodName + "']");
                XmlElement methodElement = methodNode as XmlElement;
                if (methodElement != null)
                {
                    methodElement.SetAttribute(DynReturnAtt, false.ToString());
                }
            }
        }