예제 #1
0
        public void Load()
        {
            if (this.Instancia == null)
            {
                this.Instancia = (Lfx.Components.Function) this.ComponentInfo.Assembly.CreateInstance(this.ComponentInfo.EspacioNombres + "." + this.Nombre);
            }

            if (Instancia != null)
            {
                this.Instancia.Workspace = Lfx.Workspace.Master;
                Lfx.Types.OperationResult Res = this.Instancia.Try();
                if (Res.Success)
                {
                    this.Ready = true;
                }
                else
                {
                    this.Ready = false;
                }
            }
            else
            {
                this.Ready = false;
            }
        }
예제 #2
0
                public void Load()
                {
                        if (this.Instancia == null)
                                this.Instancia = (Lfx.Components.Function)this.ComponentInfo.Assembly.CreateInstance(this.ComponentInfo.EspacioNombres + "." + this.Nombre);

                        if (Instancia != null) {
                                this.Instancia.Workspace = Lfx.Workspace.Master;
                                Lfx.Types.OperationResult Res = this.Instancia.Try();
                                if (Res.Success) {
                                        this.Ready = true;
                                } else {
                                        this.Ready = false;
                                }
                        } else {
                                this.Ready = false;
                        }
                }
예제 #3
0
        //[STAThread]
        public static void Main(string[] args)
        {
            //Console.WriteLine("RunComponent");
            //Console.WriteLine("    Ejecuta un componente Lfx fuera del entorno de Lázaro.");
            //Console.WriteLine("    Copyright 2004-2012 Ernesto N. Carrea");
            //Console.WriteLine("");
            System.Windows.Forms.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(ThreadExceptionHandler);
            AppDomain.CurrentDomain.UnhandledException       += new UnhandledExceptionEventHandler(GlobalExceptionHandler);
            System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            string ComponentName = null, FunctionName = null;

            if (args.Length == 2)
            {
                ComponentName = args[0];
                FunctionName  = args[1];
            }
            else if (args.Length == 1)
            {
                ComponentName = args[0];
                FunctionName  = args[0];
            }
            else if (args.Length == 0)
            {
                ComponentName = System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().Location);
                FunctionName  = ComponentName;
            }

            Lfx.Workspace.Master  = new Lfx.Workspace("default");
            Lbl.Sys.Config.Actual = new Lbl.Sys.Configuracion.Global();
            Lbl.Sys.Config.Cargar();

            if (ComponentName != null && FunctionName != null)
            {
                //Console.WriteLine("Ejecutando " + ComponentName + "." + FunctionName);
                Lbl.Componentes.Componente Comp = new Lbl.Componentes.Componente(Lfx.Workspace.Master.GetNewConnection(ComponentName));
                Comp.Crear();
                Comp.Nombre         = ComponentName;
                Comp.EspacioNombres = ComponentName;
                Lfx.Components.Manager.RegisterComponent(Comp);

                Lfx.Components.Function Funcion = null;
                try {
                    Funcion = Comp.Funciones[FunctionName].Instancia;
                } catch (Exception ex) {
                    System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error");
                }
                if (Funcion != null)
                {
                    Funcion.Workspace      = Lfx.Workspace.Master;
                    Funcion.ExecutableName = System.Reflection.Assembly.GetExecutingAssembly().Location;
                    Funcion.Arguments      = Environment.GetCommandLineArgs();
                    Funcion.Run(true);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("No se puede ejecutar " + ComponentName + "." + FunctionName, "Error");
                }
            }
            else
            {
                Console.WriteLine("Uso:");
                Console.WriteLine("    RunComponent [NombreComponente] [NombreFuncion]");
                Console.WriteLine("        Si no se especifica NombreFuncion, se asume igual que NombreComponente.");
                Console.WriteLine("        Si no se especifica NombreComponente, se asume el nombre de este ejecutable.");
            }
        }