示例#1
0
 public void Dispose()
 {
     if (tool != null)
     {
         tool.Dispose();
     }
     this.tool = null;
     this.filterSet.Dispose();
     this.filterSet = null;
 }
示例#2
0
        /// <summary>
        /// Get the target of this Binding
        /// </summary>
        /// <returns>The handle to a method that can process a file. This will be a zero-method (one that loads nothing) if something went wrong.</returns>
        public FileProcessor GetTarget()
        {
            switch (this.TargetType)
            {
            case TargetType.METHOD:
                BrowsableData bd;
                switch (this.BindingType)
                {
                case BindingType.GRAPHICS:
                    bd = MainWindow.GraphData; break;

                case BindingType.PALETTE:
                    bd = MainWindow.PalData; break;

                default: MainWindow.ShowError("Invalid binding: " + this.Name + " has an invalid BindingType value: " + this.bindingType.ToString()); return(this.loadNothing);
                }
                MethodInfo mi;
                try { mi = bd.GetType().GetMethod(this.Target, new Type[] { typeof(String) }); }
                catch { MainWindow.ShowError("Invalid Binding: no such method " + this.Target); return(this.loadNothing); }
                try
                {
                    return(FileProcessor.CreateDelegate(typeof(FileProcessor), bd, mi, true) as FileProcessor);
                }
                catch (Exception e)
                {
                    MainWindow.ShowError("Something went wrong in Binding.GetTarget; " + e.Message);
                    return(this.loadNothing);
                }

            case TargetType.LUA:

                if (tool != null)
                {
                    tool.Dispose();
                }
                tool = new LuaTool(this, this.Target);
                return(new FileProcessor(tool.loadFile));

            default:
                MainWindow.ShowError("Invalid binding: " + this.Name + " has as invalid TargetType: " + this.TargetType.ToString());
                return(this.loadNothing);
            }
        }
示例#3
0
 public void Dispose()
 {
     if (tool != null)
         tool.Dispose();
     this.tool = null;
     this.filterSet.Dispose();
     this.filterSet = null;
 }
示例#4
0
        /// <summary>
        /// Get the target of this Binding
        /// </summary>
        /// <returns>The handle to a method that can process a file. This will be a zero-method (one that loads nothing) if something went wrong.</returns>
        public FileProcessor GetTarget()
        {
            switch (this.TargetType)
            {
                case TargetType.METHOD:
                    BrowsableData bd;
                    switch (this.BindingType)
                    {
                        case BindingType.GRAPHICS:
                            bd = MainWindow.GraphData; break;
                        case BindingType.PALETTE:
                            bd = MainWindow.PalData; break;
                        default: MainWindow.ShowError("Invalid binding: "+this.Name+" has an invalid BindingType value: "+this.bindingType.ToString()); return this.loadNothing;
                    }
                    MethodInfo mi;
                    try { mi = bd.GetType().GetMethod(this.Target, new Type[] { typeof(String) }); }
                    catch { MainWindow.ShowError("Invalid Binding: no such method " + this.Target); return this.loadNothing; }
                    try
                    {
                        return FileProcessor.CreateDelegate(typeof(FileProcessor), bd, mi, true) as FileProcessor;
                    }
                    catch(Exception e)
                    {
                        MainWindow.ShowError("Something went wrong in Binding.GetTarget; " + e.Message);
                        return this.loadNothing;
                    }
                case TargetType.LUA:

                    if (tool != null)
                        tool.Dispose();
                    tool = new LuaTool(this, this.Target);
                    return new FileProcessor(tool.loadFile);

                default:
                    MainWindow.ShowError("Invalid binding: "+this.Name+" has as invalid TargetType: "+this.TargetType.ToString());
                    return this.loadNothing;
            }
        }