Esempio n. 1
0
        private static Transform SyncKernel(MVVMNode node, GameObject uFrameMVVMKernel)
        {
            var servicesContainer = uFrameMVVMKernel.transform.Find("Services");

            if (servicesContainer == null)
            {
                servicesContainer = new GameObject("Services").transform;
                servicesContainer.SetParent(uFrameMVVMKernel.transform);
            }

            var systemLoadersContainer = uFrameMVVMKernel.transform.Find("SystemLoaders");

            if (systemLoadersContainer == null)
            {
                systemLoadersContainer = new GameObject("SystemLoaders").transform;
                systemLoadersContainer.SetParent(uFrameMVVMKernel.transform);
            }

            var sceneLoaderContainer = uFrameMVVMKernel.transform.Find("SceneLoaders");

            if (sceneLoaderContainer == null)
            {
                sceneLoaderContainer = new GameObject("SceneLoaders").transform;
                sceneLoaderContainer.SetParent(uFrameMVVMKernel.transform);
            }

            //var servicesNodes = InvertApplication.Container.Resolve<WorkspaceService>().CurrentWorkspace.Graphs
            //                                               .SelectMany(g => g.AllGraphItems.OfType<ServiceNode>());
            var servicesNodes = InvertApplication.Container.Resolve <WorkspaceService>()
                                .Workspaces.SelectMany(w => w.Graphs)
                                .SelectMany(g => g.AllGraphItems.OfType <ServiceNode>());

            foreach (var serviceNode in servicesNodes)
            {
                //var type = InvertApplication.FindType(serviceNode.FullName);
                var type = InvertApplication.FindRuntimeTypeByName(serviceNode.FullName);
                if (type != null && servicesContainer.GetComponent(type) == null)
                {
                    servicesContainer.gameObject.AddComponent(type);
                }
            }

            //var systemNodes = InvertApplication.Container.Resolve<WorkspaceService>().CurrentWorkspace.Graphs
            //                                   .SelectMany(g => g.AllGraphItems.OfType<SubSystemNode>());
            var systemNodes = InvertApplication.Container.Resolve <WorkspaceService>()
                              .Workspaces.SelectMany(w => w.Graphs)
                              .SelectMany(g => g.AllGraphItems.OfType <SubSystemNode>());

            foreach (var systemNode in systemNodes)
            {
                //var type = InvertApplication.FindType(string.Format("{0}Loader", systemNode.FullName));
                var type = InvertApplication.FindRuntimeTypeByName(string.Format("{0}Loader", systemNode.FullName));
                if (type != null && systemLoadersContainer.GetComponent(type) == null)
                {
                    systemLoadersContainer.gameObject.AddComponent(type);
                }
            }

            //var sceneNodes = node.Graph.AllGraphItems.OfType<SceneTypeNode>();
            var sceneNodes = InvertApplication.Container.Resolve <WorkspaceService>()
                             .Workspaces.SelectMany(w => w.Graphs)
                             .SelectMany(g => g.AllGraphItems.OfType <SceneTypeNode>());

            foreach (var sceneNode in sceneNodes)
            {
                //var type = InvertApplication.FindType(string.Format("{0}Loader", sceneNode.FullName));
                var type = InvertApplication.FindRuntimeTypeByName(string.Format("{0}Loader", sceneNode.FullName));
                if (type != null && sceneLoaderContainer.GetComponent(type) == null)
                {
                    sceneLoaderContainer.gameObject.AddComponent(type);
                }
            }


            EditorUtility.SetDirty(uFrameMVVMKernel);
            return(servicesContainer);
        }