本文整理汇总了C#中Windows.Storage.Streams.DataReader.ReadBoolean方法的典型用法代码示例。如果您正苦于以下问题:C# DataReader.ReadBoolean方法的具体用法?C# DataReader.ReadBoolean怎么用?C# DataReader.ReadBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.Storage.Streams.DataReader
的用法示例。
在下文中一共展示了DataReader.ReadBoolean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRead
private async void OnRead(Object sender, RoutedEventArgs e)
{
StorageFolder local = ApplicationData.Current.LocalFolder;
StorageFile file = await local.GetFileAsync("demo.dat");
if(file != null)
{
string strres = "读到的内容:\n";
using(IRandomAccessStream stream = await file.OpenReadAsync())
{
DataReader dr = new DataReader(stream);
dr.UnicodeEncoding = UnicodeEncoding.Utf8;
await dr.LoadAsync((uint)stream.Size);
bool b = dr.ReadBoolean();
strres += b.ToString() + "\n";
DateTimeOffset dt = dr.ReadDateTime();
strres += dt.ToString("yyyy-M-d") + "\n";
uint len = dr.ReadUInt32();
if(len > 0)
{
strres += dr.ReadString(len);
}
dr.Dispose();
}
tbResult.Text = strres;
}
}
示例2: SendImageAsync
/// <summary>
/// Send the data of the test to the server.
/// </summary>
/// <param name="testResultImage">The image to send.</param>
public static async Task<bool> SendImageAsync(TestResultImage testResultImage)
{
if (!Connect())
throw new InvalidOperationException("Could not connect to image comparer server");
try
{
if (testResultImage.TestName == null && NUnit.Framework.TestContext.CurrentContext != null)
{
testResultImage.TestName = NUnit.Framework.TestContext.CurrentContext.Test.FullName;
}
// Send initial parameters
using (var memoryStream = new MemoryStream())
{
var binaryWriter = new BinaryWriter(memoryStream);
// Header
binaryWriter.Write((int)ImageServerMessageType.SendImage);
TestGameBase.TestGameLogger.Info(@"Sending image information...");
testResultImage.Write(binaryWriter);
var dataWriter = new DataWriter(imageComparisonServer.OutputStream);
dataWriter.WriteBytes(memoryStream.ToArray());
await dataWriter.StoreAsync();
await dataWriter.FlushAsync();
dataWriter.DetachStream();
}
var dataReader = new DataReader(imageComparisonServer.InputStream);
await dataReader.LoadAsync(1);
var result = dataReader.ReadBoolean();
dataReader.DetachStream();
return result;
}
catch (Exception)
{
throw;
}
}
示例3: ReadStatus
private async Task<bool> ReadStatus()
{
bool state = false;
try
{
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile file = await storageFolder.GetFileAsync("status.txt");
var stream = await file.OpenAsync(FileAccessMode.ReadWrite);
ulong size = stream.Size;
using (var inputStream = stream.GetInputStreamAt(0))
{
using (var dataReader = new DataReader(inputStream))
{
uint numBytesLoaded = await dataReader.LoadAsync((uint)size);
state = dataReader.ReadBoolean();
}
}
stream.Dispose();
}
catch (Exception) {}
return state;
}