static void ReadData(NodeReference node) { try { node.AppendSubscript(""); string subscr = node.NextSubscript(); while (!subscr.Equals("")) { node.SetSubscript(node.GetSubscriptCount(), subscr); if (node.HasData()) { Console.Write(" ".PadLeft(node.GetSubscriptCount() * 4, '-') + subscr + " -> "); GetData(node); } if (node.HasSubnodes()) { ReadData(node); } subscr = node.NextSubscript(); } } catch (GlobalsException ex) { Console.WriteLine(ex.Message); } finally { node.SetSubscriptCount(node.GetSubscriptCount() - 1); } }
private static object ReadArray(NodeReference node, Type columnType) { var arrayLengthsString = node.GetString(EnumerableLengthsSubscriptName); if (string.IsNullOrEmpty(arrayLengthsString)) { return(null); } var elementType = columnType.GetElementType(); var arrayLengths = ToArrayIndexes(arrayLengthsString); var instance = Array.CreateInstance(elementType, arrayLengths); var subscript = node.NextSubscript(EnumerableLengthsSubscriptName); while (!subscript.Equals("")) { node.AppendSubscript(subscript); var item = ReadNode(node, elementType); var indexes = ToArrayIndexes(subscript); instance.SetValue(item, indexes); subscript = node.NextSubscript(); node.SetSubscriptCount(node.GetSubscriptCount() - 1); } return(instance); }
// graph constructor is marked INTERNAL because we want the client to use the // static class factory method CreateGraph(), which redirects here after doing checks. // For opening existing graphs, // we provide another method called OpenGraph() which redirects here also. internal GlGraph(string graph_name) { bool creating_new = !GlobalsGraphAdmin.AllGraphs().Contains(graph_name); _GlNodeRef = GlobalsGraphAdmin.ActiveConnection().CreateNodeReference(graph_name); if (creating_new) _GlNodeRef.Set(GlobalsGraphAdmin.GL_GRAPH_FLAG); // format identifier, causes persistence else { // opening an existing graph. Start by initializing the existing nodes string loop_node_guid = _GlNodeRef.NextSubscript(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, ""); while (loop_node_guid != "") { Guid new_guid = Guid.Empty; if (Guid.TryParse(loop_node_guid, out new_guid)) AllNodesByGuid.Add(new_guid, new GlGraphNode(this, new_guid)); else _GlNodeRef.Kill(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, loop_node_guid); // clean up bad data loop_node_guid = _GlNodeRef.NextSubscript(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, loop_node_guid); } // now loop again and load the edges foreach (GlGraphNode loop_node in AllNodes) { loop_node.InitializeEdges(); } } }
private static object ReadEnumerable(NodeReference node, Type columnType) { var instance = (IList)Activator.CreateInstance(columnType); var elementType = columnType.IsGenericType ? columnType.GetGenericArguments().Single() : typeof(object); if (string.IsNullOrEmpty(node.NextSubscript(""))) { return(null); } var subscript = node.NextSubscript(EnumerableLengthsSubscriptName); while (!subscript.Equals("")) { node.AppendSubscript(subscript); var item = ReadNode(node, elementType); instance.Add(item); subscript = node.NextSubscript(); node.SetSubscriptCount(node.GetSubscriptCount() - 1); } return(instance); }
// constructor is marked INTERNAL because we want the client to use the // static class factory method CreateDocSet(), which redirects here after doing checks. // For opening existing doc sets, // we provide another method called OpenDocSet() which redirects here also. internal GlDocSet(string docset_name) { bool creating_new = !GlobalsDocDB.AllDocSetNames().Contains(docset_name); _GlNodeRef = GlobalsDocDB.ActiveConnection().CreateNodeReference(docset_name); if (creating_new) { _GlNodeRef.Set(GlobalsDocDB.GL_DOCS_FLAG); // format identifier, causes persistence } else { // opening an existing doc set. Start by initializing the existing nodes string loop_node_guid = _GlNodeRef.NextSubscript(""); while (loop_node_guid != "") { Guid new_guid = Guid.Empty; if (Guid.TryParse(loop_node_guid, out new_guid)) { AllDocsByGuid.Add(new_guid, new GlDoc(this, new_guid)); } else { _GlNodeRef.Kill(loop_node_guid); // clean up bad data } loop_node_guid = _GlNodeRef.NextSubscript(loop_node_guid); } } }
private static bool IsNullableComplexColumnEmpty(NodeReference node) { node.AppendSubscript(""); var isEmpty = string.IsNullOrEmpty(node.NextSubscript()); node.SetSubscriptCount(node.GetSubscriptCount() - 1); return(isEmpty); }
public List <string> PropertyNames() { List <string> working_list = new List <string>(); string loop_subscript = _DocNodeRef.NextSubscript(""); while (loop_subscript != "") { try { if (_DocNodeRef.HasSubnodes(loop_subscript, VALUE_SUBSCRIPT)) { continue; } working_list.Add(loop_subscript); } catch { } loop_subscript = _DocNodeRef.NextSubscript(loop_subscript); } return(working_list); }
internal static IEnumerable <NodeReference> GetEntitiesNodes(NodeReference node, DataContext context) { var result = new List <NodeReference>(); node.AppendSubscript(""); var subscript = node.NextSubscript(); while (!subscript.Equals("")) { if (!string.Equals(subscript, IdentityValueSubscriptName)) { var entityNode = context.CreateNodeReference(node.GetName()); entityNode.AppendSubscript(subscript); result.Add(entityNode); } node.SetSubscript(node.GetSubscriptCount(), subscript); subscript = node.NextSubscript(); } return(result); }
private static bool IsKeyExists(string key, NodeReference node) { if (string.IsNullOrEmpty(key)) { return(false); } node.AppendSubscript(GetPreviousSubscriptKey(key)); var subscript = node.NextSubscript(); while (!subscript.Equals("")) { if (string.Equals(subscript, key)) { return(true); } node.SetSubscript(node.GetSubscriptCount(), subscript); subscript = node.NextSubscript(); } return(false); }
// graph constructor is marked INTERNAL because we want the client to use the // static class factory method CreateGraph(), which redirects here after doing checks. // For opening existing graphs, // we provide another method called OpenGraph() which redirects here also. internal GlGraph(string graph_name) { bool creating_new = !GlobalsGraphAdmin.AllGraphs().Contains(graph_name); _GlNodeRef = GlobalsGraphAdmin.ActiveConnection().CreateNodeReference(graph_name); if (creating_new) { _GlNodeRef.Set(GlobalsGraphAdmin.GL_GRAPH_FLAG); // format identifier, causes persistence } else { // opening an existing graph. Start by initializing the existing nodes string loop_node_guid = _GlNodeRef.NextSubscript(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, ""); while (loop_node_guid != "") { Guid new_guid = Guid.Empty; if (Guid.TryParse(loop_node_guid, out new_guid)) { AllNodesByGuid.Add(new_guid, new GlGraphNode(this, new_guid)); } else { _GlNodeRef.Kill(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, loop_node_guid); // clean up bad data } loop_node_guid = _GlNodeRef.NextSubscript(GlobalsGraphAdmin.GL_NODES_SUBSCRIPT, loop_node_guid); } // now loop again and load the edges foreach (GlGraphNode loop_node in AllNodes) { loop_node.InitializeEdges(); } } }
public void DisplayForSubscripts(params object[] working_subscripts) { string prefix = Environment.NewLine + working_noderef.GetName(); if (working_subscripts.Length > 0) { for (int ix = 0; ix < working_subscripts.Length; ix++) { prefix += "[" + working_subscripts[ix].ToString() + "]"; } } prefix += " = "; try { string current_val = working_noderef.GetString(working_subscripts); if (current_val != null) { if (current_val != "") { textDocContents.AppendText(prefix + current_val); } } } catch { } try { if (working_noderef.HasSubnodes(working_subscripts)) { int count = 0; object[] sub_params = new object[working_subscripts.Length + 1]; for (int loop_index = 0; loop_index < working_subscripts.Length; loop_index++) { sub_params[loop_index] = working_subscripts[loop_index]; } sub_params[working_subscripts.Length] = ""; string loop_sub = working_noderef.NextSubscript(sub_params); while (loop_sub != "") { count++; if (count > 10) { textDocContents.AppendText(Environment.NewLine + "..."); break; } sub_params[working_subscripts.Length] = loop_sub; DisplayForSubscripts(sub_params); loop_sub = working_noderef.NextSubscript(sub_params); } } } catch //(Exception e) { MessageBox.Show("Error displaying data"); return; } }