Static class containing some static helper method used during example execution.
        /// <summary>
        /// This example shows how the repository discard semanticless words.
        /// </summary>
        public static void CleanTagExample()
        {
            ExampleHelper.ExampleMethodPrint("Clean a string from semanticless words", MethodInfo.GetCurrentMethod());
            string example1 = "The wind of change";

            Console.WriteLine("\"" + example1 + "\" => \"" + _repository.DiscardSemanticlessWords(example1) + "\"");
        }
示例#2
0
 /// <summary>
 /// Access method that will be executed by <c>ProgrammingExamples</c> and runs all the example method of the set.
 /// </summary>
 public static void RunExamples()
 {
     ExampleHelper.ExampleSetPrint("Tag Examples", typeof(TagExamples));
     //TagReadAndWrite();
     CompleteTagReadAndWrite();
     //CompleteToLightTag();
 }
        /// <summary>
        /// This example shows how to refreash a resource inside the repository.
        /// </summary>
        public static void RefreshExample()
        {
            ExampleHelper.ExampleMethodPrint("Refresh a previously loaded tag", MethodInfo.GetCurrentMethod());
            _repository.RefreshResource(tag.TagHash, new Uri("http://localhost:18292"), DateTime.Now.AddHours(1));
            KademliaResource rs = _repository.Get(tag.TagHash);

            ExampleHelper.DumpObjectProperties(rs);
        }
        /// <summary>
        /// This example uses the <c>Store</c> method to insert a new resource in the repository
        /// </summary>
        public static void StoreExample()
        {
            ExampleHelper.ExampleMethodPrint("Store a Tag and linking it with a peer URI", MethodInfo.GetCurrentMethod());
            _repository.StoreResource(tag, new Uri("http://*****:*****@"..\..\Resource\SevenMP3.mp3");

            _repository.StoreResource(anotherTag, new Uri("http://localhost:28182"), DateTime.Now);
        }
        /// <summary>
        /// This example show how to perform research inside the repository
        /// </summary>
        public static void SearchExample()
        {
            ExampleHelper.ExampleMethodPrint("Trying to Search for Tags with a search Query", MethodInfo.GetCurrentMethod());
            string query = "cross";

            KademliaResource[] results = _repository.SearchFor(query);
            foreach (KademliaResource rs in results)
            {
                ExampleHelper.DumpObjectProperties(rs);
            }
        }
        /// <summary>
        /// This example use the <c>GetAll</c> method to show all object contained in the repository
        /// </summary>
        private static void GetAllExample()
        {
            ExampleHelper.ExampleMethodPrint("Print all KademliaResource in the repository", MethodInfo.GetCurrentMethod());
            LinkedList <KademliaResource> coll = _repository.GetAllElements();

            foreach (KademliaResource res in coll)
            {
                ExampleHelper.DumpObjectProperties(res);
                Console.WriteLine();
            }
        }
示例#7
0
        /// <summary>
        /// This example shows how to build a <c>CompleteTag</c> and a <c>LightTag</c>.
        /// </summary>
        private static void CompleteToLightTag()
        {
            ExampleHelper.ExampleMethodPrint("Generating Light Tag from Complete Tag and Read it", MethodInfo.GetCurrentMethod());
            CompleteTag tag = new CompleteTag(@"..\..\Resource\SevenMP3.mp3");

            Console.WriteLine("Read info from Complete Tag");
            Console.WriteLine("Title: " + tag.Title);
            Console.WriteLine("Artist: " + tag.Artist);
            Console.WriteLine("Album: " + tag.Album);
            LightTag miniTag = new LightTag(tag);

            Console.WriteLine("Read info from Light Tag");
            Console.WriteLine("Title. " + miniTag.Title);
            Console.WriteLine("Artist: " + miniTag.Artist);
            Console.WriteLine("Album: " + miniTag.Album);
            Console.WriteLine("Raw Byte Length: " + miniTag.RawData.Length);
            Console.WriteLine("Raw Byte : " + miniTag.ToString());
        }
示例#8
0
        /// <summary>
        /// This example shows how to read complete tag from file and write it to the console.
        /// </summary>
        private static void CompleteTagReadAndWrite()
        {
            ExampleHelper.ExampleMethodPrint("Generating Complete Tag From File and Read it", MethodInfo.GetCurrentMethod());
            CompleteTag tag = new CompleteTag(@"..\..\Resource\SevenMP3.mp3");

            Console.WriteLine("Hash: " + tag.FileHash);
            Console.WriteLine("Title: " + tag.Title);
            Console.WriteLine("Artist: " + tag.Artist);
            Console.WriteLine("Album: " + tag.Album);
            Console.WriteLine("Genre: " + tag.Genre);
            Console.WriteLine("Year: " + tag.Year);
            Console.WriteLine("Track: " + tag.Track);
            Console.WriteLine("Length: " + tag.Length);
            Console.WriteLine("File Size: " + tag.FileSize);
            Console.WriteLine("Channels: " + tag.Channels);
            Console.WriteLine("Bitrate: " + tag.Bitrate);
            Console.WriteLine("Sample Rate: " + tag.SampleRate);
            //Console.WriteLine("Specific Tag: " + tag.SpecificTag.GetType().FullName);
        }
示例#9
0
        /// <summary>
        /// This example shows how to read light tag from byte array and write it to the console.
        /// </summary>
        private static void TagReadAndWrite()
        {
            ExampleHelper.ExampleMethodPrint("Tag Read and Write Example", MethodInfo.GetCurrentMethod());
            LightTag tag = new LightTag();

            int[] ret = tag.SetTagData(
                "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
                "123456789012345678901234567890",
                "123456789012345678901234567890");
            Console.WriteLine("Sizes of value set");
            foreach (int i in ret)
            {
                Console.Write(i);
                Console.Write(" ");
            }
            Console.WriteLine("\nValues read");
            Console.WriteLine(tag.Title);
            Console.WriteLine(tag.Artist);
            Console.WriteLine(tag.Album);
        }
 /// <summary>
 /// This example uses the <c>DeleteTag</c> method to delete a tag from the repository
 /// </summary>
 public static void DeleteExample()
 {
     ExampleHelper.ExampleMethodPrint("Delete a previously loaded tag", MethodInfo.GetCurrentMethod());
     Console.WriteLine("Delete Result: " + _repository.DeleteTag(tag.TagHash));
 }