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


C# List.Dispose方法代码示例

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


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

示例1: LaunchWithFiles

		void LaunchWithFiles (GLib.File app, IEnumerable<GLib.File> files)
		{
			AppInfo appinfo = null;
			if (app != null) {
				appinfo = GLib.DesktopAppInfo.NewFromFilename (app.Path);
			} else {
				if (!files.Any ())
					return;

				// if we weren't given an app info, query the file for the default handler
				try {
					appinfo = files.First ().QueryDefaultHandler (null);
				} catch {
					// file probably doesnt exist
					return;
				}
			}
			
			try {
				GLib.List launchList;
				
				if (!files.Any ()) {
					appinfo.Launch (null, null);

				// check if the app supports files or Uris
				} else if (appinfo.SupportsFiles) {
					launchList = new GLib.List (new GLib.File[] {}, typeof (GLib.File), true, false);
					foreach (GLib.File f in files)
						launchList.Append (f);

					appinfo.Launch (launchList, null);
					launchList.Dispose ();
					
				} else if (appinfo.SupportsUris) {
					launchList = new GLib.List (new string[] {}, typeof (string), true, true);
					foreach (GLib.File f in files) {
						// try to use GLib.File.Uri first, if that throws an exception,
						// catch and use P/Invoke to libdocky.  If that's still null, warn & skip the file.
						try {
							launchList.Append (f.Uri.ToString ());
						} catch (UriFormatException) { 
							string uri = f.StringUri ();
							if (string.IsNullOrEmpty (uri)) {
								Log<SystemService>.Warn ("Failed to retrieve URI for {0}.  It will be skipped.", f.Path);
								continue;
							}
							launchList.Append (uri);
						}
					}
					appinfo.LaunchUris (launchList, null);
					launchList.Dispose ();
					
				} else {
					Log<SystemService>.Error ("Error opening files. The application doesn't support files/URIs or wasn't found.");	
				}
				
			} catch (GException e) {
				Log.Notify (string.Format ("Error running: {0}", appinfo.Name), Gtk.Stock.DialogWarning, e.Message);
				Log<SystemService>.Error (e.Message);
				Log<SystemService>.Info (e.StackTrace);
			}

			(appinfo as IDisposable).Dispose ();
		}
开发者ID:Aurora-and-Equinox,项目名称:docky,代码行数:64,代码来源:SystemService.cs


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