/// <summary> /// hydrates the graph from a string /// </summary> /// <param name="text"></param> /// <param name="valueManagers">if null, the Default managers are used</param> /// <returns></returns> public static Graph Parse(string text, ValueManagerChainOfResponsibility managerSet) { Graph graph = new Graph(managerSet); graph.Parse(text); return graph; }
/// <summary> /// converts the provided object into a graph /// </summary> /// <param name="obj"></param> /// <param name="valueManagers">if null, the Default managers are used</param> /// <returns></returns> public static Graph Build(object obj, ValueManagerChainOfResponsibility managerSet, Func<object, GraphPath, bool> skipFilter = null) { Graph graph = new Graph(managerSet); graph.BuildGraph(obj, skipFilter); return graph; }
public static Graph NewDefault() { Graph graph = new Graph(ValueManagerChainOfResponsibility.NewDefault()); return graph; }
public static Graph New(ValueManagerChainOfResponsibility managerSet) { Graph graph = new Graph(managerSet); return graph; }
public static XDocument ConvertToXML(Graph graph) { XDocument doc = new XDocument(); XElement root = new XElement("root"); doc.Add(root); var nodes = graph.NodeStore.GetAll(); nodes = nodes.OrderBy((x) => { return x.TraversalIndex; }).ToList(); XElement parent = null; nodes.WithEach(node => { var name = ScrubBackingFieldName(node.Path.CurrentSegment.Path); var nameArr = name.Split(new string[] { " " }, StringSplitOptions.None); var nodeName = nameArr[0]; var depth = nameArr.Length == 2 ? nameArr[1] : "0"; var mgr = graph.ChainOfResponsibility.GetValueManagerById(node.ValueManagerId); var context = string.Join(",", LengthEncoder.MakeReadable(node.Context, "").ToArray()); XElement layer = new XElement(nodeName, new XAttribute("i", node.TraversalIndex), new XAttribute("depth", depth), new XAttribute("mgr", node.ValueManagerId), context); //if (parent == null) //{ root.Add(layer); //} //else //{ // parent.Add(layer); //} //parent = layer; }); return doc; }