当前位置: 首页>>代码示例>>C#>>正文


C# SerializationContext.GetService方法代码示例

本文整理汇总了C#中SerializationContext.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# SerializationContext.GetService方法的具体用法?C# SerializationContext.GetService怎么用?C# SerializationContext.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SerializationContext的用法示例。


在下文中一共展示了SerializationContext.GetService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LineColumns2

        public void LineColumns2()
        {
            SerializationContext ctx = new SerializationContext();

            ISerializationSettings settings = ctx.GetService(typeof(ISerializationSettings)) as ISerializationSettings;
            settings.EnsureAccurateLineNumbers = true;

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.SerializationContext = ctx;
            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/Calendar1.ics", Encoding.UTF8, serializer)[0];

            Assert.IsNotNull(iCal.Todos["2df60496-1e73-11db-ba96-e3cfe6793b5f"]);
            Assert.IsNotNull(iCal.Todos["4836c236-1e75-11db-835f-a024e2a6131f"]);
            Assert.AreEqual(110, iCal.Todos["4836c236-1e75-11db-835f-a024e2a6131f"].Properties["LOCATION"].Line);
            Assert.AreEqual(123, iCal.Todos["2df60496-1e73-11db-ba96-e3cfe6793b5f"].Properties["UID"].Line);
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:16,代码来源:SerializationTest.cs

示例2: LineColumns1

        public void LineColumns1()
        {
            SerializationContext ctx = new SerializationContext();

            ISerializationSettings settings = ctx.GetService(typeof(ISerializationSettings)) as ISerializationSettings;
            settings.EnsureAccurateLineNumbers = true;

            iCalendarSerializer serializer = new iCalendarSerializer();
            serializer.SerializationContext = ctx;
            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars/Serialization/EmptyLines1.ics", Encoding.UTF8, serializer)[0];

            Assert.AreEqual(2, iCal.Events.Count);
            Assert.AreEqual(4, iCal.Events.First().Line);
            Assert.AreEqual(18, iCal.Events[1].Line);
            Assert.AreEqual(5, iCal.Events.First().Properties["CREATED"].Line);
            Assert.AreEqual(6, iCal.Events.First().Properties["LAST-MODIFIED"].Line);
            Assert.AreEqual(7, iCal.Events.First().Properties["DTSTAMP"].Line);
            Assert.AreEqual(8, iCal.Events.First().Properties["UID"].Line);
            Assert.AreEqual(9, iCal.Events.First().Properties["SUMMARY"].Line);
            Assert.AreEqual(10, iCal.Events.First().Properties["CLASS"].Line);
            Assert.AreEqual(11, iCal.Events.First().Properties["DTSTART"].Line);
            Assert.AreEqual(12, iCal.Events.First().Properties["DTEND"].Line);
            Assert.AreEqual(13, iCal.Events.First().Properties["CATEGORIES"].Line);
            Assert.AreEqual(14, iCal.Events.First().Properties["X-MOZILLA-ALARM-DEFAULT-LENGTH"].Line);
            Assert.AreEqual(15, iCal.Events.First().Properties["LOCATION"].Line);
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:26,代码来源:SerializationTest.cs


注:本文中的SerializationContext.GetService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。