public object Load(INodeLoader loader, out int errors) { object instance = FindOrMakeInstance(); errors = Load(loader, ref instance); return(instance); }
/// <summary> /// Adds a node loader to this manager, for the given type. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="nodeType"></param> /// <param name="loader"></param> internal void AddLoader <T>(Type nodeType, INodeLoader <T> loader) where T : NodeModel { if (!nodeType.IsSubclassOf(typeof(NodeModel))) { throw new ArgumentException(@"Given type is not a subclass of NodeModel.", "nodeType"); } nodeLoaders[nodeType] = loader; alsoKnownAsMappings[nodeType.FullName] = nodeType; }
private bool GetNodeSourceFromType(Type type, out INodeLoader <NodeModel> data) { if (GetNodeSourceFromTypeHelper(type, out data)) { return(true); // Found among built-in types, return it. } Log(string.Format("Could not load node of type: {0}", type.FullName)); return(false); }
// TODO: Need furture clarification about the load process internal bool UpdateFromHierarchy(INodeLoader assembleController) { var needFresh = UpdateWindowList(assembleController); if (needFresh) { PrepareList(this.windowList); UpdateVisibility(); } return(needFresh); }
public int Load(INodeLoader loader, ref object instance) { var load = new NodeLoader { Loader = loader }; var node = instance as IConfigNode; node?.BeforeLoaded(); int count = Apply(ref instance, load); node?.AfterLoaded(); return(count); }
private bool GetNodeSourceFromTypeHelper(Type type, out INodeLoader <NodeModel> data) { while (true) { if (type == null || type == typeof(NodeModel)) { data = null; return(false); } if (nodeLoaders.TryGetValue(type, out data)) { return(true); // Found among built-in types, return it. } type = type.BaseType; } }
public void LoadWindows(INodeLoader assembleController, Action <Rect> layoutCallback) { if (assembleController == null) { // TODO: Clean the screen when assembleController is null layoutCallback(Rect.zero); } this.assembleController = assembleController; var needRefresh = UpdateFromHierarchy(assembleController); if (needRefresh) { ApplyAssembleFlow(this.windowList, assembleController); PrepareList(windowList); this.isDirty = false; } LayoutWindows(layoutCallback); }
private bool UpdateWindowList(INodeLoader assembleController) { bool needRefresh = false; // A bit hacky, but so far the best way to convert any type to T IEnumerable <T> nodeList = assembleController.GetAllNodes <T>(); var nodeSetToBeDeleted = new HashSet <int>(windowList.Keys); foreach (var node in nodeList) { WindowItem <T> window; this.windowList.TryGetValue(node.GetID(), out window); if (window != null) { // Exist item, just remove from node set and do nothing nodeSetToBeDeleted.Remove(node.GetID()); if (window.IsDeleted()) { window.MarkDeleted(false); } if (node.GetName() != window.GetNodeName()) { window.UpdateNodeName(node.GetName()); needRefresh = true; } } else { // The key is new, add new item var newWindow = new WindowItem <T>(node); this.windowList.Add(newWindow.GetNodeId(), newWindow); needRefresh = true; //Debug.Log("Added item " + newWindow.GetNodeId()); } } foreach (var item in nodeSetToBeDeleted) { this.windowList[item].MarkDeleted(true); needRefresh = true; Debug.Log("Item deleted " + item); } return(needRefresh); }
/// <summary> /// Adds a node loader to this manager. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="loader"></param> internal void AddLoader <T>(INodeLoader <T> loader) where T : NodeModel { AddLoader(typeof(T), loader); }
private void ApplyAssembleFlow(IDictionary <int, WindowItem <T> > windowList, INodeLoader assembleController) { var flowString = assembleController.GetAssembleFlowAsset() == null ? "" : assembleController.GetAssembleFlowAsset().text; assembleController.ParseAssembleFlowFile(flowString, (int step0, int step1) => { WindowItem <T> w0; WindowItem <T> w1; if (windowList.TryGetValue(step0, out w0) && windowList.TryGetValue(step1, out w1)) { w1.AddPreviousStep(w0); } else { Debug.LogError("Failed to create flow nodes of " + step0 + "->" + step1); } }); }
public void LoadContent(INodeLoader myController) { this.target = myController; this.windowManager = new WindowManager <T>(); windowManager.LoadWindows(myController, (r) => this.panelSize = r.size); }
public LazyLoadedGraph(INodeLoader <TNode, TEdgeTag> nodeLoader) { _nodeLoader = nodeLoader; }