Пример #1
0
        /// <summary>
        /// Ignore if returns null.
        /// </summary>
        /// <param name="propertyElement"></param>
        /// <returns></returns>
        private static XElement GetPropertyElement(XElement propertyElement)
        {
            var result = new XElement(xsd + "element",
                                      new XAttribute("name", (string)propertyElement.Attribute("camelName")),
                                      new XAttribute("minOccurs", "0"));

            string propertyType = (string)propertyElement.Attribute("type");

            if (propertyType == "Collection")
            {
                result.Add(new XAttribute("maxOccurs", "unbounded"));
                var elementType = propertyElement.Element("elementType");
                result.Attribute("name").Value = (string)elementType.Attribute("elementTag");
                result.Add(new XAttribute("type", (string)elementType.Attribute("name")));
            }
            else if (propertyType == "Enum")
            {
                string enumType = (string)propertyElement.Attribute("enumType");

                result.Add(new XAttribute("maxOccurs", "1"));
                result.Add(new XAttribute("type", enumType));
            }
            else if (IgnoreTypes.Contains(propertyType))
            {
                return(null);
            }
            else
            {
                result.Add(new XAttribute("maxOccurs", "1"));
                result.Add(new XAttribute("type", GetXsdType(propertyType, false)));
            }

            return(result);
        }
Пример #2
0
        private void WriteIEnumerable(System.IO.TextWriter writer, object value)
        {
            WritingArray = true;
            writer.Write("[");
            PushIndent();
            IEnumerable?enumerable = value as System.Collections.IEnumerable;
            int         writeCount = 0;

#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
#pragma warning disable CS8602 // Dereference of a possibly null reference.
            foreach (object item in enumerable)
#pragma warning restore CS8602 // Dereference of a possibly null reference.
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
            {
                bool skip = false;
                if (!(item is null) && IgnoreTypes.Contains(item.GetType()))
                {
                    skip = true;
                }

                if (!skip && ((item?.GetType().IsValueType != false) ||
                              (value is System.Collections.IEnumerable)))
                {
                    if (writeCount > 0)
                    {
                        if (!WritingArray)
                        {
                            writer.Write($",{GetLineFeed()}{GetIndent()}");
                        }
                        else
                        {
                            writer.Write(",");
                        }
                    }
#pragma warning disable CS8604 // Possible null reference argument.
                    Write(writer, item);
#pragma warning restore CS8604 // Possible null reference argument.
                    ++writeCount;
                }
            }
            PopIndent();
            if (!WritingArray)
            {
                writer.Write($"{GetLineFeed()}{GetIndent()}]{GetLineFeed()}");
            }
            else
            {
                writer.Write($"]");
            }

            WritingArray = false;
        }
Пример #3
0
        private void DoCheck(object sender, LuaEventArgs e)
        {
            if (_weightSet == null)
            {
                LogDebug("No weight set was found for your character.{0}Ensure that the 'Data\\Weight Sets\\' folder exists and has valid weight sets.", Environment.NewLine);
                return;
            }

            if (!TreeRoot.IsRunning || StyxWoW.Me.Combat || StyxWoW.Me.Dead || StyxWoW.Me.IsGhost || Battlegrounds.IsInsideBattleground)
            {
                return;
            }

            // So.. beautiful!
            var equippableItems = (from item in StyxWoW.Me.BagItems
                                   where item != null
                                   where EquipQualities.Contains(item.Quality)
                                   let info = item.ItemInfo
                                              where
                                              info.Bond != WoWItemBondType.OnEquip ||
                                              EquipBoEQualities.Contains(item.Quality)
                                              let inventoryType = info.InventoryType
                                                                  let slots = InventoryManager.GetInventorySlotsByEquipSlot(inventoryType)
                                                                              where
                                                                              !IgnoreTypes.Contains(inventoryType) ||
                                                                              slots.Any(s => EquippedItems[s] == null)
                                                                              where
                                                                              inventoryType != InventoryType.TwoHandWeapon ||
                                                                              AutoEquipSettings.Instance.WeaponStyle == WeaponStyle.TwoHander
                                                                              where
                                                                              inventoryType != InventoryType.Shield ||
                                                                              AutoEquipSettings.Instance.WeaponStyle == WeaponStyle.OneHanderAndShield
                                                                              where StyxWoW.Me.CanEquipItem(item)
                                                                              select item).ToList();

            if (equippableItems.Count == 0)
            {
                return;
            }

            if (AutoEquipSettings.Instance.AutoEquipItems)
            {
                CheckForItems(equippableItems);
            }
            if (AutoEquipSettings.Instance.AutoEquipBags)
            {
                CheckForBag(equippableItems);
            }
        }
Пример #4
0
            protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
            {
                var property = base.CreateProperty(member, memberSerialization);

                if (IgnoreTypes.Contains(property.PropertyType) ||
                    typeof(MulticastDelegate).IsAssignableFrom(property.PropertyType.BaseType))
                {
                    Trace.TraceError(
                        $"Runtime avoided JSON serializing property '{property.PropertyType.Name} {property.DeclaringType.Name}.{property.PropertyName}' that would cause a circular reference.");
                    property.ShouldSerialize = i => false;
                    property.Ignored         = true;
                }

                return(property);
            }
Пример #5
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: AdobeTypeGen <adobe-type>.xml > <adobe-type>.d.ts");
                return;
            }

            var xmlPath = args[0];

            if (!File.Exists(xmlPath))
            {
                Console.Error.WriteLine($"File not exists: {xmlPath}");
            }

            // dictionary
            // - map
            //  - topicref
            //   - topicref
            // - package
            //  - classdef
            //   - elements
            //    - property
            //    - method
            var xmlDoc      = XElement.Load(xmlPath);
            var classDefs   = GenerateClassDefs(xmlDoc);
            var customTypes = GenerateCustomTypes();

            Console.WriteLine("/// <reference path=\"global.d.ts\" />");
            foreach (var cls in classDefs)
            {
                if (IgnoreTypes.IndexOf(cls.Name) >= 0)
                {
                    continue;
                }
                Console.WriteLine(cls.ToExpr());
            }

            foreach (var ct in customTypes)
            {
                Console.WriteLine(ct.ToExpr());
            }
            Console.WriteLine();
        }
        /// <summary>
        /// After the action has been executed, the Rescue will be invoked if the filterContext has an Exception.
        /// </summary>
        /// <param name="filterContext">The current filter context.</param>
        public virtual void OnException(ExceptionContext filterContext)
        {
            Type baseExceptionType = filterContext.Exception.GetBaseException().GetType();

            if (IgnoreAjax && filterContext.HttpContext.Request.IsAjaxRequest())
            {
                return;
            }

            if (IgnoreTypes != null && IgnoreTypes.Contains(baseExceptionType))
            {
                return;
            }

            foreach (var expectedExceptionType in ExceptionsTypes)
            {
                if (expectedExceptionType.IsAssignableFrom(baseExceptionType))
                {
                    if (AutoLocate)
                    {
                        if (ViewExists(baseExceptionType, filterContext))
                        {
                            ViewName                       = baseExceptionType.Name;
                            filterContext.Result           = CreateActionResult(filterContext.Exception, filterContext);
                            filterContext.ExceptionHandled = true;
                            return;
                        }

                        if (ViewExists(expectedExceptionType, filterContext))
                        {
                            ViewName                       = expectedExceptionType.Name;
                            filterContext.Result           = CreateActionResult(filterContext.Exception, filterContext);
                            filterContext.ExceptionHandled = true;
                            return;
                        }
                    }
                    filterContext.Result           = CreateActionResult(filterContext.Exception, filterContext);
                    filterContext.ExceptionHandled = true;
                    return;
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Ignore if returns null
        /// </summary>
        /// <param name="propertyElement"></param>
        /// <returns></returns>
        private static XElement GetAttributeElement(XElement propertyElement)
        {
            var result = new XElement(xsd + "attribute",
                                      new XAttribute("name", (string)propertyElement.Attribute("camelName")));

            var propertyType = (string)propertyElement.Attribute("type");

            if (propertyType == "Collection")
            {
                return(null);
            }

            if (propertyType == "Enum")
            {
                string enumType = (string)propertyElement.Attribute("enumType");

                result.Add(new XAttribute("type", enumType));
            }
            else if (IgnoreTypes.Contains(propertyType))
            {
                return(null);
            }
            else
            {
                result.Add(new XAttribute("type", GetXsdType(propertyType, true)));
            }

            var doc = propertyElement.Element("doc");

            if (doc != null)
            {
                var summary = doc.Element("summary");
                if (summary != null)
                {
                    result.Add(new XElement(xsd + "annotation",
                                            new XElement(xsd + "documentation",
                                                         summary.Value)));
                }
            }

            return(result);
        }
Пример #8
0
 /// <summary>
 /// Whether to load the Startup Type or not, allows all Startup Types not in IgnoreTypes by default
 /// </summary>
 public virtual bool LoadType(Type startupType) => !IgnoreTypes.Contains(startupType);
Пример #9
0
            public void DumpObject(object?o, bool avoidDumpEntity = false)
            {
                if (o == null)
                {
                    Sb.Append("null");
                    return;
                }

                if (o is Type type)
                {
                    Sb.Append("typeof(");
                    Sb.Append(CSharpRenderer.TypeName(type));
                    Sb.Append(")");
                    return;
                }

                Type t = o.GetType();

                if (IsDelegate(t))
                {
                    Sb.Append("[DELEGATE]");
                    return;
                }

                if (IsBasicType(t) || t.IsValueType)
                {
                    Sb.Append(DumpValue(o !));
                    return;
                }

                Sb.Append("new ");

                Sb.Append(CSharpRenderer.CleanIdentifiers(CSharpRenderer.TypeName(t)));

                if (IgnoreTypes.Contains(t))
                {
                    Sb.Append("{ " + o !.ToString() + " }");
                    return;
                }

                if (objects.Contains(o !))
                {
                    if (o is Entity ent)
                    {
                        Sb.Append("({0}{1})".FormatWith(
                                      ent.IsNew ? "IsNew": ent.IdOrNull.ToString(),
                                      ent == null ? null : ", ticks: " + ent.ticks
                                      ));
                    }
                    if (o is Lite <Entity> )
                    {
                        var id = ((Lite <Entity>)o).IdOrNull;
                        Sb.Append(id.HasValue ? "({0})".FormatWith(id.Value) : "");
                    }
                    Sb.Append(" /* [ALREADY] {0} */".FormatWith(SafeToString(o !)));
                    return;
                }

                objects.Add(o !);

                if (o is Entity e)
                {
                    Sb.Append("({0}{1})".FormatWith(
                                  e.IsNew ? "IsNew" : e.IdOrNull.ToString(),
                                  e.ticks == 0 ? null : ", ticks: " + e.ticks
                                  ));

                    string toString = SafeToString(o);

                    Sb.Append(" /* {0} {1} */".FormatWith(toString, (avoidDumpEntity ? "[DUMP AS LITE]" : "")));

                    if (avoidDumpEntity)
                    {
                        return;
                    }
                }

                if (o is Lite <Entity> l)
                {
                    Sb.Append("({0}, \"{1}\")".FormatWith((l.IdOrNull.HasValue ? l.Id.ToString() : "null"), l.ToString()));
                    if (((Lite <Entity>)o).EntityOrNull != null && !avoidDumpEntity)
                    {
                        Sb.AppendLine().AppendLine("{".Indent(level));
                        level += 1;
                        var prop = o.GetType().GetProperty(nameof(Lite <Entity> .Entity)) !;
                        DumpPropertyOrField(prop.PropertyType, prop.Name, prop.GetValue(o, null) !);
                        level -= 1;
                        Sb.Append("}".Indent(level));
                    }
                    return;
                }

                if (o is IEnumerable ie && !Any(ie))
                {
                    Sb.Append("{}");
                    return;
                }

                if (o is byte[] && !showByteArrays)
                {
                    Sb.Append("{...}");
                    return;
                }

                Sb.AppendLine().AppendLine("{".Indent(level));
                level += 1;

                if (t.Namespace.HasText() && t.Namespace.StartsWith("System.Reflection"))
                {
                    Sb.AppendLine("ToString = {0},".FormatWith(SafeToString(o !)).Indent(level));
                }
                else if (o is Exception ex)
                {
                    DumpPropertyOrField(typeof(string), "Message", ex.Message);
                    DumpPropertyOrField(typeof(string), "StackTrace", ex.StackTrace);
                    DumpPropertyOrField(typeof(Exception), "InnerException", ex.InnerException);
                    DumpPropertyOrField(typeof(IDictionary), "Data", ex.Data);
                }
                else if (o is IEnumerable)
                {
                    if (o is IDictionary dic)
                    {
                        foreach (DictionaryEntry?item in dic)
                        {
                            Sb.Append("{".Indent(level));
                            DumpObject(item !.Value.Key);
                            Sb.Append(", ");
                            DumpObject(item !.Value.Value);
                            Sb.AppendLine("},");
                        }
                    }
                    else
                    {
                        foreach (var item in (o as IEnumerable) !)
                        {
                            Sb.Append("".Indent(level));
                            DumpObject(item, avoidDumpEntity);
                            Sb.AppendLine(",");
                        }
                    }
                }
                else if (!typeof(ModifiableEntity).IsAssignableFrom(t))
                {
                    foreach (var prop in t.GetProperties(BindingFlags.Instance | BindingFlags.Public))
                    {
                        var hasAvoidDumpEntityAttr = prop.HasAttribute <AvoidDumpEntityAttribute>();
                        DumpPropertyOrField(prop.PropertyType, prop.Name, prop.GetValue(o, null), hasAvoidDumpEntityAttr);
                    }
                }
                else
                {
                    foreach (var field in Reflector.InstanceFieldsInOrder(t).OrderBy(IsMixinField))
                    {
                        if (IsIdOrTicks(field))
                        {
                            continue;
                        }

                        var hasAvoidDumpEntityAttr = field.HasAttribute <AvoidDumpEntityAttribute>() || Reflector.TryFindPropertyInfo(field)?.HasAttribute <AvoidDumpEntityAttribute>() == true;

                        if (IsMixinField(field))
                        {
                            var val = field.GetValue(o);

                            if (val == null)
                            {
                                continue;
                            }

                            DumpPropertyOrField(field.FieldType, GetFieldName(field), val, hasAvoidDumpEntityAttr);
                        }

                        var skip = this.showIgnoredFields == ShowIgnoredFields.Yes ? false :
                                   this.showIgnoredFields == ShowIgnoredFields.OnlyQueryables ? IsIgnored(field) && Reflector.TryFindPropertyInfo(field)?.HasAttribute <QueryablePropertyAttribute>() != true :
                                   this.showIgnoredFields == ShowIgnoredFields.No ? IsIgnored(field) :
                                   throw new InvalidOperationException("Unexpected ShowIgnoredFields");

                        if (!skip)
                        {
                            DumpPropertyOrField(field.FieldType, GetFieldName(field), field.GetValue(o), hasAvoidDumpEntityAttr);
                        }
                    }
                }

                level -= 1;
                Sb.Append("}".Indent(level));
                return;
            }
Пример #10
0
        private void WriteIDictionary(System.IO.TextWriter writer, object value)
        {
            WritingArray = false;
            int index = 0;

            writer.Write("{");
            PushIndent();

            if (value is IDictionary dictionary)
            {
                List <string>?keys = new List <string>();
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
#pragma warning disable CS8604 // Possible null reference argument.
                foreach (string key in dictionary.Keys)
                {
                    keys.Add(key);
                }
#pragma warning restore CS8604 // Possible null reference argument.
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
                //foreach (object key in dictionary.Keys)
                foreach (string key in keys)
                {
                    object?item = dictionary[key];
                    bool   skip = false;
                    if (!(item is null) && IgnoreTypes.Contains(item.GetType()))
                    {
                        skip = true;
                    }

                    if (!skip)
                    {
                        if (index > 0)
                        {
                            writer.Write($",{GetLineFeed()}{GetIndent()}");
                        }
                        else
                        {
                            writer.Write($"{GetLineFeed()}{GetIndent()}");
                        }
                        writingPrimitiveValue = true;
                        Write(writer, key);
                        writingPrimitiveValue = false;

                        object?tmp = dictionary[key];
                        if (tmp?.GetType().IsPrimitive != false || (tmp is string))
                        {
                            writer.Write(":");
                            writingPrimitiveValue = true;
#pragma warning disable CS8604 // Possible null reference argument.
                            Write(writer, dictionary[key]);
#pragma warning restore CS8604 // Possible null reference argument.
                            writingPrimitiveValue = false;
                        }
                        else
                        {
                            writer.Write($": ");
#pragma warning disable CS8604 // Possible null reference argument.
                            Write(writer, dictionary[key]);
#pragma warning restore CS8604 // Possible null reference argument.
                        }

                        ++index;
                    }
                }
                PopIndent();
                if (dictionary.Count > 0)
                {
                    writer.Write(GetLineFeed());
                }

                writer.Write($"{GetIndent()}}}");
            }
        }
Пример #11
0
        public bool DefaultIgnoreFilter(object o)
        {
            var type = o.GetType();

            return(IgnoreTypes?.Contains(type) == true || o is IDisposable);
        }
Пример #12
0
 public static bool ShouldBeConverted(Type objType)
 {
     return(!objType.IsPrimitive && !objType.IsValueType && !IgnoreTypes.Contains(objType));
 }
Пример #13
0
        public static void Load(XElement xml)
        {
            XElement[] elements = xml.Elements().ToArray();
            foreach (XElement element in elements)
            {
                string name  = element.Name.ToString();
                string value = element.Value;

                switch (name.ToLower())
                {
                case "autoequipitems":
                case "equipitems":
                    bool autoEquipItems;
                    if (!bool.TryParse(value, out autoEquipItems))
                    {
                        Log(false, "Setting {0} has wrong value - boolean value expected, True/False. Value was: {1}", name, value);
                        autoEquipItems = true;
                    }

                    AutoEquipItems = autoEquipItems;
                    break;

                case "autoequipbags":
                case "equipbags":
                    bool autoEquipBags;
                    if (!bool.TryParse(value, out autoEquipBags))
                    {
                        Log(false, "Setting {0} has wrong value - boolean value expected, True/False. Value was: {1}", name, value);
                        autoEquipBags = true;
                    }

                    AutoEquipBags = autoEquipBags;
                    break;

                case "equipepics":
                case "equipepic":
                case "equippurples":
                case "equippurple":
                    bool equipEpics;
                    if (!bool.TryParse(value, out equipEpics))
                    {
                        Log(false, "Setting {0} has wrong value - boolean value expected, True/False. Value was: {1}", name, value);
                        equipEpics = false;
                    }

                    EquipPurples = equipEpics;
                    break;

                case "equiprares":
                case "equiprare":
                case "equipblues":
                case "equipblue":
                    bool equipRares;
                    if (!bool.TryParse(value, out equipRares))
                    {
                        Log(false, "Setting {0} has wrong value - boolean value expected, True/False. Value was: {1}", name, value);
                        equipRares = false;
                    }

                    EquipBlues = equipRares;
                    break;

                case "equipuncommons":
                case "equipuncommon":
                case "equipgreens":
                case "equipgreen":
                    bool equipGreens;
                    if (!bool.TryParse(value, out equipGreens))
                    {
                        Log(false, "Setting {0} has wrong value - boolean value expected, True/False. Value was: {1}", name, value);
                        equipGreens = false;
                    }

                    EquipGreens = equipGreens;
                    break;

                case "equipcommons":
                case "equipcommon":
                case "equipwhites":
                case "equipwhite":
                    bool equipWhites;
                    if (!bool.TryParse(value, out equipWhites))
                    {
                        Log(false, "Setting {0} has wrong value - boolean value expected, True/False. Value was: {1}", name, value);
                        equipWhites = false;
                    }

                    EquipWhites = equipWhites;
                    break;

                case "equippoors":
                case "equippoor":
                case "equipgray":
                case "equipgrays":
                case "equipgrey":
                case "equipgreys":
                    bool equipGrays;
                    if (!bool.TryParse(value, out equipGrays))
                    {
                        Log(false, "Setting {0} has wrong value - boolean value expected, True/False. Value was: {1}", name, value);
                        equipGrays = false;
                    }

                    EquipGrays = equipGrays;
                    break;

                case "replaceboa":
                case "replaceboas":
                case "replaceheirloom":
                case "replaceheirlooms":
                    bool replaceHeirlooms;
                    if (!bool.TryParse(value, out replaceHeirlooms))
                    {
                        Log(false, "Setting ReplaceHeirlooms has wrong value - boolean value expected, True/False. Value was: {0}", value);
                        replaceHeirlooms = false;
                    }

                    ReplaceHeirlooms = replaceHeirlooms;
                    break;

                case "ignoretypes":
                case "dontequiptypes":
                    XElement[] ignoreTypes = element.Elements("Type").ToArray();
                    foreach (XElement ignoreType in ignoreTypes)
                    {
                        string ignoreTypeValue = ignoreType.Value;
                        if (string.IsNullOrEmpty(ignoreTypeValue))
                        {
                            continue;
                        }

                        InventoryType type;
                        try
                        {
                            type = (InventoryType)Enum.Parse(typeof(InventoryType), ignoreTypeValue, true);
                        }
                        catch (ArgumentException)
                        {
                            Log(false, "Ignore type \"{0}\" is unknown!", ignoreTypeValue);
                            continue;
                        }

                        if (!IgnoreTypes.Contains(type))
                        {
                            IgnoreTypes.Add(type);
                        }
                    }
                    break;

                case "protectedslots":
                case "protectslots":
                    XElement[] protectedSlots = element.Elements("Slot").ToArray();
                    foreach (XElement protectedSlot in protectedSlots)
                    {
                        string protectedSlotValue = protectedSlot.Value;
                        if (string.IsNullOrEmpty(protectedSlotValue))
                        {
                            continue;
                        }

                        InventorySlot slot;
                        try
                        {
                            slot = (InventorySlot)Enum.Parse(typeof(InventorySlot), protectedSlotValue, true);
                        }
                        catch (ArgumentException)
                        {
                            Log(false, "Protected slot \"{0}\" is unknown!", protectedSlotValue);
                            continue;
                        }

                        if (!ProtectedSlots.Contains(slot))
                        {
                            ProtectedSlots.Add(slot);
                        }
                    }
                    break;

                case "ignoreitems":
                case "protecteditems":
                    XElement[] ignoreItems = element.Elements("Item").ToArray();
                    foreach (XElement ignoreItem in ignoreItems)
                    {
                        uint   ignoreItemId   = 0;
                        string ignoreItemName = "";

                        XAttribute[] ignoreItemAttribs = ignoreItem.Attributes().ToArray();
                        foreach (XAttribute ignoreItemAttrib in ignoreItemAttribs)
                        {
                            string attribName  = ignoreItemAttrib.Name.ToString();
                            string attribValue = ignoreItemAttrib.Value;

                            switch (attribName.ToLower())
                            {
                            case "id":
                            case "entry":
                                if (!uint.TryParse(attribValue, out ignoreItemId))
                                {
                                    Log(false, "Setting {0} has wrong value - positive number expected, 0 or > 0. Value was: {1}", name, value);
                                }

                                break;

                            case "name":
                                ignoreItemName = attribValue;
                                break;
                            }
                        }

                        IgnoreItems.Add(new KeyValuePair <uint, string>(ignoreItemId, ignoreItemName));
                    }
                    break;
                }
            }
        }
Пример #14
0
            public void DumpObject(object o)
            {
                if (o == null)
                {
                    Sb.Append("null");
                    return;
                }

                if (o is Type)
                {
                    Sb.Append("typeof(");
                    Sb.Append(CSharpRenderer.TypeName((Type)o));
                    Sb.Append(")");
                    return;
                }

                Type t = o.GetType();

                if (IsDelegate(t))
                {
                    Sb.Append("[DELEGATE]");
                    return;
                }

                if (IsBasicType(t) || t.IsValueType)
                {
                    Sb.Append(DumpValue(o));
                    return;
                }

                Sb.Append("new ");

                Sb.Append(CSharpRenderer.CleanIdentifiers(CSharpRenderer.TypeName(t)));

                if (IgnoreTypes.Contains(t))
                {
                    Sb.Append("{ " + o.ToString() + " }");
                    return;
                }

                if (objects.Contains(o))
                {
                    if (o is Entity)
                    {
                        var ident = o as Entity;
                        var ent   = o as Entity;

                        Sb.Append("({0}{1})".FormatWith(
                                      ident.IsNew ? "IsNew": ident.IdOrNull.ToString(),
                                      ent == null ? null : ", ticks: " + ent.ticks
                                      ));
                    }
                    if (o is Lite <Entity> )
                    {
                        var id = ((Lite <Entity>)o).IdOrNull;
                        Sb.Append(id.HasValue ? "({0})".FormatWith(id.Value) : "");
                    }
                    Sb.Append(" /* [CICLE] {0} */".FormatWith(SafeToString(o)));
                    return;
                }

                objects.Add(o);

                if (o is Entity)
                {
                    var ent = (Entity)o;
                    Sb.Append("({0}{1})".FormatWith(
                                  ent.IsNew ? "IsNew" : ent.IdOrNull.ToString(),
                                  ent.ticks == 0 ? null : ", ticks: " + ent.ticks
                                  ));

                    string toString = SafeToString(o);

                    Sb.Append(" /* {0} */".FormatWith(toString));
                }

                if (o is Lite <Entity> )
                {
                    var l = o as Lite <Entity>;
                    Sb.Append("({0}, \"{1}\")".FormatWith((l.IdOrNull.HasValue ? l.Id.ToString() : "null"), l.ToString()));
                    if (((Lite <Entity>)o).UntypedEntityOrNull == null)
                    {
                        return;
                    }
                }

                if (o is IEnumerable && !Any((o as IEnumerable)))
                {
                    Sb.Append("{}");
                    return;
                }

                if (o is byte[] && !showByteArrays)
                {
                    Sb.Append("{...}");
                    return;
                }

                Sb.AppendLine().AppendLine("{".Indent(level));
                level += 1;

                if (t.Namespace.HasText() && t.Namespace.StartsWith("System.Reflection"))
                {
                    Sb.AppendLine("ToString = {0},".FormatWith(SafeToString(o)).Indent(level));
                }
                else if (o is Exception)
                {
                    var ex = o as Exception;
                    DumpPropertyOrField(typeof(string), "Message", ex.Message);
                    DumpPropertyOrField(typeof(string), "StackTrace", ex.StackTrace);
                    DumpPropertyOrField(typeof(Exception), "InnerException", ex.InnerException);
                    DumpPropertyOrField(typeof(IDictionary), "Data", ex.Data);
                }
                else if (o is IEnumerable)
                {
                    if (o is IDictionary)
                    {
                        foreach (DictionaryEntry item in (o as IDictionary))
                        {
                            Sb.Append("{".Indent(level));
                            DumpObject(item.Key);
                            Sb.Append(", ");
                            DumpObject(item.Value);
                            Sb.AppendLine("},");
                        }
                    }
                    else
                    {
                        foreach (var item in (o as IEnumerable))
                        {
                            Sb.Append("".Indent(level));
                            DumpObject(item);
                            Sb.AppendLine(",");
                        }
                    }
                }
                else if (!typeof(ModifiableEntity).IsAssignableFrom(t))
                {
                    foreach (var prop in t.GetProperties(BindingFlags.Instance | BindingFlags.Public))
                    {
                        DumpPropertyOrField(prop.PropertyType, prop.Name, prop.GetValue(o, null));
                    }
                }
                else
                {
                    foreach (var field in Reflector.InstanceFieldsInOrder(t).OrderBy(IsMixinField))
                    {
                        if (IsIdOrTicks(field))
                        {
                            continue;
                        }

                        if (IsMixinField(field))
                        {
                            var val = field.GetValue(o);

                            if (val == null)
                            {
                                continue;
                            }

                            DumpPropertyOrField(field.FieldType, GetFieldName(field), val);
                        }

                        if (!showIgnoredFields && (field.HasAttribute <IgnoreAttribute>()) || (Reflector.TryFindPropertyInfo(field)?.HasAttribute <IgnoreAttribute>() == true))
                        {
                            continue;
                        }

                        DumpPropertyOrField(field.FieldType, GetFieldName(field), field.GetValue(o));
                    }
                }

                level -= 1;
                Sb.Append("}".Indent(level));
                return;
            }