示例#1
0
        protected override void OnStart(IServiceContainer container)
        {
            PathParser           pathParser           = new PathParser();
            ExpressionPathFinder expressionPathFinder = new ExpressionPathFinder();
            ConverterRegistry    converterRegistry    = new ConverterRegistry();

            ObjectSourceProxyCreationService objectSourceProxyCreationService = new ObjectSourceProxyCreationService();

            objectSourceProxyCreationService.Register(new UniversalObjectSourceProxyFactory(), 0);
            objectSourceProxyCreationService.Register(new InteractionRequestSourceProxyFactory(), 1);

            SourceProxyCreationService sourceFactoryService = new SourceProxyCreationService();

            sourceFactoryService.Register(new LiteralSourceProxyFactory(), 0);
            sourceFactoryService.Register(new ExpressionSourceProxyFactory(sourceFactoryService, expressionPathFinder), 1);
            sourceFactoryService.Register(objectSourceProxyCreationService, 2);

            TargetProxyCreationService targetFactoryService = new TargetProxyCreationService();

            targetFactoryService.Register(new UniversalTargetProxyFactory(), 0);
            targetFactoryService.Register(new UnityTargetProxyFactory(), 10);
            targetFactoryService.Register(new ObservablePropertyTargetProxyFactory(), 20);

            BindingFactory bindingFactory = new BindingFactory(sourceFactoryService, targetFactoryService);
            StandardBinder binder         = new StandardBinder(bindingFactory);
            ProxyFactory   proxyFactory   = ProxyFactory.Default;

            PropertyInfo info = typeof(UnityEngine.GameObject).GetProperty("activeSelf");

            proxyFactory.Register(new ProxyPropertyInfo <UnityEngine.GameObject, bool>(info, g => g.activeSelf, (g, v) => g.SetActive(v)));

            container.Register <IBinder>(binder);
            container.Register <IBindingFactory>(bindingFactory);
            container.Register <IConverterRegistry>(converterRegistry);

            container.Register <IExpressionPathFinder>(expressionPathFinder);
            container.Register <IPathParser>(pathParser);

            container.Register <IObjectSourceProxyFactory>(objectSourceProxyCreationService);
            container.Register <IObjectSourceProxyFactoryRegistry>(objectSourceProxyCreationService);

            container.Register <ISourceProxyFactory>(sourceFactoryService);
            container.Register <ISourceProxyFactoryRegistry>(sourceFactoryService);

            container.Register <ITargetProxyFactory>(targetFactoryService);
            container.Register <ITargetProxyFactoryRegister>(targetFactoryService);

            container.Register <IProxyFactory>(proxyFactory);
            container.Register <IProxyRegistry>(proxyFactory);
        }
        protected override void OnStart(IServiceContainer container)
        {
            PathParser           pathParser           = new PathParser();
            ExpressionPathFinder expressionPathFinder = new ExpressionPathFinder();
            ConverterRegistry    converterRegistry    = new ConverterRegistry();

            ObjectSourceProxyFactory objectSourceProxyFactory = new ObjectSourceProxyFactory();

            objectSourceProxyFactory.Register(new UniversalNodeProxyFactory(), 0);

            SourceProxyFactory sourceFactory = new SourceProxyFactory();

            sourceFactory.Register(new LiteralSourceProxyFactory(), 0);
            sourceFactory.Register(new ExpressionSourceProxyFactory(sourceFactory, expressionPathFinder), 1);
            sourceFactory.Register(objectSourceProxyFactory, 2);

            TargetProxyFactory targetFactory = new TargetProxyFactory();

            targetFactory.Register(new UniversalTargetProxyFactory(), 0);
            targetFactory.Register(new UnityTargetProxyFactory(), 10);
#if FAIRY_GUI
            targetFactory.Register(new FairyTargetProxyFactory(), 20);
#endif
#if UNITY_2019_3_OR_NEWER
            targetFactory.Register(new VisualElementProxyFactory(), 30);
#endif

            BindingFactory bindingFactory = new BindingFactory(sourceFactory, targetFactory);
            StandardBinder binder         = new StandardBinder(bindingFactory);

            container.Register <IBinder>(binder);
            container.Register <IBindingFactory>(bindingFactory);
            container.Register <IConverterRegistry>(converterRegistry);

            container.Register <IExpressionPathFinder>(expressionPathFinder);
            container.Register <IPathParser>(pathParser);

            container.Register <INodeProxyFactory>(objectSourceProxyFactory);
            container.Register <INodeProxyFactoryRegister>(objectSourceProxyFactory);

            container.Register <ISourceProxyFactory>(sourceFactory);
            container.Register <ISourceProxyFactoryRegistry>(sourceFactory);

            container.Register <ITargetProxyFactory>(targetFactory);
            container.Register <ITargetProxyFactoryRegister>(targetFactory);
        }
        protected void OnStart(IQFrameworkContainer container)
        {
            PathParser           pathParser           = new PathParser();
            ExpressionPathFinder expressionPathFinder = new ExpressionPathFinder();
            ConverterRegistry    converterRegistry    = new ConverterRegistry();

            ObjectSourceProxyFactory objectSourceProxyFactory = new ObjectSourceProxyFactory();

            objectSourceProxyFactory.Register(new UniversalNodeProxyFactory(), 0);

            SourceProxyFactory sourceFactory = new SourceProxyFactory();

            sourceFactory.Register(new LiteralSourceProxyFactory(), 0);
            sourceFactory.Register(new ExpressionSourceProxyFactory(sourceFactory, expressionPathFinder), 1);
            sourceFactory.Register(objectSourceProxyFactory, 2);

            TargetProxyFactory targetFactory = new TargetProxyFactory();

            targetFactory.Register(new UniversalTargetProxyFactory(), 0);
            targetFactory.Register(new UnityTargetProxyFactory(), 10);

            BindingFactory bindingFactory = new BindingFactory(sourceFactory, targetFactory);
            StandardBinder binder         = new StandardBinder(bindingFactory);

            container.RegisterInstance <IBinder>(binder);
            container.RegisterInstance <IBindingFactory>(bindingFactory);
            container.RegisterInstance <IConverterRegistry>(converterRegistry);

            container.RegisterInstance <IExpressionPathFinder>(expressionPathFinder);
            container.RegisterInstance <IPathParser>(pathParser);

            container.RegisterInstance <INodeProxyFactory>(objectSourceProxyFactory);
            container.RegisterInstance <INodeProxyFactoryRegister>(objectSourceProxyFactory);

            container.RegisterInstance <ISourceProxyFactory>(sourceFactory);
            container.RegisterInstance <ISourceProxyFactoryRegistry>(sourceFactory);

            container.RegisterInstance <ITargetProxyFactory>(targetFactory);
            container.RegisterInstance <ITargetProxyFactoryRegister>(targetFactory);
        }