public void StringNames(string name)
            {
                string path       = CreateFile(name, 1024);
                string thumb_path = ThumbnailGenerator.ThumbnailPath(path);

                ThumbnailGenerator.Create(path);

                Assert.IsTrue(File.Exists(thumb_path), String.Format("Missing: {0} created from {1}", thumb_path, path));
                using (Gdk.Pixbuf thumb = new Gdk.Pixbuf(thumb_path)) {
                    Assert.IsNotNull(thumb);
                    Assert.AreEqual(thumb.GetOption(ThumbUri), UriList.PathToFileUriEscaped(path));
                    Assert.AreEqual(new Uri(thumb.GetOption(ThumbUri)), UriList.PathToFileUri(path));
                    Assert.IsTrue(ThumbnailGenerator.ThumbnailIsValid(thumb, UriList.PathToFileUri(path)));
                }

                File.Delete(path);
                File.Delete(thumb_path);
            }
示例#2
0
        public static string GenerateMD5(System.Uri uri)
        {
            try {
                if (md5_cache.ContainsKey(uri))
                {
                    return(md5_cache [uri]);
                }

                using (Gdk.Pixbuf pixbuf = ThumbnailGenerator.Create(uri))
                {
                    byte[] serialized = PixbufSerializer.Serialize(pixbuf);
                    byte[] md5        = MD5Generator.ComputeHash(serialized);
                    string md5_string = Convert.ToBase64String(md5);

                    md5_cache.Add(uri, md5_string);
                    return(md5_string);
                }
            } catch (Exception e) {
                Log.DebugFormat("Failed to create MD5Sum for Uri {0}; {1}", uri, e.Message);
            }

            return(string.Empty);
        }
            public void UriNames(string name)
            {
                string path = CreateFile(name, 768);
                Uri    uri  = new Uri(Gnome.Vfs.Uri.GetUriFromLocalPath(path));

                string string_path = ThumbnailGenerator.ThumbnailPath(path);
                string thumb_path  = ThumbnailGenerator.ThumbnailPath(uri);

                Assert.AreEqual(thumb_path, string_path);

                ThumbnailGenerator.Create(uri);

                Assert.IsTrue(File.Exists(thumb_path), String.Format("Missing: {0} created from {1}", thumb_path, uri));
                using (Gdk.Pixbuf thumb = new Gdk.Pixbuf(thumb_path)) {
                    Assert.IsNotNull(thumb);
                    Assert.AreEqual(thumb.GetOption(ThumbUri), UriList.UriToStringEscaped(uri));
                    Assert.AreEqual(new Uri(thumb.GetOption(ThumbUri)), uri);
                    Assert.IsTrue(ThumbnailGenerator.ThumbnailIsValid(thumb, uri));
                }

                File.Delete(thumb_path);
                File.Delete(path);
            }