Пример #1
0
        private static string Write(IScriptable scriptable, Indent indent, int depth)
        {
            if (scriptable == null)
            {
                return("");
            }

            StringBuilder sb = new StringBuilder();

            string text = WriteObject(scriptable, indent);

            if (text != null)
            {
                if (!(scriptable is IReadOnlyScriptable))
                {
                    sb.Append("<!-- [" + depth + "](" + scriptable.GetGuid() + ") ");
                    //if (indent.Peek() == null) sb.Append("\n-->");
                    //else sb.AppendLine("-->");
                    sb.AppendLine("-->");
                }
                sb.AppendLine(text);
            }

            foreach (Accessor accessor in FieldAccessor.GetForObject(scriptable))
            {
                IList list = accessor.Get() as IList;
                if (list == null)
                {
                    continue;
                }

                for (int i = 0; i < list.Count; i++)
                {
                    IScriptable child = list[i] as IScriptable;
                    if (child == null)
                    {
                        continue;
                    }
                    IIgnorable ignorable = child as IIgnorable;
                    if (ignorable != null && ignorable.Ignored)
                    {
                        continue;
                    }
                    sb.AppendLine();
                    sb.Append(Write(child, indent, depth + 1));
                }
            }

            if (text != null)
            {
                indent.Pop();
            }

            return(sb.ToString());
        }