System.Security.SecurityElement.ToString C# (CSharp) Method

ToString() private method

private ToString ( string indent, object obj, string>.Action write ) : void
indent string
obj object
write string>.Action
return void
        private void ToString(string indent, object obj, Action<object, string> write)
        {
            write(obj, "<");
            write(obj, _tag);

            // If there are any attributes, plop those in.
            if (_attributes != null && _attributes.Count > 0)
            {
                write(obj, " ");

                int iMax = _attributes.Count;
                Debug.Assert(iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly");

                for (int i = 0; i < iMax; i += 2)
                {
                    string strAttrName = (string)_attributes[i];
                    string strAttrValue = (string)_attributes[i + 1];

                    write(obj, strAttrName);
                    write(obj, "=\"");
                    write(obj, strAttrValue);
                    write(obj, "\"");

                    if (i != _attributes.Count - 2)
                    {
                        write(obj, Environment.NewLine);
                    }
                }
            }

            if (_text == null && (_children == null || _children.Count == 0))
            {
                // If we are a single tag with no children, just add the end of tag text.
                write(obj, "/>");
                write(obj, Environment.NewLine);
            }
            else
            {
                // Close the current tag.
                write(obj, ">");

                // Output the text
                write(obj, _text);

                // Output any children.
                if (_children != null)
                {
                    ConvertSecurityElementFactories();

                    write(obj, Environment.NewLine);

                    for (int i = 0; i < _children.Count; ++i)
                    {
                        ((SecurityElement)_children[i]).ToString(string.Empty, obj, write);
                    }
                }

                // Output the closing tag
                write(obj, "</");
                write(obj, _tag);
                write(obj, ">");
                write(obj, Environment.NewLine);
            }
        }

Same methods

SecurityElement::ToString ( ) : string

Usage Example

Example #1
0
    //removePath将要删除的路径
    static public string GetFileListXMLString(List <string> fileList, string removePath)
    {
        var root = new System.Security.SecurityElement("root");

        foreach (var item in fileList)
        {
            string fileName = Path.GetFileName(item);
            string ext      = Path.GetExtension(item);
            if (string.Compare(ext, ".meta", true) == 0)
            {
                continue;
            }

            string filePath = null;
            if (IsUseAssetBundle)
            {
                filePath = item.Replace(removePath, "");
                root.AddChild(new System.Security.SecurityElement("k", fileName.ToLower()));
                root.AddChild(new System.Security.SecurityElement("v", filePath.ToLower()));
            }
            else
            {
                filePath = item.Replace(removePath, "");
                root.AddChild(new System.Security.SecurityElement("k", fileName));
                root.AddChild(new System.Security.SecurityElement("v", filePath));
            }
        }

        return(root.ToString());
    }
All Usage Examples Of System.Security.SecurityElement::ToString