当前位置: 首页>>代码示例>>C#>>正文


C# DBElement.showElement方法代码示例

本文整理汇总了C#中DBElement.showElement方法的典型用法代码示例。如果您正苦于以下问题:C# DBElement.showElement方法的具体用法?C# DBElement.showElement怎么用?C# DBElement.showElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBElement的用法示例。


在下文中一共展示了DBElement.showElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            WriteLine("Testing DBExtensions Package\n");
            WriteLine();

            //Insert first element
            Write("\n --- Test DBElement<int,string> ---");
            DBElement<int, string> elem1 = new DBElement<int, string>();
            elem1.payload = "a payload";
            Write(elem1.showElement<int, string>());

            //Insert first element into DB
            DBEngine<int, DBElement<int, string>> dbs = new DBEngine<int, DBElement<int, string>>();
            dbs.insert(1, elem1);
            dbs.show<int, DBElement<int, string>, string>();
            WriteLine();

            //Insert first element into String Key/Value DB
            Write("\n --- Test DBElement<string,List<string>> ---");
            DBElement<string, List<string>> newelem1 = new DBElement<string, List<string>>();
            newelem1.name = "newelem1";
            newelem1.descr = "test new type";
            newelem1.children = new List<string> { "Key1", "Key2" };
            newelem1.payload = new List<string> { "one", "two", "three" };
            Write(newelem1.showElement<string, List<string>, string>());
            DBEngine<string, DBElement<string, List<string>>> dbe = new DBEngine<string, DBElement<string, List<string>>>();
            dbe.insert("key1", newelem1);
            dbe.show<string, DBElement<string, List<string>>, List<string>, string>();
            Write("\n\n");
        }
开发者ID:darshanmp,项目名称:Remote-NoSQL-DB,代码行数:30,代码来源:DBExtensionsTest.cs

示例2: key_value_search

 /* Defining a query using lambda function to search specific key 
 */
 public void key_value_search(DBEngine<int, DBElement<int, string>> db, IQuery<int, DBElement<int, string>> i_query, QueryEngine<int, DBElement<int, string>> qe )
 {
     "Query for value with specified key (key = 2):".title();
     WriteLine();
     int key_to_search = 2;
     Func<int, string, bool> keyValueSearch = (int key, string search) => //lambda function
     {
         if (!db.Keys().Contains(key))
             return false;
         else
         {
             if (key == int.Parse(search))
             {
                 DBElement<int, string> ele = new DBElement<int, string>();
                 db.getValue(key, out ele);
                 return true;
             }
             else { return false; }
         }
     };
     // pass query to query engine and call simpleQuery to make query on DBEngine
     qe.simpleQuery(keyValueSearch, key_to_search.ToString(), out i_query);
     WriteLine();
     foreach (var key in i_query.Keys())
     {
         DBElement<int, string> temp = new DBElement<int, string>();
         i_query.getValue(key, out temp);
         WriteLine("key : {0}", key);
         temp.showElement();
         WriteLine();
     }
 }
开发者ID:yogeshchaudhari16991,项目名称:NoSQLDatabase,代码行数:34,代码来源:QueryPredicate.cs

示例3: TestR2

    public void TestR2()
    {
      "Demonstrating Requirement #2".title('=');
      "Database with string as payload".title();
      DBElement<int, string> elem = new DBElement<int, string>();
      elem.name = "element";
      elem.descr = "test element";
      elem.timeStamp = DateTime.Now;
      elem.children.AddRange(new List<int>{ 1, 2, 3 });
      elem.payload = "elem's payload";
      elem.showElement();
      db.insert(1, elem);
      db.showDB();
      WriteLine();
      "database with list of strings as payload".title();
      DBElement<string, List<string>> element = new DBElement<string, List<string>>();
      element.name = "element2";
      element.descr = "test element for list of strings as value";
      element.timeStamp = DateTime.Now;
      element.children.AddRange(new List<string> { "one","two"});
      element.payload = new List<string> { "element's payload", "2nd payload" };
      element.showEnumerableElement();
      enum_db.insert("enum_one", element);
      enum_db.showEnumerableDB();
      WriteLine();

    }
开发者ID:yogeshchaudhari16991,项目名称:RemoteNoSQLDB,代码行数:27,代码来源:TestExec.cs

示例4: testDBlement

        public void testDBlement()
        {
            Write("\n --- Test DBElement<int,string> ---");
            DBElement<int, string> elem1 = new DBElement<int, string>();
            elem1.payload = "a payload";
            Write(elem1.showElement<int, string>());
            WriteLine();

            DBElement<int, string> elem2 = new DBElement<int, string>("Darth Vader", "Evil Overlord");
            elem2.payload = "The Empire strikes back!";
            Write(elem2.showElement<int, string>());
            WriteLine();

            var elem3 = new DBElement<int, string>("Luke Skywalker", "Young HotShot");
            elem3.children.AddRange(new List<int> { 1, 5, 23 });
            elem3.payload = "X-Wing fighter in swamp - Oh oh!";
            Write(elem3.showElement<int, string>());
            WriteLine();

            Write("\n --- Test DBEngine<int,DBElement<int,string>> ---");

            int key = 0;
            Func<int> keyGen = () => { ++key; return key; };  // anonymous function to generate keys

            DBEngine<int, DBElement<int, string>> db = new DBEngine<int, DBElement<int, string>>();
            bool p1 = db.insert(keyGen(), elem1);
            bool p2 = db.insert(keyGen(), elem2);
            bool p3 = db.insert(keyGen(), elem3);
            if (p1 && p2 && p3)
                Write("\n  all inserts succeeded");
            else
                Write("\n  at least one insert failed");
            db.show<int, DBElement<int, string>, string>();
            WriteLine();
        }
开发者ID:rakeshh91,项目名称:Android-Projects,代码行数:35,代码来源:DBEngineTest.cs

示例5: TestR3

    void TestR3()//addition and deletion of key/value pairs
    {
      "Demonstrating Requirement #3".title();
	  WriteLine();
	  
	  Write("\n --- Test addition of key/value pairs Start---");
	  WriteLine();
	  DBElement<int, string> elem1 = new DBElement<int, string>();
      elem1.name = "element#1";//add a new key/value pairs
      elem1.descr = "test element#1";
      elem1.timeStamp = DateTime.Now;
      elem1.children.AddRange(new List<int>{ 6, 8 });
      elem1.payload = "elem#1's payload";
      elem1.showElement();
      db.insert(2, elem1);
	  Write("\n\n Show key/value pairs in data base:\n");
      db.showDB();
      WriteLine();
	  Write("\n --- Test addition of key/value pairs End---");
	  WriteLine();
	  
	  Write("\n --- Test deletion of key/value pairs Start---");
	  WriteLine();
	  db.delete(1);//delete an existing key/value pairs
	  Write("\n\n Show key/value pairs in data base:\n");
      db.showDB();
      WriteLine();
      db.delete(100);//try to delete a key/value pairs that doesn't exist
	  Write("\n --- Test deletion of key/value pairs End---");
      WriteLine();
    }
开发者ID:lxinghe,项目名称:681project4,代码行数:31,代码来源:TestExec.cs

示例6: TestR2

        void TestR2()
        {
            "Demonstrating Requirement #2".title();
            //creating new element of type int and string
            DBElement<int, string> element = new DBElement<int, string>();
            element.name = "first element of db";
            element.descr = "int and string type";
            element.timeStamp = DateTime.Now;
            element.children.AddRange(new List<int> { 0, 2, 4, 8 });
            element.payload = "first element's payload";
            element.showElement();
            db.insert(1, element);
            db.showDB();
            WriteLine();
            //creating new element of type string and list of strings
            DBElement<string, List<string>> element2 = new DBElement<string, List<string>>();
            element2.name = "second element of db";
            element2.descr = "strings and strings of string types";
            element2.timeStamp = DateTime.Now;
            element2.children.AddRange(new List<string> { "SMA", "OOD", "Project2" });
            element2.payload = new List<string> { "second", "SMA", "project" };
            element2.showEnumerableElement();
            db2.insert("2", element2);
            db2.showEnumerableDB();
            WriteLine();

        }
开发者ID:abhilash215,项目名称:Remote-Key-Value-Database,代码行数:27,代码来源:TestExec.cs

示例7: TestR2

        void TestR2()
    {
      "Demonstrating Requirement #2".title();
      DBElement<int, string> elem = new DBElement<int, string>();
      elem.name = "element";
      elem.descr = "test element";
      elem.timeStamp = DateTime.Now;
      elem.children.AddRange(new List<int>{ 1, 2, 3 });
      elem.payload = "elem's payload";
      elem.showElement();
      db.insert(1, elem);
	  Write("\n\n Show key/value pairs in data base:\n");
      db.showDB();
      WriteLine();
    }
开发者ID:lxinghe,项目名称:681project4,代码行数:15,代码来源:TestExec.cs

示例8: 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();
      
    }
开发者ID:yogeshchaudhari16991,项目名称:RemoteNoSQLDB,代码行数:48,代码来源:TestExec.cs

示例9: Main

        // Main Method to test the implementation of DBElement Package
        static void Main(string[] args)
        {
            "Testing DBElement Package".title('=');
            WriteLine();

            Write("\n --- Test DBElement<int,string> ---");
            WriteLine();
            // new elements for  int and string database
            DBElement<int, string> elem1 = new DBElement<int, string>();
            Write(elem1.showElement<int, string>());
            WriteLine();

            DBElement<int, string> elem2 = new DBElement<int, string>("Darth Vader", "Evil Overlord");
            elem2.payload = "The Empire strikes back!";
            Write(elem2.showElement<int, string>());
            WriteLine();

            var elem3 = new DBElement<int, string>("Luke Skywalker", "Young HotShot");
            elem3.children = new List<int> { 1, 2, 7 };
            elem3.payload = "X-Wing fighter in swamp - Oh oh!";
            Write(elem3.showElement<int, string>());
            WriteLine();

            Write("\n --- Test DBElement<string,List<string>> ---");
            WriteLine();

            //new elements for  string and list of strings database
            DBElement<string, List<string>> newelem1 = new DBElement<string, List<string>>();
            newelem1.name = "newelem1";
            newelem1.descr = "test new type";
            newelem1.payload = new List<string> { "one", "two", "three" };
            Write(newelem1.showElement<string, List<string>, string>());
            WriteLine();

            DBElement<string, List<string>> newerelem1 = new DBElement<string, List<string>>();
            newerelem1.name = "newerelem1";
            newerelem1.descr = "same stuff";
            newerelem1.children.Add("first_key");
            newerelem1.children.Add("second_key");
            newerelem1.payload = new List<string> { "alpha", "beta", "gamma" };
            newerelem1.payload.AddRange(new[] { "delta", "epsilon" });
            Write(newerelem1.showElement<string, List<string>, string>());
            WriteLine();

            Write("\n\n");
        }
开发者ID:abhilash215,项目名称:NoSQL-Database,代码行数:47,代码来源:DBElementTest.cs

示例10: query

    //private DBEngine<int, DBElement<int, List<int>>> keysFromQuery = new DBEngine<int, DBElement<int, List<int>>>();

        
	public string query(XDocument message)	{//method used to handle queries
		string reply;
		List<int> children = new List<int>();
		XElement element = message.Element("Message").Element("QueryType");
		Query<int, int, string> query1 = new Query<int, int, string>(db);
		switch(element.Value){
				case "the value of specified key":
					element = message.Element("Message").Element("Key");
				    DBElement<int, string> elem = new DBElement<int, string>();
				    query1.checkValueByKey(Int32.Parse(element.Value), out elem);
					reply = ("The value of specified key " + element.Value + " is\n" + elem.showElement<int, string>());
					break;
				case "the children of specified key":
					element = message.Element("Message").Element("Key");
					children = query1.childrenByKey(Int32.Parse(element.Value));
					reply = ("The children of specified key " + element.Value + " is\n");
					reply = this.addChildToStr(children, reply);
					break;
				case "the keys share a same pattern":
					element = message.Element("Message").Element("Pattern");
					Query<string, int, string> queryString = new Query<string, int, string>(dbString);
					List<string> keyString = new List<string>();
					keyString = queryString.keysWithPattern(dbString,element.Value);
					reply = ("The keys share a same pattern \"" + element.Value + "\" is\n");
					foreach(var key in keyString)
						reply += (String.Format("{0}\n", key.ToString()));
					break;
				case "the keys share same pattern in their metadata":
					element = message.Element("Message").Element("Pattern");
					children = query1.keysSameMdataPattern(element.Value);
					reply = ("The keys share same pattern " + element.Value + " is\n");
					reply = this.addChildToStr(children, reply);
					break;
				case "the keys of value created in the same time interval":
					List<DateTime> dts = new List<DateTime>();
					dts = this.getDTS(message);
					children = query1.keysSameTinterval(dts[0], dts[1]);
					reply = ("The keys of value created in the same time interval between " + dts[0].ToString() + " and " + dts[1]).ToString()+"\n";
					reply = this.addChildToStr(children, reply);
					break;
				default:
                    reply = ("Invalid editing type.");
					break;
			}
		return reply;
	}
开发者ID:lxinghe,项目名称:681project4,代码行数:49,代码来源:Server.cs

示例11: TestR2

        void TestR2()
        {
            DBElement<int, string> elem = new DBElement<int, string>();
            elem.name = "India";
            elem.descr = "Country";
            elem.timeStamp = DateTime.Now;
            elem.children.AddRange(new List<int> { 2, 3 });
            elem.payload = "Famous cricket player";
            WriteLine();

            "1) The element is as shown below".title();
            elem.showElement();
            db.insert(1, elem);
            WriteLine();

            "2) The key Value pair is shown below".title();
            db.showDB();
            WriteLine();
        }
开发者ID:rakeshh91,项目名称:Android-Projects,代码行数:19,代码来源:TestExec.cs

示例12: Main

        static void Main(string[] args)
        {
            /*
             * Create and edit a DBEngine first.
             * Then create a DBFactory using the DBEngine.
             */

            "Testing DBEngine Package".title('=');
            WriteLine();

            Write("\n --- Test DBElement<int,string> ---");
            DBElement<int, string> elem1 = new DBElement<int, string>();
            elem1.payload = "a payload";
            Write(elem1.showElement<int, string>());
            WriteLine();

            DBElement<int, string> elem2 = new DBElement<int, string>("Darth Vader", "Evil Overlord");
            elem2.payload = "The Empire strikes back!";
            Write(elem2.showElement<int, string>());
            WriteLine();

            int key = 0;
            Func<int> keyGen = () => { ++key; return key; };  // anonymous function to generate keys

            DBEngine<int, DBElement<int, string>> db = new DBEngine<int, DBElement<int, string>>();
            bool p1 = db.insert(keyGen(), elem1);
            bool p2 = db.insert(keyGen(), elem2);

            Write("\n --- Create DBFactory<int, DBElement<int, string>> from DBEngine<int,DBElement<int, string>> ---");

            DBFactory<int, DBElement<int, string>> dbFactory = new DBFactory<int, DBElement<int, string>>(db);
            foreach (int dbKey in dbFactory.Keys())
            {
                DBElement<int, string> value;
                dbFactory.getValue(dbKey, out value);
                value.showElement();
            }
            dbFactory.showDB();
            Write("\n\n");
        }
开发者ID:CodeWizrd,项目名称:RemoteNoSQLDB,代码行数:40,代码来源:DBFactoryTest.cs

示例13: Main

 static void Main(string[] args)
 {
     DBEngine<int, DBElement<int, string>> db = Test1();
     //Insert the Second element
     Write("\n --- Test DBElement<string,List<string>> ---");
     DBElement<string, List<string>> newerelem1 = new DBElement<string, List<string>>();
     newerelem1.name = "newerelem1";
     newerelem1.descr = "better formatting";
     newerelem1.payload = new List<string> { "alpha", "beta", "gamma" };
     newerelem1.payload.Add("delta");
     newerelem1.payload.Add("epsilon");
     Write(newerelem1.showElement<string, List<string>, string>());
     WriteLine();
     //Insert the Third element
     DBElement<string, List<string>> newerelem2 = new DBElement<string, List<string>>();
     newerelem2.name = "newerelem2";
     newerelem2.descr = "better formatting";
     newerelem1.children.AddRange(new[] { "first", "second" });
     newerelem2.payload = new List<string> { "a", "b", "c" };
     newerelem2.payload.Add("d");
     newerelem2.payload.Add("e");
     Write(newerelem2.showElement<string, List<string>, string>());
     WriteLine();
     Write("\n --- Test DBEngine<string,DBElement<string,List<string>>> ---");
     //Anonymous functionality for generating string key
     int seed = 0;
     string skey = seed.ToString();
     Func<string> skeyGen = () =>
     {
         ++seed;
         skey = "string" + seed.ToString();
         skey = skey.GetHashCode().ToString();
         return skey;
     };
     Test2(db, newerelem1, newerelem2, skeyGen);
 }
开发者ID:darshanmp,项目名称:Remote-NoSQL-DB,代码行数:36,代码来源:DBEngineTest.cs

示例14: TestR4

    void TestR4(){//support editing of value including the addition and/or deletion of relationships, 
                  //editing text metadata and replacing an existing value's instance with a new instance

            "Demonstrating Requirement #4".title();

        DBElement<int, string> temp = new DBElement<int, string>();
        ItemEditor<int, string> editItem;
		
        if (db.containsKey(2)){
            db.getValue(2, out temp);
			Write("\n\n --- value before modified---\n");
			temp.showElement();
            editItem = new ItemEditor<int, string>(temp);
			editItem.nameEdit("newName!!");//edit the name of the value with key 2
			editItem.descrEdit("new description!!");//edit description
			editItem.dateTimeEdit();//update timeStamp
			editItem.addRelationship(18);//add relationship
			editItem.deleteRelationship(6);//delete relationship
			editItem.payloadEdit("new payload!!");//modify payload
			
			DBElement<int, string> elemNew = new DBElement<int, string>();
			editItem.replaceWithInstance(out elemNew);// replace an existing value's instance with a new instance
			temp = null;
			Write("\n\n --- value after modified---\n");
			elemNew.showElement();
            editItem = null;
        }

        else
			Write("Value not found!");
		
      //Write("\n\n Show key/value pairs in data base:\n");
	  //db.showDB();
      WriteLine();
      WriteLine();
    }
开发者ID:lxinghe,项目名称:681project4,代码行数:36,代码来源:TestExec.cs

示例15: GetByKey

 /// <summary>
 /// Get by GetByKey results are handled here and query constructed
 /// </summary>
 /// <param name="status"></param>
 /// <param name="doc"></param>
 /// <param name="key"></param>
 /// <param name="elem"></param>
 private void GetByKey(out bool status, ref XDocument doc, out int key, out DBElement<int, string> elem)
 {
     sb = new StringBuilder();
     key = int.Parse(doc.Descendants("Key").Select(i => i).Single().Value);
     WriteLine("\n..Getting the value for key {0} ..\n", key);
     elem = new DBElement<int, string>();
     status = query.getKey(db, key, out elem);
     sb.Append(String.Format(" Key:" + key));
     sb.AppendLine();
     sb.Append(String.Format(" Value:"));
     sb.AppendLine();
     WriteLine(sb.ToString());
     sb.Append(elem.showElement());
     doc.Descendants("Response").Select(i => i).Single().Value = sb.ToString();
 }
开发者ID:darshanmp,项目名称:Remote-NoSQL-DB,代码行数:22,代码来源:RequestHandler.cs


注:本文中的DBElement.showElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。