public void TemplateSetup() { var type = InvertApplication.FindTypeByNameExternal(Ctx.Data.RelatedTypeName); if (type != null) { Ctx.TryAddNamespace(type.Namespace); } else { type = InvertApplication.FindType(Ctx.Data.RelatedTypeName); if (type != null) { Ctx.TryAddNamespace(type.Namespace); } } Ctx.CurrentDeclaration.Name = Ctx.Data.Name + "Command"; Ctx.AddCondition("Argument", _ => _.HasArgument); if (!Ctx.IsDesignerFile) { Ctx.CurrentDeclaration.BaseTypes.Clear(); } }
public virtual Type FindType(string clrTypeString) { var name = clrTypeString.Split(',').FirstOrDefault(); if (name != null) { return(InvertApplication.FindType(name)); } return(null); return(null); }
public TutorialStep SaveAndCompile(GraphNode node) { return(new TutorialStep("Save & Compile the project.", () => { if (InvertApplication.FindType(node.FullName) == null) { return string.Format("Expected generated types are not found. Make sure that:\n\n" + "* You clicked 'Save and Compile' button\n" + "* Generation is finished\n" + "* Unity console does not contain compilation errors\n"); } return null; })); }
public void Import(List <ExportedRepository> exportedItems) { foreach (var item in exportedItems) { var type = InvertApplication.FindType(item.Type); if (type != null) { var repository = GetRepositoryFor(type); foreach (var record in item.Records) { repository.Import(record); } } } }
public override void Perform(SceneTypeNode node) { if (!EditorApplication.SaveCurrentSceneIfUserWantsTo()) { return; } var paths = node.Project.SystemDirectory; var scenesPath = System.IO.Path.Combine(paths, "Scenes"); var relativeScenesPath = System.IO.Path.Combine(node.Graph.AssetDirectory, "Scenes"); if (!Directory.Exists(scenesPath)) { Directory.CreateDirectory(scenesPath); } EditorApplication.NewScene(); var go = new GameObject(string.Format("_{0}Root", node.Name)); var type = InvertApplication.FindType(node.FullName); if (type != null) { go.AddComponent(type); } EditorUtility.SetDirty(go); var scenePath = System.IO.Path.Combine(scenesPath, node.Name + ".unity"); var relativeScenePath = System.IO.Path.Combine(relativeScenesPath, node.Name + ".unity"); if (!File.Exists(scenePath)) { EditorApplication.SaveScene(System.IO.Path.Combine(relativeScenesPath, node.Name + ".unity"), false); AssetDatabase.Refresh(); } else { EditorApplication.SaveScene(); AssetDatabase.Refresh(); } if (!UnityEditor.EditorBuildSettings.scenes.Any(s => { return(s.path.EndsWith(node.Name + ".unity")); })) { var list = EditorBuildSettings.scenes.ToList(); list.Add(new EditorBuildSettingsScene(relativeScenePath, true)); EditorBuildSettings.scenes = list.ToArray(); } }
public override void Perform(SceneTypeNode node) { //var paths = EditorWindow.GetWindow<ElementsDesigner>().Diagram.Data.Settings.CodePathStrategy; var sceneManagerData = node as SceneTypeNode; if (sceneManagerData == null) { return; } var type = InvertApplication.FindType(node.FullName.AsSceneManager()); if (type == null) { EditorUtility.DisplayDialog("Can't add to scene", "The diagram must be saved and have no compiler errors.", "OK"); return; } Selection.activeGameObject.AddComponent(type); }
public override void Perform(SceneTypeNode node) { var sceneManagerData = node as SceneTypeNode; if (sceneManagerData == null) { return; } var type = InvertApplication.FindType(node.FullName.AsSceneManager()); if (type == null) { EditorUtility.DisplayDialog("Can't add to scene", "The diagram must be saved and have no compiler errors.", "OK"); return; } GameObject obj = new GameObject("_SceneManager"); obj.AddComponent(type); }
public void TemplateSetup() { this.Ctx.TryAddNamespace("uFrame.Kernel"); this.Ctx.TryAddNamespace("uFrame.MVVM"); this.Ctx.TryAddNamespace("uFrame.Serialization"); var type = InvertApplication.FindTypeByNameExternal(Ctx.Data.RelatedTypeName); if (type != null) { Ctx.TryAddNamespace(type.Namespace); } else { type = InvertApplication.FindType(Ctx.Data.RelatedTypeName); if (type != null) { Ctx.TryAddNamespace(type.Namespace); } } Ctx.CurrentDeclaration.IsPartial = true; Ctx.CurrentDeclaration.Name = Ctx.Data.Name + "Command"; Ctx.AddCondition("Argument", _ => !string.IsNullOrEmpty(_.RelatedType)); }
private static Transform SyncKernel(DiagramViewModel 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 = node.CurrentRepository.NodeItems.OfType <ServiceNode>(); foreach (var serviceNode in servicesNodes) { var type = InvertApplication.FindType(serviceNode.FullName); if (type != null && servicesContainer.GetComponent(type) == null) { servicesContainer.gameObject.AddComponent(type); } } var systemNodes = node.GraphData.Project.AllGraphItems.OfType <SubsystemNode>(); foreach (var systemNode in systemNodes) { //if (!systemNode.GetContainingNodes(systemNode.Graph.Project).OfType<ElementNode>().Any()) continue; var type = InvertApplication.FindType(string.Format("{0}Loader", systemNode.FullName)); if (type != null && systemLoadersContainer.GetComponent(type) == null) { systemLoadersContainer.gameObject.AddComponent(type); } } var sceneNodes = node.CurrentRepository.NodeItems.OfType <SceneTypeNode>(); foreach (var sceneNode in sceneNodes) { var type = InvertApplication.FindType(string.Format("{0}Loader", sceneNode.FullName)); if (type != null && sceneLoaderContainer.GetComponent(type) == null) { sceneLoaderContainer.gameObject.AddComponent(type); } } EditorUtility.SetDirty(uFrameMVVMKernel); return(servicesContainer); }
private static Transform SyncKernel(MVVMNode node, GameObject uFrameMVVMKernel) { var servicesContainer = uFrameMVVMKernel.transform.FindChild("Services"); if (servicesContainer == null) { servicesContainer = new GameObject("Services").transform; servicesContainer.SetParent(uFrameMVVMKernel.transform); } var systemLoadersContainer = uFrameMVVMKernel.transform.FindChild("SystemLoaders"); if (systemLoadersContainer == null) { systemLoadersContainer = new GameObject("SystemLoaders").transform; systemLoadersContainer.SetParent(uFrameMVVMKernel.transform); } var sceneLoaderContainer = uFrameMVVMKernel.transform.FindChild("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>()); foreach (var serviceNode in servicesNodes) { var type = InvertApplication.FindType(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>()); foreach (var systemNode in systemNodes) { var type = InvertApplication.FindType(string.Format("{0}Loader", systemNode.FullName)); if (type != null && systemLoadersContainer.GetComponent(type) == null) { systemLoadersContainer.gameObject.AddComponent(type); } } var sceneNodes = node.Graph.AllGraphItems.OfType <SceneTypeNode>(); foreach (var sceneNode in sceneNodes) { var type = InvertApplication.FindType(string.Format("{0}Loader", sceneNode.FullName)); if (type != null && sceneLoaderContainer.GetComponent(type) == null) { sceneLoaderContainer.gameObject.AddComponent(type); } } EditorUtility.SetDirty(uFrameMVVMKernel); return(servicesContainer); }
public void ImportData(JSONClass node) { var typeName = string.Empty; if (node["_CLRType"] != null) { typeName = node["_CLRType"].Value; } else if (node["Type"] != null) { typeName = node["Type"].Value; } var type = InvertApplication.FindType(typeName) ?? Type.GetType(typeName); if (type == null && typeName.StartsWith("ConnectionData")) { type = typeof(ConnectionData); } if (type != null) { var result = ImportType(type, node); if (result is IGraphData) { var item = InvertApplication.Container.Resolve <WorkspaceService>(); if (item.CurrentWorkspace != null) { item.CurrentWorkspace.AddGraph(result as IGraphData); } CurrentGraph = result as InvertGraph; CurrentGraph.RootFilterId = node["RootNode"]["Identifier"].Value; Debug.Log("Set Root filter id to " + CurrentGraph.RootFilterId); } if (result is GraphNode) { CurrentNode = result as GraphNode; CurrentNode.GraphId = CurrentGraph.Identifier; } if (result is DiagramNodeItem) { ((IDiagramNodeItem)result).NodeId = CurrentNode.Identifier; } if (result is ITypedItem) { // TODO Find type and replace it will fullname ((ITypedItem)result).RelatedType = node["ItemType"].Value; } foreach (KeyValuePair <string, JSONNode> child in node) { var array = child.Value as JSONArray; if (array != null) { foreach (var item in array.Childs.OfType <JSONClass>()) { ImportData(item); } } var cls = child.Value as JSONClass; if (cls != null) { if (child.Key == "FilterState") { continue; } if (child.Key == "Settings") { continue; } if (child.Key == "Changes") { continue; } if (child.Key == "PositionData") { ImportPositionData(cls); } else { if (child.Key == "RootNode") { InvertApplication.Log("Importing ROOT NODE"); } ImportData(cls); } } } } }