本文整理汇总了C#中Storage.OpenStream方法的典型用法代码示例。如果您正苦于以下问题:C# Storage.OpenStream方法的具体用法?C# Storage.OpenStream怎么用?C# Storage.OpenStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Storage
的用法示例。
在下文中一共展示了Storage.OpenStream方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadXml
private static object ReadXml(Storage postStorage, string streamName, XmlReadHandler readHandler)
{
XmlTextReader reader = new XmlTextReader(new StreamReader(postStorage.OpenStream(streamName, StorageMode.Open, false), utf8Encoding, false));
try
{
return readHandler(reader);
}
finally
{
reader.Close();
}
}
示例2: WriteDateTime
private static void WriteDateTime(Storage postStorage, string fieldName, DateTime fieldValue)
{
using (BinaryWriter writer = new BinaryWriter(postStorage.OpenStream(fieldName, StorageMode.Create, true)))
writer.Write(fieldValue.Ticks);
}
示例3: WriteXml
private static void WriteXml(Storage postStorage, string streamName, object data, XmlWriteHandler writeHandler)
{
XmlTextWriter writer = new XmlTextWriter(postStorage.OpenStream(streamName, StorageMode.Create, true), utf8Encoding);
try
{
writer.WriteStartDocument();
writeHandler(writer, data);
writer.WriteEndDocument();
}
finally
{
writer.Close();
}
}
示例4: ReadDateTime
private static DateTime ReadDateTime(Storage postStorage, string fieldName)
{
using (BinaryReader reader = new BinaryReader(postStorage.OpenStream(fieldName, StorageMode.Open, false)))
return new DateTime(reader.ReadInt64());
}
示例5: ReadStringUtf8
private static string ReadStringUtf8(Storage postStorage, string fieldName)
{
using (StreamReader reader = new StreamReader(postStorage.OpenStream(fieldName, StorageMode.Open, false), utf8Encoding))
return reader.ReadToEnd();
}
示例6: WriteStringUtf8
private static void WriteStringUtf8(Storage postStorage, string fieldName, string fieldValue)
{
using (StreamWriter writer = new StreamWriter(postStorage.OpenStream(fieldName, StorageMode.Create, true), utf8Encoding))
writer.Write(fieldValue);
}
示例7: WriteSpellingContextDictionary
private void WriteSpellingContextDictionary(Storage postStorage, BlogPostSupportingFileStorage supportingFileStorage)
{
Stream spellingStream = supportingFileStorage.ReadSpellingContextDictionary();
if (spellingStream != null)
{
using (spellingStream)
{
using (Stream stream = postStorage.OpenStream(SPELLING_CONTEXT_DICTIONARY, StorageMode.Create))
StreamHelper.Transfer(spellingStream, stream);
}
}
}
示例8: ReadSpellingContextDictionary
private void ReadSpellingContextDictionary(Storage postStorage, BlogPostSupportingFileStorage supportingFileStorage)
{
// try to get the dictionary stream
Stream dictionaryStream;
try { dictionaryStream = postStorage.OpenStream(SPELLING_CONTEXT_DICTIONARY, StorageMode.Open); }
catch (StorageException) { return; }
// write it to supporting file storage
using (dictionaryStream)
supportingFileStorage.WriteSpellingContextDictionary(dictionaryStream);
}