コード例 #1
0
 public sealed override void Initialize(AVSValue args, ScriptEnvironment env)
 {
     try
     {
         using (new DynamicEnvironment(env))
         {
             OverlayUtils.InitArgs(this, args);
             Initialize(args);
             base.Initialize(args, env);
         }
         topLevel = new DynamicEnvironment(env, false);
         AfterInitialize();
         topLevel.Detach();
     }
     catch (Exception ex)
     {
         try
         {
             DisposeAll();
         }
         catch
         {
             // ignored
         }
         finally
         {
             if (ex is SEHException)
             {
                 throw new AvisynthException("Runtime function call error: " + DynamicEnvironment.LastError);
             }
             DynamicEnvironment.LastError = ex.Message;
             throw new AvisynthException(ex.Message);
         }
     }
 }
コード例 #2
0
ファイル: OverlayUtils.cs プロジェクト: KAviSynth/AutoOverlay
        public static AVSValue ToAvsValue(this object val)
        {
            if (val == null)
            {
                return(new AVSValue());
            }
            if (val is DynamicEnvironment)
            {
                val = ((DynamicEnvironment)val).Clip;
            }
            if (val is Clip clip)
            {
                var cached = DynamicEnvironment.FindClip(clip);
                if (cached != null)
                {
                    return(cached);
                }
            }

            if (!(val is string) && val is IEnumerable array)
            {
                return(new AVSValue(array.OfType <object>().Select(ToAvsValue).ToArray()));
            }
            var ctor = typeof(AVSValue).GetConstructor(new[] { val.GetType() });

            if (ctor == null)
            {
                throw new AvisynthException($"Wrong type '{val.GetType()}' for {nameof(AVSValue)} instantiation");
            }
            return((AVSValue)ctor.Invoke(new[] { val }));
        }
コード例 #3
0
 public sealed override void Initialize(AVSValue args, ScriptEnvironment env)
 {
     try
     {
         using (new DynamicEnvironment(env))
         {
             OverlayUtils.InitArgs(this, args);
             Initialize(args);
             base.Initialize(args, env);
         }
         topLevel = new DynamicEnvironment(env, false);
         AfterInitialize();
         topLevel.Detach();
     }
     catch (Exception ex)
     {
         try
         {
             DisposeAll();
         }
         finally
         {
             throw ex;
         }
     }
 }
コード例 #4
0
 protected override void Dispose(bool disposing)
 {
     Filters.Remove(this);
     base.Dispose(disposing);
     OverlayUtils.Dispose(this);
     topLevel?.Dispose();
     topLevel = null;
 }