Based on: https://stackoverflow.com/a/42264037/6155481
 public static void Write(object element, int depth, TextWriter log)
 {
     ObjectDumper dumper = new ObjectDumper(depth);
     dumper.writer = log;
     dumper.WriteObject(null, element);
     log.WriteLine(new string('-', 20));
 }
 public static string Write(object o, int depth)
 {
     var sw = new StringWriter();
     sw.NewLine = "\r\n";
     ObjectDumper dumper = new ObjectDumper(sw, depth);
     dumper.WriteObject(null, o);
     return sw.ToString();
 }
Beispiel #3
0
	public static string ToString(object o, int depth = 0)
	{
		using (var sw = new StringWriter())
		{
			ObjectDumper dumper = new ObjectDumper(depth, sw);
			dumper.WriteObject(null, o);
			return sw.ToString();
		}
	}
Beispiel #4
0
 /// <summary>
 /// Dumps the object to a string. Added for convenience by Pete.
 /// </summary>
 public static string String(object element)
 {
     using (var w = new StringWriter())
     {
         var dumper = new ObjectDumper(0) { writer = w };
         dumper.WriteObject(null, element);
         return w.ToString();
     }
 }
 public static void Write(object element, int depth, NLog.Logger log)
 {
     if (log.IsTraceEnabled)
     {
         ObjectDumper dumper = new ObjectDumper(depth);
         dumper.WriteObject(null, element);
         log.Trace(dumper.builder);
     }
 }
        public void DumpValueTypeInteger() {
            var objectDumper = new ObjectDumper(1);
            var xElement = objectDumper.Dump(1337, "Model");

            var stringBuilder = new StringBuilder();
            ObjectDumper.ConvertToJSon(xElement, stringBuilder);
            var json = stringBuilder.ToString();

            var jObject = new JObject(
                new JProperty("name", "Model"), 
                new JProperty("value", "1337"));

            ComparareJsonObject(jObject, json);
        }
Beispiel #7
0
		/// <summary>
		/// Dumps values of the specified target.
		/// </summary>
		/// <param name="target">The target.</param>
		/// <param name="depth">The depth of the dump.</param>
		/// <returns>A string representing the object dump.</returns>
		public static string Dump(object target, int depth)
		{
			try
			{
				using (var dumper = new ObjectDumper(depth))
				{
					dumper.WriteObject(null, target);
					return dumper.ToString().TrimEnd(Environment.NewLine.ToCharArray());
				}
			}
			catch (Exception ex)
			{
				return string.Format("Dump failure: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace);
			}
		}
Beispiel #8
0
 public static void Write(object o, int depth)
 {
     ObjectDumper dumper = new ObjectDumper(depth);
     dumper.WriteObject(null, o);
 }
Beispiel #9
0
        public string GetEntityInformation()
        {
            var dump = ObjectDumper.Dump(this);

            return(dump);
        }
Beispiel #10
0
    private void ProcessEvent(MSGEvent e)
    {
        AnswerMessage ans = e.RecvMessage;

        switch (ans.Type)
        {
        case AnswerMessage.AnsType.Connect:
            status = Status.Login;
            Log("Login Succeed");
            Log("Connect ans =>" + ObjectDumper.Dump(ans.Connect));
            break;

        case AnswerMessage.AnsType.Info:
            Log("Game Info Received");
            Log("Info => " + BitConverter.ToString(ans.Info.GameInfo));
            break;

        case AnswerMessage.AnsType.Channel:
            Log("Channel Info Received");
            Log("Channel Info => \n" + ObjectDumper.Dump(ans.Channel.ChannelInfo));
            break;

        case AnswerMessage.AnsType.AutoJoin:
            status = Status.InRoom;
            Log("Auto Join Ans");
            Log("Ans => " + BitConverter.ToString(ans.AutoJoin.GameRoomInfo));
            ProcessAutoJoin(ans.AutoJoin.GameRoomInfo);
            break;

        case AnswerMessage.AnsType.LeaveGame:
            status = Status.Login;
            Log("Leave Game");
            Log("Ans => " + ObjectDumper.Dump(ans.LeaveGame));
            break;

        case AnswerMessage.AnsType.Close:
            Log("Ans Close");
            break;

        case AnswerMessage.AnsType.Notice:
            Log("Notice Received");
            Log("Notices =>" + ObjectDumper.Dump(ans.Notice.Notices));
            break;

        case AnswerMessage.AnsType.DB:
            Log("Ans DB Received");
            Log("Ans DB =>" + ObjectDumper.Dump(ans.DB));
            break;

        case AnswerMessage.AnsType.GameProtocol:
            status = Status.InGame;
            Log("Game Message");
            Log("Message => " + BitConverter.ToString(ans.GameProtocol.Buffer));
            ProcessGameProtocol(ans.GameProtocol.Buffer);

            break;

        case AnswerMessage.AnsType.Error:
            Log("Error");
            Log("Error Msg =>" + ObjectDumper.Dump(ans.Error));
            break;

        default:
            Log("Ans =>" + ObjectDumper.Dump(ans));
            break;
        }
    }
Beispiel #11
0
	public static void WriteTo(object o, Stream stream, int depth = 0)
	{
		ObjectDumper dumper = new ObjectDumper(depth, new StreamWriter(stream));
		dumper.WriteObject(null, o);
	}
Beispiel #12
0
 public void A()
 {
     var dic = new Dictionary<string, string> { { "Key 1", "Value 1" }, { "Key 2", "Value 2" } };
     var x = new ObjectDumper().Dump(typeof(Object));
 }
Beispiel #13
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.Out.Write("error: no argument");
                return;
            }
            IGCCore core = new IGCCore();

            core.Load(args[0]);

            //TODO: fancy print GAs attributes and other array values

            ObjectDumper.Write("Globals-", core.Constants);

            foreach (DataCivilizationIGC civ in core.m_civilizations)
            {
                string civid = "Factions-" + civ.name + "(" + civ.civilizationID + ")-";
                ObjectDumper.Write(civid, civ);
            }
            foreach (DataDevelopmentIGC dev in core.m_developments)
            {
                string devid = "Devels-" + dev.name + "(" + dev.developmentID + ")-";
                ObjectDumper.Write(devid, dev);
            }
            foreach (DataDroneTypeIGC d in core.m_droneTypes)
            {
                string did = "Drones-" + d.name + " (" + d.droneTypeID + ")-";
                ObjectDumper.Write(did, d);
            }
            foreach (DataProjectileTypeIGC p in core.m_projectileTypes)
            {
                string pid = "Projectiles-p#" + p.projectileTypeID + "-";
                ObjectDumper.Write(pid, p);
            }
            foreach (DataStationTypeIGC s in core.m_stationTypes)
            {
                string sid = "Stations-" + s.name + "(" + s.stationTypeID + ")-";
                ObjectDumper.Write(sid, s);
            }
            foreach (DataHullTypeIGC h in core.m_hullTypes)
            {
                string hid = "Ships-" + h.name + "(" + h.hullID + ")-";
                ObjectDumper.Write(hid, h);
            }
            foreach (DataPartTypeIGC p in core.m_partTypes)
            {
                string pid = "Parts-" + p.name + "(" + p.partID + ")-";
                ObjectDumper.Write(pid, p);
            }
            foreach (DataChaffTypeIGC m in core.m_chaffTypes)
            {
                string mid = "Chaffs-" + m.launcherDef.name + "(" + m.expendabletypeID + ")-";
                ObjectDumper.Write(mid, m);
            }
            foreach (DataMineTypeIGC m in core.m_mineTypes)
            {
                string mid = "Mines-" + m.launcherDef.name + "(" + m.expendabletypeID + ")-";
                ObjectDumper.Write(mid, m);
            }
            foreach (DataMissileTypeIGC m in core.m_missileTypes)
            {
                string mid = "Missiles-" + m.launcherDef.name + "(" + m.expendabletypeID + ")-";
                ObjectDumper.Write(mid, m);
            }
            foreach (DataProbeTypeIGC m in core.m_probeTypes)
            {
                string mid = "Probes-" + m.launcherDef.name + "(" + m.expendabletypeID + ")-";
                ObjectDumper.Write(mid, m);
            }
            foreach (DataLauncherTypeIGC l in core.m_launcherTypes)
            {
                string lid = "Launchers-" + l.partID + "-" + l.expendabletypeID + "-";
                ObjectDumper.Write(lid, l);
            }
            foreach (DataTreasureSetIGC t in core.m_treasureSets)
            {
                string tid = "Treasures-" + t.name + "(" + t.treasureSetID + ")-";
                ObjectDumper.Write(tid, t);
            }
        }
 public static string GetObjectValue(object o)
 {
     ObjectDumper dumper = new ObjectDumper(1, false);
     dumper.WriteObject(null, o);
     return dumper.sb.ToString();
 }
Beispiel #15
0
 public static string Dump(object element, int depth = 4, int indentSize = 2, char indentChar = ' ')
 {
     var instance = new ObjectDumper(depth, indentSize, indentChar);
     return instance.DumpElement(element, true);
 }
Beispiel #16
0
    public static void Main()
    {
        Data1 d = new Data1();

        ObjectDumper.Write(d);
    }
Beispiel #17
0
 internal static void Write(object o, int depth, TextWriter log)
 {
     ObjectDumper dumper = new ObjectDumper(depth);
     dumper.writer = log;
     dumper.WriteObject(null, o);
 }
Beispiel #18
0
 private void Dump(object p)
 {
     ObjectDumper.Write(p, treeView1, textBox1);
 }
Beispiel #19
0
 private string OutputDebugForFailedDestination(ISamplingUtilities samplingUtilities, int nullDestinationCounter) {
     string errorMessage = "Thread-" + Thread.CurrentThread.Name + " GetDestination<TourSampleItem> returned null " + nullDestinationCounter + ""
         + " times. DestinationSampler object: " + ObjectDumper.Dump(this, /* depth */ 2, /* maxEnumeratedItems */ 3) + "\n\nsamplingUtilities: " + ObjectDumper.Dump(samplingUtilities, /* depth */ 2, /* maxEnumeratedItems */ 3);
     Global.PrintFile.WriteLine(errorMessage, /* writeToConsole */ true);
     return errorMessage;
 }
Beispiel #20
0
            public static void Write(StringBuilder sb, object o, int depth)
            {
                ObjectDumper dumper = new ObjectDumper(sb, depth);

                dumper.WriteObject(sb, null, o);
            }
Beispiel #21
0
 public string DumpInformation()
 {
     return(ObjectDumper.Write(_operator));
 }
Beispiel #22
0
        private void GetAccessToken(HttpContext context)
        {
            GetAccessTokenRequest gat = new GetAccessTokenRequest();

            String token    = context.Request.Params["txtrequest_token"];
            String verifier = context.Request.Params["txtverification_code"];

            gat.token    = token;
            gat.verifier = verifier;

            gat.requestEnvelope = new RequestEnvelope("en_US");
            GetAccessTokenResponse gats = null;

            try
            {
                PermissionsService service = new PermissionsService();
                gats = service.GetAccessToken(gat);
                context.Response.Write("<html><body><textarea rows=30 cols=80>");
                ObjectDumper.Write(gats, 5, context.Response.Output);
                context.Response.Write("</textarea></br>");

                //Selenium Test Case
                context.Response.Write("</br>Acknowledgement: ");
                context.Response.Write("<div id = '");
                context.Response.Write("Acknowledgement");
                context.Response.Write("'>");
                context.Response.Write(gats.responseEnvelope.ack);
                context.Response.Write("</div>");

                context.Response.Write("</br>Request token: ");
                context.Response.Write("<div id = '");
                context.Response.Write("Request token");
                context.Response.Write("'>");
                context.Response.Write(context.Request.Params["txtrequest_token"]);
                context.Response.Write("</div>");

                context.Response.Write("</br>Verification code: ");
                context.Response.Write("<div id = '");
                context.Response.Write("Verification code");
                context.Response.Write("'>");
                context.Response.Write(context.Request.Params["txtverification_code"]);
                context.Response.Write("</div>");

                context.Response.Write("</br>token: ");
                context.Response.Write("<div id = '");
                context.Response.Write("token");
                context.Response.Write("'>");
                context.Response.Write(gats.token);
                context.Response.Write("</div>");

                context.Response.Write("</br>tokenSecret: ");
                context.Response.Write("<div id = '");
                context.Response.Write("tokenSecret");
                context.Response.Write("'>");
                context.Response.Write(gats.tokenSecret);
                context.Response.Write("</div>");
            }
            catch (System.Exception e)
            {
                context.Response.Write(e.Message);
            }
        }
        public void DumpShapeAndChild_DepthSix() {
            var objectDumper = new ObjectDumper(6);
            var testShape = new TestShape
            {
                Metadata = new ShapeMetadata
                {
                    Type = "TestContentType",
                    DisplayType = "Detail",
                    Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
                    Position = "1",
                    ChildContent = new HtmlString("<p>Test Para</p>"),
                    Wrappers = new[] { "TestContentType_Wrapper" }
                },
                SomeInteger = 1337,
                SomeBoolean = true,
                SomeString = "Never gonna give you up"
            };

            testShape.Classes.Add("bodyClass1");
            testShape.Classes.Add("bodyClass2");

            testShape.Add(new TestShape
            {
                Metadata = new ShapeMetadata
                {
                    Type = "TestContentChildType",
                    DisplayType = "Detail",
                    Alternates = new[] { "TestContentChildType_Detail", "TestContentChildType_Detail_2" },
                    Position = "1",
                    ChildContent = new HtmlString("<p>Test Child Para</p>"),
                    Wrappers = new[] { "TestContentChildType_Wrapper" }
                },
                SomeInteger = 1337,
                SomeBoolean = true,
                SomeString = "Never gonna give you up"
            });

            testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));

            var xElement = objectDumper.Dump(testShape, "Model");

            var stringBuilder = new StringBuilder();
            ObjectDumper.ConvertToJSon(xElement, stringBuilder);
            var json = stringBuilder.ToString();

            var jObject = new JObject(
                new JProperty("name", "Model"),
                new JProperty("value", "TestContentType Shape"),
                new JProperty("children", new JArray(
                    new JObject(
                        new JProperty("name", "Classes"),
                        new JProperty("value", "List&lt;String&gt;"),
                        new JProperty("children", new JArray(
                            new JObject(
                                new JProperty("name", "[0]"),
                                new JProperty("value", "&quot;bodyClass1&quot;")),
                            new JObject(
                                new JProperty("name", "[1]"),
                                new JProperty("value", "&quot;bodyClass2&quot;"))))),
                    new JObject(
                        new JProperty("name", "Attributes"),
                        new JProperty("value", "Dictionary&lt;String, String&gt;"),
                        new JProperty("children", new JArray(
                            new JObject(
                                new JProperty("name", "[&quot;onClick&quot;]"),
                                new JProperty("value", "&quot;dhtmlIsBad&quot;"))))),
                    new JObject(
                        new JProperty("name", "Items"),
                        new JProperty("value", "List&lt;Object&gt;"),
                        new JProperty("children", new JArray(
                            new JObject(
                                new JProperty("name", "[0]"),
                                new JProperty("value", "TestContentChildType Shape"),
                                new JProperty("children", new JArray(
                                    new JObject(
                                        new JProperty("name", "Classes"),
                                        new JProperty("value", "List&lt;String&gt;")),
                                    new JObject(
                                        new JProperty("name", "Attributes"),
                                        new JProperty("value", "Dictionary&lt;String, String&gt;")),
                                    new JObject(
                                        new JProperty("name", "Items"),
                                        new JProperty("value", "List&lt;Object&gt;")))))))))));

            ComparareJsonObject(jObject, json);
        }
        public void DumpDictionary_DepthTwo() {
            var dictionary = new Dictionary<string, int> { { "One", 1 }, { "Two", 2 }, { "Three", 3 } };

            var objectDumper = new ObjectDumper(2);
            var xElement = objectDumper.Dump(dictionary, "Model");

            var stringBuilder = new StringBuilder();
            ObjectDumper.ConvertToJSon(xElement, stringBuilder);
            var json = stringBuilder.ToString();

            var jObject = new JObject(
                new JProperty("name", "Model"),
                new JProperty("value", "Dictionary&lt;String, Int32&gt;"),
                new JProperty("children", new JArray(
                    new JObject(
                        new JProperty("name", "[&quot;One&quot;]"),
                        new JProperty("value", "1")),
                    new JObject(
                        new JProperty("name", "[&quot;Two&quot;]"),
                        new JProperty("value", "2")),
                    new JObject(
                        new JProperty("name", "[&quot;Three&quot;]"),
                        new JProperty("value", "3"))
                    )));

            ComparareJsonObject(jObject, json);
        }
Beispiel #25
0
 public static void Write(object o, int depth, TextWriter outputStream = null)
 {
     ObjectDumper dumper = new ObjectDumper(depth, outputStream);
     dumper.WriteObject(null, o);
 }
        public void DumpContentItem_DepthSix() {
            var contentItem = new ContentItem { ContentType = "TestContentType" };
            var testingPart = new ContentPart { TypePartDefinition = new ContentTypePartDefinition(new ContentPartDefinition("TestingPart"), new SettingsDictionary()) };
            contentItem.Weld(testingPart);

            var objectDumper = new ObjectDumper(6);
            var xElement = objectDumper.Dump(contentItem, "Model");

            var stringBuilder = new StringBuilder();
            ObjectDumper.ConvertToJSon(xElement, stringBuilder);
            var json = stringBuilder.ToString();

            var jObject = new JObject(
                new JProperty("name", "Model"),
                new JProperty("value", "ContentItem"),
                new JProperty("children", new JArray(
                    new JObject(
                        new JProperty("name", "Id"),
                        new JProperty("value", "0")),
                    new JObject(
                        new JProperty("name", "Version"),
                        new JProperty("value", "0")),
                    new JObject(
                        new JProperty("name", "ContentType"),
                        new JProperty("value", "&quot;TestContentType&quot;")),
                    new JObject(
                        new JProperty("name", "TestingPart"),
                        new JProperty("value", "ContentPart"),
                        new JProperty("children", new JArray(
                            new JObject(
                                new JProperty("name", "Id"),
                                new JProperty("value", "0")),
                            new JObject(
                                new JProperty("name", "TypeDefinition"),
                                new JProperty("value", "null")),
                            new JObject(
                                new JProperty("name", "TypePartDefinition"),
                                new JProperty("value", "ContentTypePartDefinition"),
                                new JProperty("children", new JArray(
                                    new JObject(
                                        new JProperty("name", "PartDefinition"),
                                        new JProperty("value", "ContentPartDefinition"),
                                        new JProperty("children", new JArray(
                                                new JObject(
                                                    new JProperty("name", "Name"),
                                                    new JProperty("value", "&quot;TestingPart&quot;")),
                                                new JObject(
                                                    new JProperty("name", "Fields"),
                                                    new JProperty("value", "ContentPartFieldDefinition[]")),
                                                new JObject(
                                                    new JProperty("name", "Settings"),
                                                    new JProperty("value", "SettingsDictionary"))))),
                                    new JObject(
                                        new JProperty("name", "Settings"),
                                        new JProperty("value", "SettingsDictionary")),
                                    new JObject(
                                        new JProperty("name", "ContentTypeDefinition"),
                                        new JProperty("value", "null"))))),
                            new JObject(
                                new JProperty("name", "PartDefinition"),
                                new JProperty("value", "ContentPartDefinition"),
                                new JProperty("children", new JArray(
                                    new JObject(
                                        new JProperty("name", "Name"),
                                        new JProperty("value", "&quot;TestingPart&quot;")),
                                    new JObject(
                                        new JProperty("name", "Fields"),
                                        new JProperty("value", "ContentPartFieldDefinition[]")),
                                    new JObject(
                                        new JProperty("name", "Settings"),
                                        new JProperty("value", "SettingsDictionary"))))),
                            new JObject(
                                new JProperty("name", "Settings"),
                                new JProperty("value", "SettingsDictionary")),
                            new JObject(
                                new JProperty("name", "Fields"),
                                new JProperty("value", "List&lt;ContentField&gt;"))))))));

            ComparareJsonObject(jObject, json);
        }
Beispiel #27
0
        public void OnDisplaying(ShapeDisplayingContext context) {
            if (!IsActivable()) {
                return;
            }

            var shape = context.Shape;
            var shapeMetadata = (ShapeMetadata) context.Shape.Metadata;
            var currentTheme = _themeManager.GetRequestTheme(_workContext.HttpContext.Request.RequestContext);
            var shapeTable = _shapeTableManager.GetShapeTable(currentTheme.Id);

            if (!shapeMetadata.Wrappers.Contains("ShapeTracingWrapper")) {
                return;
            }

            var descriptor = shapeTable.Descriptors[shapeMetadata.Type];

            // dump the Shape's content
            var dump = new ObjectDumper(6).Dump(context.Shape, "Model");

            var sb = new StringBuilder();
            ObjectDumper.ConvertToJSon(dump, sb);
            shape._Dump = sb.ToString();

            shape.Template = null;
            shape.OriginalTemplate = descriptor.BindingSource;

            foreach (var extension in new[] { ".cshtml", ".aspx" }) {
                foreach (var alternate in shapeMetadata.Alternates.Reverse().Concat(new [] {shapeMetadata.Type}) ) {
                    var alternateFilename = FormatShapeFilename(alternate, shapeMetadata.Type, shapeMetadata.DisplayType, currentTheme.Location + "/" + currentTheme.Id, extension);
                    if (_webSiteFolder.FileExists(alternateFilename)) {
                        shape.Template = alternateFilename;
                    }
                }
            }

            if(shape.Template == null) {
                shape.Template = descriptor.BindingSource;
            }

            if(shape.Template == null) {
                shape.Template = descriptor.Bindings.Values.FirstOrDefault().BindingSource;
            }

            if (shape.OriginalTemplate == null) {
                shape.OriginalTemplate = descriptor.Bindings.Values.FirstOrDefault().BindingSource;
            }

            try {
                // we know that templates are classes if they contain ':'
                if (!shape.Template.Contains(":") && _webSiteFolder.FileExists(shape.Template)) {
                    shape.TemplateContent = _webSiteFolder.ReadFile(shape.Template);
                }
            }
            catch {
                // the url might be invalid in case of a code shape
            }

            if (shapeMetadata.PlacementSource != null && _webSiteFolder.FileExists(shapeMetadata.PlacementSource)) {
                context.Shape.PlacementContent = _webSiteFolder.ReadFile(shapeMetadata.PlacementSource);
            }

            // Inject the Zone name
            if(shapeMetadata.Type == "Zone") {
                shape.Hint = ((Zone) shape).ZoneName;
            }

            shape.ShapeId = _shapeId++;
        }
        public void DumpObject_DepthOne() {
            var objectDumper = new ObjectDumper(1);
            var xElement = objectDumper.Dump(new TestObject
            {
                SomeInteger = 1337,
                SomeBoolean = true,
                SomeString = "Never gonna give you up"
            }, "Model");

            Assert.Throws(typeof (NullReferenceException), () => {
                var stringBuilder = new StringBuilder();
                ObjectDumper.ConvertToJSon(xElement, stringBuilder);
                var json = stringBuilder.ToString();
            });
        }
Beispiel #29
0
 public static void Write(object o, int depth, TextWriter log)
 {
     var dumper = new ObjectDumper(depth) {_writer = log};
     dumper.WriteObject(null, o);
 }
Beispiel #30
0
        public void Linq010()
        {
            Dictionary <int, string> Calendar = new Dictionary <int, string>
            {
                { 1, "January" },
                { 2, "Feburary" },
                { 3, "March" },
                { 4, "April" },
                { 5, "May" },
                { 6, "June" },
                { 7, "July" },
                { 8, "August" },
                { 9, "September" },
                { 10, "October" },
                { 11, "November" },
                { 12, "December" }
            };


            var monthActivity =
                from cust in dataSource.Customers
                from order in cust.Orders
                orderby order.OrderDate.Month
                group order by order.OrderDate.Month into monthAverage
                select new
            {
                monthAverage.Key,
                averageActivity = monthAverage.Count() / monthAverage.Select(item => item.OrderDate.Year).Distinct().Count()
            };
            var yearActivity =
                from cust in dataSource.Customers
                from order in cust.Orders
                orderby order.OrderDate.Year
                group order by order.OrderDate.Year into YearAverage
                select new
            {
                YearAverage.Key,
                averageActivity = YearAverage.Count()
            };
            var yearAndMonthActivity =
                from cust in dataSource.Customers
                from orders in cust.Orders
                group orders by new { Year = orders.OrderDate.Year, Month = orders.OrderDate.Month } into yearAndMonthGroupped
            orderby yearAndMonthGroupped.Key.Year, yearAndMonthGroupped.Key.Month
                select new
            {
                Year  = yearAndMonthGroupped.Key.Year,
                Month = yearAndMonthGroupped.Key.Month,
                Total = yearAndMonthGroupped.Count()
            };


            ///* Сделайте среднегодовую статистику активности клиентов по месяцам (без учета года)
            ObjectDumper.Write("Average annual statistical customer activity by months (excluding year)");
            ObjectDumper.Write(" ");
            foreach (var prod in monthActivity)
            {
                ObjectDumper.Write($"{Calendar[prod.Key]}  {prod.averageActivity}");
                ObjectDumper.Write(" ");
            }

            ObjectDumper.Write("---------------------------------------------------------------------------------------- ");
            //... статистику по годам,

            ObjectDumper.Write("Average annual statistical customer activity by years");
            ObjectDumper.Write(" ");
            foreach (var prod in yearActivity)
            {
                ObjectDumper.Write($"Year {prod.Key}  {prod.averageActivity}");
                ObjectDumper.Write(" ");
            }
            ObjectDumper.Write("---------------------------------------------------------------------------------------- ");
            //...по годам и месяцам (т.е. когда один месяц в разные годы имеет своё значение).
            ObjectDumper.Write("Average annual statistical customer activity by months and years");
            foreach (var month in yearAndMonthActivity)
            {
                ObjectDumper.Write($"{ month.Year}  {null,15}{Calendar[month.Month]}  { month.Total}");
                ObjectDumper.Write(" ");
            }
        }
Beispiel #31
0
 public void FullDump()
 {
     ObjectDumper dumper = new ObjectDumper(4, true, true, (System.Reflection.BindingFlags.FlattenHierarchy));
     logger.Error("Dump of the spellbook of {0} : ", Character.Name);
     foreach (var spell in m_spells)
     {
         logger.Error("   Spell {0}", spell.ToString(true));
         foreach (var effectdice in spell.LevelTemplate.effects)
         {
             EffectBase effect = new EffectBase(effectdice);
             logger.Error("       Effect {0} : {1} - {2} {3:P}", effect.Description, effectdice.diceNum <= effectdice.diceSide ? effectdice.diceNum : effectdice.diceSide, effectdice.diceNum > effectdice.diceSide ? effectdice.diceNum : effectdice.diceSide, effectdice.random == 0 ? 1.0 : effectdice.random / 100.0);
         }
     }
 }
Beispiel #32
0
	public static void Write(object o, int depth = 0)
	{
		ObjectDumper dumper = new ObjectDumper(depth, Console.Out);
		dumper.WriteObject(null, o);
	}
        public void DumpObjectAndChild_DepthThree() {
            var objectDumper = new ObjectDumper(3);
            var xElement = objectDumper.Dump(new TestObject
            {
                SomeInteger = 1337,
                SomeBoolean = true,
                SomeString = "Never gonna give you up",
                ChildObject = new TestObject() {
                    SomeInteger = 58008,
                    SomeBoolean = false,
                    SomeString = "Never gonna let you down",                    
                }
            }, "Model");

            var stringBuilder = new StringBuilder();
            ObjectDumper.ConvertToJSon(xElement, stringBuilder);
            var json = stringBuilder.ToString();

            var jObject = new JObject(
                new JProperty("name", "Model"),
                new JProperty("value", "TestObject"),
                new JProperty("children", new JArray(
                    new JObject(
                        new JProperty("name", "SomeInteger"),
                        new JProperty("value", "1337")),
                    new JObject(
                        new JProperty("name", "SomeBoolean"),
                        new JProperty("value", "True")),
                    new JObject(
                        new JProperty("name", "SomeString"),
                        new JProperty("value", "&quot;Never gonna give you up&quot;")),
                    new JObject(
                        new JProperty("name", "ChildObject"),
                        new JProperty("value", "TestObject"),
                        new JProperty("children", new JArray(
                            new JObject(
                                new JProperty("name", "SomeInteger"),
                                new JProperty("value", "58008")),
                            new JObject(
                                new JProperty("name", "SomeBoolean"),
                                new JProperty("value", "False")),
                            new JObject(
                                new JProperty("name", "SomeString"),
                                new JProperty("value", "&quot;Never gonna let you down&quot;")),
                            new JObject(
                                new JProperty("name", "ChildObject"),
                                new JProperty("value", "null")
                            )
                        ))
                    )
                )));

            ComparareJsonObject(jObject, json);
        }
Beispiel #34
0
    public static void Write(object o, int depth)
    {
        ObjectDumper dumper = new ObjectDumper(depth);

        dumper.WriteObject(null, o);
    }
Beispiel #35
0
 public static List<string> Dump(object element, int indentSize)
 {
     var instance = new ObjectDumper(indentSize);
     return instance.DumpElement(element);
 }
        public void DumpIShape_DepthOne() {
            var objectDumper = new ObjectDumper(1);
            var xElement = objectDumper.Dump(new TestIShape {
                Metadata = new ShapeMetadata() {
                    Type = "TestContentType",
                    DisplayType = "Detail",
                    Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
                    Position = "1",
                    ChildContent = new HtmlString("<p>Test Para</p>"),
                    Wrappers = new[] { "TestContentType_Wrapper" }
                },
                SomeInteger = 1337,
                SomeBoolean = true,
                SomeString = "Never gonna give you up"
            }, "Model");

            Assert.Throws(typeof(NullReferenceException), () => {
                var stringBuilder = new StringBuilder();
                ObjectDumper.ConvertToJSon(xElement, stringBuilder);
                var json = stringBuilder.ToString();
            });
        }
        public void DumpIShape_DepthFour() {
            var objectDumper = new ObjectDumper(4);
            var xElement = objectDumper.Dump(new TestIShape {
                Metadata = new ShapeMetadata() {
                    Type = "TestContentType",
                    DisplayType = "Detail",
                    Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
                    Position = "1",
                    ChildContent = new HtmlString("<p>Test Para</p>"),
                    Wrappers = new[] { "TestContentType_Wrapper" }
                },
                SomeInteger = 1337,
                SomeBoolean = true,
                SomeString = "Never gonna give you up"
            }, "Model");

            var stringBuilder = new StringBuilder();
            ObjectDumper.ConvertToJSon(xElement, stringBuilder);
            var json = stringBuilder.ToString();

            var jObject = new JObject(
                new JProperty("name", "Model"),
                new JProperty("value", "TestContentType Shape"));
           
            ComparareJsonObject(jObject, json);
        }
        public void DumpShape_DepthOne() {
            var objectDumper = new ObjectDumper(1);
            var testShape = new TestShape
            {
                Metadata = new ShapeMetadata()
                {
                    Type = "TestContentType",
                    DisplayType = "Detail",
                    Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
                    Position = "1",
                    ChildContent = new HtmlString("<p>Test Para</p>"),
                    Wrappers = new[] { "TestContentType_Wrapper" }
                },
                SomeInteger = 1337,
                SomeBoolean = true,
                SomeString = "Never gonna give you up"
            };

            testShape.Classes.Add("bodyClass1");
            testShape.Classes.Add("bodyClass2");

            testShape.Add("Child Item");

            testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));

            var xElement = objectDumper.Dump(testShape, "Model");

            Assert.Throws(typeof(NullReferenceException), () =>
            {
                var stringBuilder = new StringBuilder();
                ObjectDumper.ConvertToJSon(xElement, stringBuilder);
                var json = stringBuilder.ToString();
            });
        }
 public static void Write(object element, int depth, TextWriter log)
 {
     ObjectDumper dumper = new ObjectDumper(depth);
     dumper.writer = log;
     dumper.WriteObject(null, element);
 }
        public void DumpShape_DepthTwo() {
            var objectDumper = new ObjectDumper(2);
            var testShape = new TestShape
            {
                Metadata = new ShapeMetadata()
                {
                    Type = "TestContentType",
                    DisplayType = "Detail",
                    Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" },
                    Position = "1",
                    ChildContent = new HtmlString("<p>Test Para</p>"),
                    Wrappers = new[] { "TestContentType_Wrapper" }
                },
                SomeInteger = 1337,
                SomeBoolean = true,
                SomeString = "Never gonna give you up"
            };

            testShape.Classes.Add("bodyClass1");
            testShape.Classes.Add("bodyClass2");

            testShape.Add("Child Item");

            testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad"));

            var xElement = objectDumper.Dump(testShape, "Model");

            var stringBuilder = new StringBuilder();
            ObjectDumper.ConvertToJSon(xElement, stringBuilder);
            var json = stringBuilder.ToString();

            var jObject = new JObject(
                new JProperty("name", "Model"),
                new JProperty("value", "TestContentType Shape"));

            ComparareJsonObject(jObject, json);
        }
Beispiel #41
0
 public static void Write(object o, TextWriter writer, int depth)
 {
     ObjectDumper dumper = new ObjectDumper(writer, depth);
     dumper.WriteObject(null, o);
 }
 void IDumpabled.Dump(string name, ObjectDumper dumper)
 {
     dumper.DumpText(name, "{{ {0} }}", ToString());
 }