本文整理汇总了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);
}
示例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);
}