本文整理汇总了C#中Hyena.SafeUri类的典型用法代码示例。如果您正苦于以下问题:C# SafeUri类的具体用法?C# SafeUri怎么用?C# SafeUri使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeUri类属于Hyena命名空间,在下文中一共展示了SafeUri类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenWrite
public System.IO.Stream OpenWrite (SafeUri uri, bool overwrite)
{
var file = FileFactory.NewForUri (uri.AbsoluteUri);
return new GioStream (overwrite
? file.Replace (null, false, FileCreateFlags.None, null)
: file.Create (FileCreateFlags.None, null));
}
示例2: AudioCdTrackInfo
public AudioCdTrackInfo (AudioCdDiscModel model, string deviceNode, int index)
{
this.model = model;
this.index_on_disc = index;
Uri = new SafeUri (String.Format ("cdda://{0}#{1}", index_on_disc + 1, deviceNode));
}
示例3: CopyIfNeeded
public void CopyIfNeeded (IPhoto item, SafeUri destinationBase)
{
// remember source uri for copying xmp file
SafeUri defaultVersionUri = item.DefaultVersion.Uri;
foreach (IPhotoVersion version in item.Versions) {
// Copy into photo folder and update IPhotoVersion uri
var source = version.Uri;
var destination = destinationBase.Append (source.GetFilename ());
if (!source.Equals (destination)) {
destination = GetUniqueFilename (destination);
file_system.File.Copy (source, destination, false);
copied_files.Add (destination);
original_files.Add (source);
version.Uri = destination;
}
}
// Copy XMP sidecar
var xmp_original = defaultVersionUri.ReplaceExtension(".xmp");
if (file_system.File.Exists (xmp_original)) {
var xmp_destination = item.DefaultVersion.Uri.ReplaceExtension (".xmp");
file_system.File.Copy (xmp_original, xmp_destination, true);
copied_files.Add (xmp_destination);
original_files.Add (xmp_original);
}
}
示例4: DaapTrackInfo
public DaapTrackInfo(Track track, DaapSource source)
: base()
{
TrackTitle = track.Title;
AlbumTitle = track.Album;
ArtistName = track.Artist;
DateAdded = track.DateAdded;
DateUpdated = track.DateModified;
Genre = track.Genre;
FileSize = track.Size;
TrackCount = track.TrackCount;
TrackNumber = track.TrackNumber;
DiscNumber = track.DiscNumber;
DiscCount = track.DiscCount;
Year = track.Year;
Duration = track.Duration;
MimeType = track.Format;
BitRate = (int)track.BitRate;
ExternalId = track.Id;
PrimarySource = source;
Uri = new SafeUri (String.Format (
"{0}{1}/{2}", DaapService.ProxyServer.HttpBaseAddress, source.Database.GetHashCode (), track.Id
));
//this.IsLive = false;
//this.CanSaveToDatabase = false;
}
示例5: GetThumbnailerForUri
public IThumbnailer GetThumbnailerForUri (SafeUri uri)
{
if (ImageFile.HasLoader (uri)) {
return new ImageThumbnailer (uri, fileSystem);
}
return null;
}
示例6: CreateThumbnail
bool CreateThumbnail (SafeUri thumbnailUri, ThumbnailSize size, IImageFile imageFile)
{
var pixels = size == ThumbnailSize.Normal ? 128 : 256;
Pixbuf pixbuf;
try {
pixbuf = imageFile.Load ();
} catch (Exception e) {
Log.DebugFormat ("Failed loading image for thumbnailing: {0}", imageFile.Uri);
Log.DebugException (e);
return false;
}
double scale_x = (double)pixbuf.Width / pixels;
double scale_y = (double)pixbuf.Height / pixels;
double scale = Math.Max (1.0, Math.Max (scale_x, scale_y));
// Ensures that the minimum value is 1 so that pixbuf.ScaleSimple doesn't return null
// Seems to only happen in rare(?) cases
int target_x = Math.Max ((int)(pixbuf.Width / scale), 1);
int target_y = Math.Max ((int)(pixbuf.Height / scale), 1);
var thumb_pixbuf = pixbuf.ScaleSimple (target_x, target_y, InterpType.Bilinear);
var mtime = fileSystem.File.GetMTime (imageFile.Uri).ToString ();
thumb_pixbuf.Savev (thumbnailUri.LocalPath, "png",
new string [] { ThumbnailService.ThumbUriOpt, ThumbnailService.ThumbMTimeOpt, null },
new string [] { imageFile.Uri, mtime });
pixbuf.Dispose ();
thumb_pixbuf.Dispose ();
return true;
}
示例7: Load
public void Load (SafeUri uri)
{
if (is_disposed)
return;
//First, send a thumbnail if we have one
if ((thumb = App.Instance.Container.Resolve<IThumbnailService> ().TryLoadThumbnail (uri, ThumbnailSize.Large)) != null) {
pixbuf_orientation = ImageOrientation.TopLeft;
EventHandler<AreaPreparedEventArgs> prep = AreaPrepared;
if (prep != null) {
prep (this, new AreaPreparedEventArgs (true));
}
EventHandler<AreaUpdatedEventArgs> upd = AreaUpdated;
if (upd != null) {
upd (this, new AreaUpdatedEventArgs (new Rectangle (0, 0, thumb.Width, thumb.Height)));
}
}
using (var image_file = ImageFile.Create (uri)) {
image_stream = image_file.PixbufStream ();
pixbuf_orientation = image_file.Orientation;
}
loading = true;
// The ThreadPool.QueueUserWorkItem hack is there cause, as the bytes to read are present in the stream,
// the Read is CompletedAsynchronously, blocking the mainloop
image_stream.BeginRead (buffer, 0, count, delegate (IAsyncResult r) {
ThreadPool.QueueUserWorkItem (delegate {
HandleReadDone (r);});
}, null);
}
示例8: GenerateMD5
public static string GenerateMD5(SafeUri uri)
{
var file = GLib.FileFactory.NewForUri (uri);
var stream = new GLib.GioStream (file.Read (null));
var hash = CryptoUtil.Md5EncodeStream (stream);
stream.Close ();
return hash;
}
示例9: OpenPlay
public static RadioTrackInfo OpenPlay (SafeUri uri)
{
RadioTrackInfo track = Open (uri);
if (track != null) {
track.Play ();
}
return track;
}
示例10: CopyTrackTo
public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
{
if (track.PrimarySource == this && track.Uri.Scheme.StartsWith ("http")) {
foreach (double percent in database.DownloadTrack ((int)track.ExternalId, track.MimeType, uri.AbsolutePath)) {
job.DetailedProgress = percent;
}
}
}
示例11: ImageInfo
public ImageInfo(SafeUri uri)
{
using (var img = ImageFile.Create (uri)) {
Pixbuf pixbuf = img.Load ();
SetPixbuf (pixbuf);
pixbuf.Dispose ();
}
}
示例12: GetSize
public long GetSize(SafeUri uri)
{
try {
return new System.IO.FileInfo (uri.LocalPath).Length;
} catch {
return -1;
}
}
示例13: Copy
public void Copy (SafeUri source, SafeUri destination, bool overwrite)
{
var source_file = FileFactory.NewForUri (source);
var destination_file = FileFactory.NewForUri (destination);
var flags = FileCopyFlags.AllMetadata;
if (overwrite)
flags |= FileCopyFlags.Overwrite;
source_file.Copy (destination_file, flags, null, null);
}
示例14: BaseImageFile
public BaseImageFile(SafeUri uri)
{
Uri = uri;
Orientation = ImageOrientation.TopLeft;
using (var metadata_file = Metadata.Parse (uri)) {
ExtractMetadata (metadata_file);
}
}
示例15: TestMissingFile
public void TestMissingFile()
{
XdgThumbnailSpec.DefaultLoader = (u) => {
throw new Exception ("not found!");
};
var uri = new SafeUri ("file:///invalid");
var pixbuf = XdgThumbnailSpec.LoadThumbnail (uri, ThumbnailSize.Large);
Assert.IsNull (pixbuf);
}