internal LocalApplication(
            IComponentDirectory parentDirectory,
            ApplicationDesc application,
            Guid instanceGuid,
            ulong instanceNumber)
        {
            this.instanceGuid   = instanceGuid;
            this.instanceNumber = instanceNumber;

            string iname = application.Name + " " + instanceGuid.ToString();

            this.applicationDescriptor = application;

            localDirectory = new ComponentDirectory(parentDirectory, iname);

            localDirectory.Register(
                new Instance(
                    localDirectory.GetInstance <DatabaseManager>().Find("/"), "WorkingDirectory"));

            localDirectory.Register(new Instance(this, "Process"));

            foreach (IComponentProvider provider in application.Components)
            {
                localDirectory.Register(provider);
            }
        }
Beispiel #2
0
        public override int Start(string verb, string[] args)
        {
            Console.WriteLine(String.Join(",", args));

            Console.WriteLine(">> INIT, v.0.0.1 Booting SharpMedia ComponentOS (c) 2005-2008");
            Console.WriteLine("Init: Starting Services...");
            (componentDirectory.GetInstance <IServiceRegistry>() as IServiceControl).Start();

            Console.Out.WriteLine("Double Vectors Per Second on a WU Thread: " +
                                  (threadControl.WorkUnits.FreeMost(typeof(ICPUWorkUnit)) as ICPUWorkUnit).FPU.DoubleVectorCrosses4D);

            IApplicationInstance proc =
                applicationInstances.Run(
                    args.Length > 0 ? args[0] : "/System/Applications/Components/TextShell", string.Empty, args);

            while (proc.IsRunning)
            {
                Thread.Sleep(100);
            }

            Console.WriteLine("Init: Shutting Down...");
            (componentDirectory.GetInstance <IServiceRegistry>() as IServiceControl).Stop();
            return(1);
        }
        public int Start(string verb, string[] arguments)
        {
            // We auto-parametrize.
            this.verb = verb;
            this.args = RegisterAutoParametrization(localDirectory, arguments);

            // Only create on first start.
            if (appInstance == null)
            {
                appInstance = localDirectory.GetInstance(
                    applicationDescriptor.ApplicationComponent) as IApplicationBase;
            }

            applicationThread = new Thread(LocalMain);
            isRunning         = true;
            applicationThread.Start();

            return(exitResult);
        }
Beispiel #4
0
        /// <summary>
        /// Application instance that lives in a dedicated app domain
        /// </summary>
        /// <param name="parentDirectory"></param>
        /// <param name="application"></param>
        /// <param name="instanceGuid"></param>
        internal AppDomainApplication(
            IComponentDirectory parentDirectory,
            ApplicationDesc application,
            Guid instanceGuid,
            ulong instanceNumber)
        {
            this.instanceGuid   = instanceGuid;
            this.instanceNumber = instanceNumber;

            string iname = application.Name + " " + instanceGuid.ToString();

            appDomain = AppDomain.CreateDomain(iname);

            /* create instance and unwrap the caller so that all the stuff happens in its own domain */
            this.bridge = appDomain.CreateInstanceAndUnwrap(
                typeof(Bridge).Assembly.FullName,
                typeof(Bridge).FullName) as Bridge;

            this.applicationDescriptor = application;

            /* set up the instance */
            this.bridge.Setup(parentDirectory, application, instanceGuid, this, parentDirectory.GetInstance <IAssemblyLoader>());
            this.bridge.Callback = this;
        }
Beispiel #5
0
 public object GetInstance(string destinationType)
 {
     return(componentDirectory.GetInstance(componentName));
 }