Exemplo n.º 1
0
        /// <summary>
        /// iterates through member nodes inside the given xml file,
        /// and remove the node if it's hidden.
        /// If there's no member nodes/ all of the member nodes have been removed,
        /// the files is deleted
        /// </summary>
        /// <param name="xmlPath"></param>
        /// <param name="zeroTouchModule"></param>
        internal static void RemoveDocumentationForHiddenNodes(string xmlPath, ZeroTouchModule zeroTouchModule)
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(xmlPath);
            XmlNodeList elemList = xml.GetElementsByTagName("member");
            MemberData  memberData;

            for (int i = 0; i < elemList.Count; i++)
            {
                string elementName    = elemList[i].Attributes["name"].Value;
                bool   hasToBeRemoved = false;
                memberData = ParseMemberElement(elementName);

                switch (memberData.type)
                {
                case Type.Field:

                case Type.Property:

                    if (!zeroTouchModule.PropertyExists(memberData.TypeName, memberData.MemberName))
                    {
                        hasToBeRemoved = true;
                    }
                    break;

                case Type.Method:

                    if (!zeroTouchModule.MethodExists(memberData.TypeName, memberData.MemberName))
                    {
                        hasToBeRemoved = true;
                    }
                    break;

                case Type.Type:

                    if (!zeroTouchModule.TypeExists(memberData.TypeName))
                    {
                        hasToBeRemoved = true;
                    }
                    break;

                default: break;
                }

                if (hasToBeRemoved)
                {
                    elemList[i].ParentNode.RemoveChild(elemList[i]);
                    i--;
                }
            }
            //save the update
            xml.Save(xmlPath);

            //node is empty, delete the xml file
            if (elemList.Count == 0)
            {
                File.Delete(xmlPath);
            }
        }
Exemplo n.º 2
0
        public void RemoveDocumentationForHiddenNodes()
        {
            ZeroTouchModule module = new ZeroTouchModule("ProtoGeometry.dll");

            XmlDocumentationsUtility.RemoveDocumentationForHiddenNodes("ProtoGeometry.xml", module);
            XmlDocument xmlTestFile = new XmlDocument();

            xmlTestFile.Load("ProtoGeometry.xml");

            XmlNodeList elemTestList = xmlTestFile.GetElementsByTagName("member");

            for (int i = 0; i < elemTestList.Count; i++)
            {
                var memberElement = XmlDocumentationsUtility.ParseMemberElement(elemTestList[i].Attributes["name"].Value);

                switch (memberElement.type)
                {
                case XmlDocumentationsUtility.Type.Field:

                case XmlDocumentationsUtility.Type.Property:

                    Assert.IsTrue(module.PropertyExists(memberElement.TypeName, memberElement.MemberName));
                    break;

                case XmlDocumentationsUtility.Type.Method:

                    Assert.IsTrue(module.MethodExists(memberElement.TypeName, memberElement.MemberName));
                    break;

                case XmlDocumentationsUtility.Type.Type:

                    Assert.IsTrue(module.TypeExists(memberElement.TypeName));
                    break;

                default: break;
                }
            }
        }
Exemplo n.º 3
0
 public void PropertyExists()
 {
     Assert.IsTrue(module.PropertyExists("Autodesk.DesignScript.Geometry.Vector", "X"));
     Assert.IsTrue(module.PropertyExists("Autodesk.DesignScript.Geometry.Surface", "ClosedInU"));
 }