当前位置: 首页>>代码示例>>C#>>正文


C# StorageFile.OpenSequentialReadAsync方法代码示例

本文整理汇总了C#中Windows.Storage.StorageFile.OpenSequentialReadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# StorageFile.OpenSequentialReadAsync方法的具体用法?C# StorageFile.OpenSequentialReadAsync怎么用?C# StorageFile.OpenSequentialReadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Storage.StorageFile的用法示例。


在下文中一共展示了StorageFile.OpenSequentialReadAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeserializeLocalSessions

		public static async Task<List<Session>> DeserializeLocalSessions(StorageFile file) {
			using (var stream = await file.OpenSequentialReadAsync()) {
				using (var dr = new Windows.Storage.Streams.DataReader(stream)) {
					var numberOfSessions = dr.ReadInt32();
					List<Session> rv = new List<Session>(numberOfSessions);
					for (int x = 0; x < numberOfSessions; x++) {
						rv.Add(LoadSession(dr));
					}
					return rv;
				}
			}
		}
开发者ID:Programmerman1,项目名称:bandcurling,代码行数:12,代码来源:Session.cs

示例2: Restore

 public async Task<List<Avalon>> Restore(StorageFile file)
 {
     List<Avalon> Return = new List<Avalon>();
     List<SerializableAvalon> temp = new List<SerializableAvalon>();
     using (IInputStream Stream = await file.OpenSequentialReadAsync())
     {
         DataContractSerializer dcs = new DataContractSerializer(typeof(List<SerializableAvalon>));
         temp = (List<SerializableAvalon>)dcs.ReadObject(Stream.AsStreamForRead());
     }
     foreach (SerializableAvalon item in temp)
     {
         Avalon Pizza = Produce(item.Definition);
         Pizza.RestorState(item);
         Return.Add(Pizza);
     }
     return Return;
 }
开发者ID:MohammedAbuissa,项目名称:Avalon,代码行数:17,代码来源:AFactory.cs

示例3: DeserializeFromFileAsync

 public static async Task<Object> DeserializeFromFileAsync(Type objectType, StorageFile file, bool deleteFile = false)
 {
     if (file == null) return null;
     try
     {
         Object obj;
         AppEventSource.Log.Debug("Suspension: Checking file..." + file.Name);
         // Get the input stream for the file
         using (IInputStream inStream = await file.OpenSequentialReadAsync())
         {
             // Deserialize the Session State
             DataContractSerializer serializer = new DataContractSerializer(objectType);
             obj = serializer.ReadObject(inStream.AsStreamForRead());
         }
         AppEventSource.Log.Debug("Suspension: Object loaded from file. " + objectType.ToString());
         // Delete the file
         if (deleteFile)
         {
             await file.DeleteAsync();
             deleteFile = false;
             AppEventSource.Log.Info("Suspension: File deleted. " + file.Name);
         }
         return obj;
     }
     catch (Exception e)
     {
         AppEventSource.Log.Error("Suspension: Error when deserializing object. Exception: " + e.Message);
         MessageDialog messageDialog = new MessageDialog("Error when deserializing App settings: " + file.Name + "\n" 
             + "The PDF file is not affected.\n " + "Details: \n" + e.Message);
         messageDialog.Commands.Add(new UICommand("Reset Settings", null, 0));
         messageDialog.Commands.Add(new UICommand("Ignore", null, 1));
         IUICommand command = await messageDialog.ShowAsync();
         switch ((int)command.Id)
         {
             case 0:
                 // Delete file
                 deleteFile = true;
                 break;
             default:
                 deleteFile = false;
                 break;
         }
         return null;
     }
     finally
     {
         // Delete the file if error occured
         if (deleteFile)
         {
             await file.DeleteAsync();
             AppEventSource.Log.Info("Suspension: File deleted due to error. " + file.Name);
         }
     }
 }
开发者ID:qiuosier,项目名称:Libra,代码行数:54,代码来源:SuspensionManager.cs

示例4: PlayFile

	async Task PlayFile(StorageFile sf)
	{
		if (sf == null) {
			Exit();
			return;
		}
		byte[] module = new byte[ASAPInfo.MaxModuleLength];
		int moduleLen;
		using (IInputStream iis = await sf.OpenSequentialReadAsync()) {
			IBuffer buf = await iis.ReadAsync(module.AsBuffer(), (uint) ASAPInfo.MaxModuleLength, InputStreamOptions.None);
			moduleLen = (int) buf.Length;
		}

		ASAP asap = new ASAP();
		asap.Load(sf.Name, module, moduleLen);
		ASAPInfo info = asap.GetInfo();
		int song = info.GetDefaultSong();
		int duration = info.GetLoop(song) ? -1 : info.GetDuration(song);
		asap.PlaySong(song, duration);

		this.MyMedia = new MediaElement {
			AudioCategory = AudioCategory.BackgroundCapableMedia,
			Volume = 1,
			AutoPlay = true
		};
		Window.Current.Content = this.MyMedia;
		await Task.Yield();
		this.MyMedia.SetSource(new ASAPRandomAccessStream(asap, duration), "audio/x-wav");

		MediaControl.TrackName = info.GetTitleOrFilename();
		MediaControl.ArtistName = info.GetAuthor();
		MediaControl.PlayPressed += MediaControl_PlayPressed;
		MediaControl.PausePressed += MediaControl_PausePressed;
		MediaControl.PlayPauseTogglePressed += MediaControl_PlayPauseTogglePressed;
		MediaControl.StopPressed += MediaControl_StopPressed;
		MediaControl.IsPlaying = true;
	}
开发者ID:hudokkow,项目名称:audiodecoder.asap,代码行数:37,代码来源:MetroASAP.cs


注:本文中的Windows.Storage.StorageFile.OpenSequentialReadAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。