Esempio n. 1
0
        public override void InstallBindings()
        {
            foreach (var autoBinding in SceneCompositionRoot.GetSceneRootObjects(_compRoot.gameObject.scene)
                     .SelectMany(x => x.GetComponentsInChildren <ZenjectAutoBinding>()))
            {
                if (autoBinding == null)
                {
                    continue;
                }

                var component = autoBinding.Component;
                var bindType  = autoBinding.BindType;

                if (component == null)
                {
                    continue;
                }

                if (bindType == ZenjectAutoBinding.BindTypes.ToInstance ||
                    bindType == ZenjectAutoBinding.BindTypes.ToInstanceAndInterfaces)
                {
                    Container.Bind(component.GetType()).ToInstance(component);
                }

                if (bindType == ZenjectAutoBinding.BindTypes.ToInterfaces ||
                    bindType == ZenjectAutoBinding.BindTypes.ToInstanceAndInterfaces)
                {
                    Container.BindAllInterfacesToInstance(component);
                }
            }
        }