예제 #1
0
        public static XDom LoadFile(string aFileName, EDomType aFileType)
        {
            switch (aFileType)
            {
            case EDomType.Xml:
                return(NewFromXml(aFileName));

            case EDomType.Hierarchy:
                return(NewFromIndentedHierarchy(aFileName));

            default:
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// Returns a string representation of this object with a set indent
        /// </summary>
        private string ToString(EDomType aType, int aIndent)
        {
            StringBuilder sb = new StringBuilder();

            if (this.Value.Length != 0 || this.Contents.Count == 0)
            {
                sb.Append(' ', aIndent * 4);
                switch (aType)
                {
                case EDomType.Xml:
                    sb.Append("<" + Name + ">" + Value);
                    break;

                case EDomType.Hierarchy:
                    sb.Append(Name + "=" + Value + "\r\n");
                    break;
                }

                foreach (XDom c in this.Contents)
                {
                    sb.Append(c.ToString(aType, aIndent + 1));
                }

                switch (aType)
                {
                case EDomType.Xml:
                    sb.Append("</" + Name + ">\r\n");
                    break;

                case EDomType.Hierarchy:
                    sb.Append("\r\n");
                    break;
                }
            }
            else
            {
                sb.Append(' ', aIndent * 2);

                switch (aType)
                {
                case EDomType.Xml:
                    sb.Append("<" + Name + ">\r\n");
                    break;

                case EDomType.Hierarchy:
                    sb.Append(Name + "\r\n");
                    break;
                }

                foreach (XDom c in this.Contents)
                {
                    sb.Append(c.ToString(aType, aIndent + 1));
                }

                switch (aType)
                {
                case EDomType.Xml:
                    sb.Append(' ', aIndent * 2);
                    sb.Append("</" + Name + ">\r\n");
                    break;

                case EDomType.Hierarchy:
                    break;
                }
            }

            return(sb.ToString());
        }
예제 #3
0
 /// <summary>
 /// Returns a string representation of this object
 /// </summary>
 public string ToString(EDomType aType)
 {
     return(ToString(aType, 0));
 }