public override IEnumerable<Item> Perform(IEnumerable<Item> items, IEnumerable<Item> modItems) { string tags; List<IFileItem> uploads; tags = AccountConfig.Tags + " "; if (modItems.Any ()) { foreach (Item modItem in modItems) { ITextItem tag = (modItem as ITextItem); tags += tag.Text + " "; } } //Build a list of all of the files to upload. uploads = new List<IFileItem> (); foreach (Item item in items) { IFileItem file = item as IFileItem; if (file == null) continue; if (Directory.Exists (file.Path)) { DirectoryInfo dinfo = new DirectoryInfo (file.Path); foreach (FileInfo f in dinfo.GetFiles ()) { if (FileIsPicture (f.FullName)) uploads.Add (Services.UniverseFactory.NewFileItem (f.FullName)); } } else { uploads.Add (file); } } Services.Application.RunOnThread ( () => { /* Mono 2.4 bug hack * This can't use using () due to some crazy-wierd scoping problem. * See https://bugzilla.novell.com/show_bug.cgi?id=516676 for details. * */ IEnumerable<IFileItem> temp = uploads; UploadPool uploadQueue = new UploadPool (tags); try { foreach (IFileItem photo in uploads) uploadQueue.EnqueueUpload (photo); uploadQueue.BeginUploads (); } finally { uploadQueue.Dispose (); } }); yield break; }
public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modItems) { string tags; List <IFileItem> uploads; tags = AccountConfig.Tags + " "; if (modItems.Any()) { foreach (Item modItem in modItems) { ITextItem tag = (modItem as ITextItem); tags += tag.Text + " "; } } //Build a list of all of the files to upload. uploads = new List <IFileItem> (); foreach (Item item in items) { IFileItem file = item as IFileItem; if (file == null) { continue; } if (Directory.Exists(file.Path)) { DirectoryInfo dinfo = new DirectoryInfo(file.Path); foreach (FileInfo f in dinfo.GetFiles()) { if (FileIsPicture(f.FullName)) { uploads.Add(Services.UniverseFactory.NewFileItem(f.FullName)); } } } else { uploads.Add(file); } } Services.Application.RunOnThread(() => { /* Mono 2.4 bug hack * This can't use using () due to some crazy-wierd scoping problem. * See https://bugzilla.novell.com/show_bug.cgi?id=516676 for details. * */ IEnumerable <IFileItem> temp = uploads; UploadPool uploadQueue = new UploadPool(tags); try { foreach (IFileItem photo in uploads) { uploadQueue.EnqueueUpload(photo); } uploadQueue.BeginUploads(); } finally { uploadQueue.Dispose(); } }); yield break; }