// create a new doc object around an existing doc in the db internal GlDoc(GlDocSet parent_docset, Guid doc_guid) { _DocUID = doc_guid; _ParentDocSet = parent_docset; _DocNodeRef = GlobalsDocDB.ActiveConnection().CreateNodeReference(_ParentDocSet.Name); _DocNodeRef.AppendSubscript(_DocUID.ToString()); }
// 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); } } }
// CONSTRUCTORS (internal). Note that GlDoc objects for existing documents // are created by the GlDocSet constructor. GlDoc objects for docs being // created by the user are created by GlDocSet.CreateNewDoc(). These two // GlDocSet methods call these internal constructors for GlDoc. // create a doc object for a brand-new doc (does not exist in DB yet) internal GlDoc(GlDocSet parent_docset) { _DocUID = Guid.NewGuid(); _ParentDocSet = parent_docset; _DocNodeRef = GlobalsDocDB.ActiveConnection().CreateNodeReference(_ParentDocSet.Name); _DocNodeRef.AppendSubscript(_DocUID.ToString()); _DocNodeRef.Set("GlDoc"); // dummy }
private void AppendActualString(string property_name, string new_value) { ValueList current_vl = _DocNodeRef.GetList(property_name, VALUE_SUBSCRIPT); if (current_vl == null) { current_vl = GlobalsDocDB.ActiveConnection().CreateList(); } current_vl.Append(new_value); _DocNodeRef.Set(current_vl, property_name, VALUE_SUBSCRIPT); current_vl.Close(); }
private void RemoveActualString(string property_name, string value_to_remove) { ValueList current_vl = _DocNodeRef.GetList(property_name, VALUE_SUBSCRIPT); ValueList new_vl = GlobalsDocDB.ActiveConnection().CreateList(); string loop_str = current_vl.GetNextString(); while (loop_str != null) { if (loop_str != value_to_remove) { new_vl.Append(loop_str); } loop_str = current_vl.GetNextString(); } _DocNodeRef.Set(new_vl, property_name, VALUE_SUBSCRIPT); current_vl.Close(); new_vl.Close(); }
public void InitForGlobalName(string name) { working_noderef = GlobalsDocDB.ActiveConnection().CreateNodeReference(name); DisplayForSubscripts(); }