當前位置: 首頁>>代碼示例>>C#>>正文


C# DataReader.ReadBoolean方法代碼示例

本文整理匯總了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;
            }
        }
開發者ID:forehalo,項目名稱:UWP-dev,代碼行數:27,代碼來源:_DataWriter.xaml.cs

示例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;
            }
        }
開發者ID:Powerino73,項目名稱:paradox,代碼行數:45,代碼來源:ImageTester.Runtime.cs

示例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;
        }
開發者ID:ebragge,項目名稱:SDE,代碼行數:24,代碼來源:MainPage.xaml.cs


注:本文中的Windows.Storage.Streams.DataReader.ReadBoolean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。