Esempio n. 1
0
        public object GetService(Type registrationInterface)
        {
            ServiceRegistration registration = null;

            if (GetActiveContext().TryGet(registrationInterface, out registration))
            {
                return(registration.GetService(this));
            }
            else
            {
                Debug.LogWarning("No service registration for type: '" + registrationInterface.ToString());
                return(null);
            }
        }
Esempio n. 2
0
        public ServiceType GetService <ServiceType>() where ServiceType : class
        {
            Type t = typeof(ServiceType);
            ServiceRegistration registration = null;

            if (GetActiveContext().TryGet(t, out registration))
            {
                return(registration.GetService <ServiceType>(this));
            }
            else
            {
                Debug.LogWarning("No service registration for type: '" + t.ToString());
                return(null);
            }
        }
Esempio n. 3
0
        public void RegisterService(ServiceRegistration serviceRegistration, Type registrationInterface)
        {
            // force the creation of the registered service and also make sure it's not null
            object service = serviceRegistration.GetService(this);

            if (service == null)
            {
                throw new NullReferenceException("ServiceRegistration returns null for type "
                                                 + registrationInterface.Name + ", registration=" + serviceRegistration);
            }

            var component = service as Component;

            if (component != null)
            {
                component.transform.parent = this.transform;
            }

            GetActiveContext().Set(registrationInterface, serviceRegistration);
        }
Esempio n. 4
0
        public static void DoDefaultInitService(ServiceRegistration reg, Services loc, Action onCompleteCallback)
        {
            object s = reg.GetService(loc);
            var    asyncInitService = s as AsyncInitService;

            if (asyncInitService != null)
            {
                asyncInitService.InitServiceAsync(loc, onCompleteCallback);
            }
            else
            {
                var autoInitService = s as AutoInitService;
                if (autoInitService != null)
                {
                    autoInitService.InitService(loc);
                }

                onCompleteCallback();
            }
        }