Example #1
0
        public void SetTarget(string Target)
        {
            if (!Targets.ContainsKey(Target))
            {
                throw (new Exception(String.Format("Unknown target '{0}' use --show_targets in order to view available targets", Target)));
            }
            this.Target = (ICConverter)Activator.CreateInstance(Targets[Target].Item2);
            this.Target.Initialize(OutputName);

#if false
            try
            {
                this.Target = (ICConverter)Activator.CreateInstance(Targets[Target].Item2);
            }
            catch (TargetInvocationException TargetInvocationException)
            {
                StackTraceUtils.PreserveStackTrace(TargetInvocationException.InnerException);
                throw(TargetInvocationException.InnerException);
            }
#endif
        }
Example #2
0
        public TType GetInstance <TType>() where TType : PspEmulatorComponent
        {
            lock (this)
            {
                try
                {
                    if (!ObjectsByType.ContainsKey(typeof(TType)))
                    {
                        Console.WriteLine("GetInstance<{0}>: Miss!", typeof(TType));
                        var Start = DateTime.Now;
                        PspEmulatorComponent Instance;
                        if (TypesByType.ContainsKey(typeof(TType)))
                        {
                            Instance = _SetInstance <TType>((PspEmulatorComponent)Activator.CreateInstance(TypesByType[typeof(TType)]));
                        }
                        else
                        {
                            Instance = _SetInstance <TType>((PspEmulatorComponent)Activator.CreateInstance(typeof(TType)));
                        }
                        Instance._InitializeComponent(this);
                        Instance.InitializeComponent();
                        var End = DateTime.Now;
                        Console.WriteLine("GetInstance<{0}>: Miss! : LoadTime({1})", typeof(TType), End - Start);
                        return((TType)Instance);
                    }

                    return((TType)ObjectsByType[typeof(TType)]);
                }
                catch (TargetInvocationException TargetInvocationException)
                {
                    Console.Error.WriteLine("Error obtaining instance '{0}'", typeof(TType));
                    StackTraceUtils.PreserveStackTrace(TargetInvocationException.InnerException);
                    throw (TargetInvocationException.InnerException);
                }
            }
        }