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


C# SafeUri.GetExtension方法代码示例

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


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

示例1: TestFileUris

 public void TestFileUris()
 {
     foreach (var test in tests) {
         var suri = new SafeUri (test.Uri);
         Assert.AreEqual (suri.AbsoluteUri, test.AbsoluteUri, String.Format("AbsoluteUri for {0}", test.Uri));
         Assert.AreEqual (suri.GetExtension (), test.Extension, String.Format("Extension for {0}", test.Uri));
         Assert.AreEqual (suri.GetBaseUri ().ToString (), test.BaseUri, String.Format("BaseUri for {0}", test.Uri));
         Assert.AreEqual (suri.GetFilename (), test.Filename, String.Format("Filename for {0}", test.Uri));
         Assert.AreEqual (suri.GetFilenameWithoutExtension (), test.FilenameWithoutExtension, String.Format("FilenameWithoutExtension for {0}", test.Uri));
     }
 }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:11,代码来源:SafeUriTests.cs

示例2: IsRaw

		public static bool IsRaw (SafeUri uri)
		{
			string [] raw_extensions = {
				".arw",
				".crw",
				".cr2",
				".dng",
				".mrw",
				".nef",
				".orf",
				".pef",
				".raw",
				".raf",
				".rw2",
				".srw",
			};
			var extension = uri.GetExtension ().ToLower ();
			return raw_extensions.Any (x => x == extension);
		}
开发者ID:mono,项目名称:f-spot,代码行数:19,代码来源:ImageFile.cs

示例3: IsJpeg

		public static bool IsJpeg (SafeUri uri)
		{
			string [] jpg_extensions = {".jpg", ".jpeg", ".jpe", ".jfi", ".jfif", ".jif"};
			var extension = uri.GetExtension ().ToLower ();
			return jpg_extensions.Any (x => x == extension);
		}
开发者ID:mono,项目名称:f-spot,代码行数:6,代码来源:ImageFile.cs

示例4: GetLoaderType

		static Type GetLoaderType (SafeUri uri)
		{
			// check if GIO can find the file, which is not the case
			// with filenames with invalid encoding
			var file = GLib.FileFactory.NewForUri (uri);
			if (!file.Exists)
             		   return null;

			string extension = uri.GetExtension ().ToLower ();

			// Ignore video thumbnails
			if (extension == ".thm")
		                return null;

			// Detect mime-type
			var info = file.QueryInfo ("standard::content-type,standard::size", FileQueryInfoFlags.None, null);
			string mime = info.ContentType;
			long size = info.Size;

			// Empty file
			if (size == 0)
		                return null;

			Type t = null;

			if (NameTable.TryGetValue (mime, out t))
				return t;

			if (NameTable.TryGetValue (extension, out t))
				return t;

			return null;
		}
开发者ID:mono,项目名称:f-spot,代码行数:33,代码来源:ImageFile.cs

示例5: GetUniqueFilename

		SafeUri GetUniqueFilename (SafeUri dest)
		{
			// Find an unused name
			int i = 1;
			var base_uri = dest.GetBaseUri ();
			var filename = dest.GetFilenameWithoutExtension ();
			var extension = dest.GetExtension ();
			while (file_system.File.Exists (dest)) {
				dest = base_uri.Append (String.Format ("{0}-{1}{2}", filename, i++, extension));
			}

			return dest;
		}
开发者ID:cizma,项目名称:f-spot,代码行数:13,代码来源:PhotoFileTracker.cs

示例6: FindImportDestination

        SafeUri FindImportDestination(SafeUri uri, DateTime time)
        {
            // Find a new unique location inside the photo folder
            string name = uri.GetFilename ();

            var dest_uri = FSpot.Core.Global.PhotoUri.Append (time.Year.ToString ())
                                          .Append (String.Format ("{0:D2}", time.Month))
                                          .Append (String.Format ("{0:D2}", time.Day));
            EnsureDirectory (dest_uri);

            // If the destination we'd like to use is the file itself return that
            if (dest_uri.Append (name) == uri)
                return uri;

            // Find an unused name
            int i = 1;
            var dest = dest_uri.Append (name);
            var file = GLib.FileFactory.NewForUri (dest);
            while (file.Exists) {
                var filename = uri.GetFilenameWithoutExtension ();
                var extension = uri.GetExtension ();
                dest = dest_uri.Append (String.Format ("{0}-{1}{2}", filename, i++, extension));
                file = GLib.FileFactory.NewForUri (dest);
            }

            return dest;
        }
开发者ID:hbons,项目名称:f-spot,代码行数:27,代码来源:MergeDb.cs

示例7: SaveToSuitableFormat

 private static void SaveToSuitableFormat(SafeUri destination, Pixbuf pixbuf, uint jpeg_quality)
 {
     // FIXME: this needs to work on streams rather than filenames. Do that when we switch to
     // newer GDK.
     var extension = destination.GetExtension ().ToLower ();
     if (extension == ".png")
         pixbuf.Save (destination.LocalPath, "png");
     else if (extension == ".jpg" || extension == ".jpeg")
         pixbuf.Save (destination.LocalPath, "jpeg", jpeg_quality);
     else
         throw new NotImplementedException ("Saving this file format is not supported");
 }
开发者ID:GNOME,项目名称:f-spot,代码行数:12,代码来源:PixbufUtils.cs

示例8: CreateDerivedVersion

    public static void CreateDerivedVersion(SafeUri source, SafeUri destination, uint jpeg_quality = 95)
    {
        if (source.GetExtension () == destination.GetExtension ()) {
            // Simple copy will do!
            var file_from = GLib.FileFactory.NewForUri (source);
            var file_to = GLib.FileFactory.NewForUri (destination);
            file_from.Copy (file_to, GLib.FileCopyFlags.AllMetadata | GLib.FileCopyFlags.Overwrite, null, null);
            return;
        }

        // Else make a derived copy with metadata copied
        using (var img = ImageFile.Create (source)) {
            using (var pixbuf = img.Load ()) {
                CreateDerivedVersion (source, destination, jpeg_quality, pixbuf);
            }
        }
    }
开发者ID:GNOME,项目名称:f-spot,代码行数:17,代码来源:PixbufUtils.cs


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