Beispiel #1
0
        public static IEnumerable <CodeValuePair> EnumerateStdSourceParams(ISourceRef source)
        {
            if ((source != null) && !string.IsNullOrEmpty(source.SourcePath))
            {
                string tmp = source.SourcePath;

                yield return(new CodeValuePair()
                {
                    Code = TemplParams.FilePath, Value = tmp
                });

                yield return(new CodeValuePair()
                {
                    Code = TemplParams.DirPath, Value = TemplParams.GetDirPath(tmp)
                });

                yield return(new CodeValuePair()
                {
                    Code = TemplParams.FileName, Value = TemplParams.GetFileName(tmp)
                });

                yield return(new CodeValuePair()
                {
                    Code = TemplParams.FileExt, Value = TemplParams.GetFileExt(tmp)
                });
            }
        }
Beispiel #2
0
 /// <summary>
 /// Execute external command. <paramref name="srf"/> must implement <see cref="ISourceRef"/>.
 /// </summary>
 /// <param name="srf">Target media file. Must implement <see cref="ISourceRef"/></param>
 public virtual void Execute(ISourceRef srf, Func <string, string> getValue = null)
 {
     if (srf != null)
     {
         this.Execute(TemplParams.EnumerateStdSourceParams(srf), getValue);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Checks if this command can be applied to the target media file.
 /// <paramref name="srf"/> must implement <see cref="ISourceRef"/>.
 /// </summary>
 /// <param name="srf">Must implement <see cref="ISourceRef"/></param>
 /// <returns></returns>
 public virtual bool CanExecute(ISourceRef srf)
 {
     if (srf == null)
     {
         return(false);
     }
     if (this.ApplicableFileExtensions != null)
     {
         if (!this.ApplicableFileExtensions.Contains(TemplParams.GetFileExt(srf.SourcePath)))
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #4
0
        public void Process(MediaTrackSource msrc)
        {
            this.Status.Clear();
            ExternalCommand xcmd;

            if (msrc.Targets.Count > 0)
            {
                List <CodeValuePair> srcPrms = new List <CodeValuePair>(TemplParams.EnumerateStdSourceParams(msrc));
                foreach (var t in msrc.Targets)
                {
                    t.Source = msrc;
                    xcmd     = t.XCmd;
                    if ((xcmd != null) && xcmd.CanExecute(msrc))
                    {
                        var pQ = srcPrms.Union(EnumerateTrgParams(t));
                        xcmd.Execute(pQ);
                    }
                }
            }
        }