本文整理汇总了C#中DBElement.addElementData方法的典型用法代码示例。如果您正苦于以下问题:C# DBElement.addElementData方法的具体用法?C# DBElement.addElementData怎么用?C# DBElement.addElementData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBElement
的用法示例。
在下文中一共展示了DBElement.addElementData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestR3
void TestR3()
{
WriteLine();
"Demonstrating Requirement #3".title('=');
WriteLine();
"Adding Key-Value pair to database".title();
DBElement<int, string> element = new DBElement<int, string>();
element.addElementData("element3", "test element for adding key-value pair to databse with value as string", DateTime.Now, new List<int> { 1, 2 }, "test elemet3's payload");
"element to be added to database".title();
element.showElement();
db.insert(2, element);
db.showDB();
WriteLine();
"Adding Key-Value pair to enumerable database".title();
DBElement<string, List<string>> listelement = new DBElement<string, List<string>>();
listelement.addElementData("element4", "test element for adding key-value pair to databse with value as list of string", DateTime.Now, new List<string> { "1", "two" }, new List<string> { "test elemet4's payload" });
"element to be added to database".title();
listelement.showEnumerableElement();
enum_db.insert("enum_two", listelement);
enum_db.showEnumerableDB();
WriteLine();
"Deleting Key-Value pair from database".title();
"Element with key=1 will be deleted from database".title();
"Element with key=1:".title();
DBElement<int, string> remove_element = new DBElement<int, string>();
db.getValue(1, out remove_element);
remove_element.showElement();
db.remove(1);
WriteLine();
"Modified Database: ".title();
db.showDB();
WriteLine();
"Deleting Key-Value pair from enumerable database".title();
"Element with key=enum_one will be deleted from database".title();
"Element with key=enum_one:".title();
DBElement<string, List<string>> remove_enum_element = new DBElement<string, List<string>>();
enum_db.getValue("enum_one", out remove_enum_element);
remove_enum_element.showEnumerableElement();
enum_db.remove("enum_one");
WriteLine();
"Modified enumerable Database: ".title();
enum_db.showEnumerableDB();
WriteLine();
}
示例2: TestR4
void TestR4(string edit_action)
{
DBElement<string, List<string>> element = new DBElement<string, List<string>>();
element.addElementData("element1", "test element for editing key-value pair to databse with value as string", DateTime.Now, new List<string> { "enum_one", "enum_two" }, new List<string> { "test element1's payload" });
enum_db.insert("enum_one", element);
"Demonstrating Requirement #4".title();
DBElement<string, List<string>> edit_element = new DBElement<string, List<string>>();
enum_db.getValue("enum_one", out edit_element);
"Element to be edited".title();
edit_element.showEnumerableElement();
WriteLine();
"Database before editing".title();
enum_db.showEnumerableDB();
WriteLine();
switch (edit_action)
{
case "edit metadata":
edit_element.edit_metadata(edit_action);
goto default;
case "add children":
edit_element.add_children(edit_action);
goto default;
case "remove children":
edit_element.remove_children(edit_action);
goto default;
case "edit payload":
edit_element.edit_payload();
goto default;
default:
"element after editing".title();
edit_element.showEnumerableElement();
"Databaser after editing".title();
enum_db.showEnumerableDB();
WriteLine();
break;
}
}
示例3: TestR5
void TestR5()
{
"Demonstrating Requirement #5".title('=');
"Persisting to XML file".title();
WriteLine();
WriteLine("Saving DB with int as key and string payload to xml file ~/debug/test_DB");
db.create_xml_from_db(false, "db.xml");
WriteLine("Saving DB with String as key and list of strings as payload to XML file ~/debug/test_enumDB");
enum_db.create_xml_from_db(false, "enum_db.xml");
WriteLine("Remove previous elements from db");
if (db != null)
{
db.removeAll();
}
WriteLine("Current DB state");
db.showDB();
WriteLine();
WriteLine("Adding element to database");
DBElement<int, string> element = new DBElement<int, string>();
element.addElementData("element1", "test element for editing key-value pair to databse with value as string", DateTime.Now, new List<int> { 1, 2 }, "test element1's payload");
db.insert(1, element);
WriteLine("DB state after adding an element");
db.showDB();
WriteLine();
WriteLine("Writing data from xml file Test_DB.xml to databse");
WriteLine("All elements from xml which have same key as the key of element present in database is discarded.");
db.create_db_from_xml("db.xml");
WriteLine();
WriteLine("Removing entries from enum Db if any");
if (enum_db != null)
{
enum_db.removeAll();
}
WriteLine("Cureent enum DB state");
enum_db.showEnumerableDB();
WriteLine();
WriteLine("Adding element to database");
DBElement<string, List<string>> listelement = new DBElement<string, List<string>>();
listelement.addElementData("element4", "test element for adding key-value pair to databse with value as list of string", DateTime.Now, new List<string> { "1", "two" }, new List<string> { "test elemet4's payload" });
enum_db.insert("six",listelement);
WriteLine("Enum database after adding an element");
enum_db.showEnumerableDB();
WriteLine("Writing data from xml file Test_enumDB.xml to enum databse");
enum_db.create_enum_db_from_xml("enum_db.xml");
WriteLine();
}
示例4: TestR4
void TestR4()
{
DBElement<int, string> element = new DBElement<int, string>();
element.addElementData("element1", "test element for editing key-value pair to databse with value as string", DateTime.Now, new List<int> { 1, 2 }, "test element1's payload");
db.insert(1, element);
"Demonstrating Requirement #4".title();
DBElement<int, string> edit_element = new DBElement<int, string>();
db.getValue(1, out edit_element);
"Element to be edited".title();
edit_element.showElement();
WriteLine();
"Databaser before editing".title();
db.showDB();
WriteLine();
"Editing metadata of element:".title();
"adding relationship in metadata".title();
edit_element.name="name after editing";
edit_element.descr="descr after editing";
edit_element.timeStamp=DateTime.Now;
edit_element.children.Add(3);
edit_element.showElement();
db.showDB();
WriteLine();
"removing relationship from metadata".title();
edit_element.children.Remove(3);
db.showDB();
WriteLine();
"editing value's instance".title();
edit_element.payload = "payload after editing";
db.showDB();
WriteLine();
}