本文整理汇总了C#中Entry.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Entry.Initialize方法的具体用法?C# Entry.Initialize怎么用?C# Entry.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry.Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeNewEntry
public void SerializeNewEntry()
{
FileStream fileStream = null;
Entry entry = new Entry();
entry.Initialize();
entry.Title = "The Title";
entry.Content = "Content";
entry.EntryId = Guid.NewGuid().ToString();
DayEntry dayEntry = new DayEntry();
dayEntry.Initialize();
dayEntry.Entries.Add(entry);
try
{
fileStream = FileUtils.OpenForWrite(
Path.Combine(CONTENT_DIRECTORY_PATH, dayEntry.FileName));
if(fileStream == null)
{
Assert.Fail("Unable to create stream {0}",
Path.Combine(CONTENT_DIRECTORY_PATH, dayEntry.FileName));
}
else
{
XmlSerializer ser = new XmlSerializer(typeof(DayEntry), new Type[]{typeof(Entry)});
using (StreamWriter writer = new StreamWriter(fileStream))
{
ser.Serialize(writer, dayEntry);
}
using(StreamReader reader = new StreamReader(Path.Combine(CONTENT_DIRECTORY_PATH, dayEntry.FileName)))
{
Console.WriteLine(reader.ReadToEnd());
}
}
}
finally
{
if(fileStream != null)
{
fileStream.Close();
}
}
}
示例2: CreateEntry
private static Entry CreateEntry(string title, bool isPublic, DateTime publishData)
{
Entry entry = new Entry();
entry.Initialize();
entry.Title = title;
entry.IsPublic = isPublic;
entry.CreatedLocalTime = publishData;
return entry;
}