protected void ControlRemoteObject(object instance, object value, PropertyInfo propertyInfo)
        {
            // Not letting mono behaviours to be injected if they are not IDIClosedContext
            // (because we cannot control their lifetime)

            IDIClosedContext ctxval = value as IDIClosedContext;

            if (RemoteObjectsHelper.IsRemoteObject(value) && (ctxval == null || !ctxval.IsValid()))
            {
                throw new MiniocException("Injecting a remote object that doesn't implement IDIClosedContext is not allowed ! Tried to inject object " + value + " into property " + propertyInfo.Name + " of the object " + instance);
            }
        }
Example #2
0
        private void RegisterRemoteObject(object instance, bool hashOnly = false)
        {
            if (!RemoteObjectsHelper.IsRemoteObject(instance))
            {
                return;
            }
            IRemoteObjectsRecord remoteRecord = (IRemoteObjectsRecord)this.ResolveInternal(typeof(IRemoteObjectsRecord), null, null, false);

            if (!hashOnly)
            {
                remoteRecord.Register(instance);
            }
            else
            {
                IRemoteObjectsHash hash = (IRemoteObjectsHash)this.ResolveInternal(typeof(IRemoteObjectsHash), null, null, false);
                hash.Register(instance);
            }
        }
Example #3
0
        private void DoInitialization()
        {
            // Ignoring starter on non-root scene
            if (Application.loadedLevelName != RootSceneName)
            {
                if (RootContainer.context == null)
                {
                    throw new MindiException("Don't use starter on non-root scene. Use _rootRedirect instead.");
                }

                return;
            }

            if (RootContainer.context != null)
            {
                throw new MindiException("The root scene is loaded when the context is already initialized !");
            }

            init = this.GetComponent <UnityContextStart>();
            if (init == null)
            {
                throw new MindiException("UnityContextStart or any inherited component not found on the _starter object !");
            }

            // Adding remote objects validator
            RemoteObjectsHelper.AddValidator(new UnityRemoteObjectsValidator());

            // Creating context
            RootContainer.context = init.CreateContext();

            // Resolving root scene factory
            RootSceneFactory factory = RootContainer.context.Resolve <RootSceneFactory>();

            factory.Create <ISceneObject>(RootSceneName, false);

            // Global start of application
            init.GlobalStart(RootContainer.context);

            // Loading auto start scene
            LoadAutoStartScene();

            ready = true;
        }