ExampleMethodPrint() public static method

This method prints on the Console the name of the example method
public static ExampleMethodPrint ( string message, MethodBase method ) : void
message string Description of the actions executed by the example
method System.Reflection.MethodBase Method type for the example
return void
Ejemplo n.º 1
0
 /// <summary>
 /// This example shows how to instantiate a new raven repository
 /// </summary>
 public static void LoadRavenExample()
 {
     ExampleHelper.ExampleMethodPrint("Generate Raven Repository Instance", MethodInfo.GetCurrentMethod());
     Persistence.RepositoryConfiguration conf = new Persistence.RepositoryConfiguration(new { data_dir = "..\\..\\Resource\\Database" });
     _trackRep = Persistence.RepositoryFactory.GetRepositoryInstance("Raven", conf);
     Console.WriteLine(_trackRep.GetType().FullName + " - " + _trackRep.RepositoryType);
 }
        /// <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) + "\"");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method shows the use and the functionality of some repository methods.
        /// <c>
        /// Insert a new Track in the Database, Count all elements and the Load it all! Then delete a item and Load it all again
        /// </c>
        /// </summary>
        public static void InsertCountLoadAllDeleteAndLoadAgain()
        {
            ExampleHelper.ExampleMethodPrint("Insert a new Track in the Database, Count all elements and the Load it all!\n" +
                                             "Then delete a item and Load it all again", MethodInfo.GetCurrentMethod());
            TrackModel track = new TrackModel(@"..\..\Resource\Garden.mp3");

            ExampleHelper.DumpObjectProperties(track.GetAsDatabaseType());
            Console.WriteLine("Save Response : " + _trackRep.Save(track));
            Console.WriteLine("Count : " + _trackRep.Count <TrackModel.Track>());
            List <TrackModel.Track> list = new List <TrackModel.Track>();

            Console.WriteLine("GetAll Response : " + _trackRep.GetAll(list));
            foreach (TrackModel.Track t in list)
            {
                ExampleHelper.DumpObjectProperties(t);
            }
            TrackModel anotherTrack = new TrackModel();

            Console.WriteLine("Delete Response: " + _trackRep.Delete <TrackModel.Track>(list.First().Id));
            list.Clear();
            Console.WriteLine("GetAll Response : " + _trackRep.GetAll(list));
            foreach (TrackModel.Track t in list)
            {
                ExampleHelper.DumpObjectProperties(t);
            }
        }
        /// <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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This example shows how to save a track in a generic repository
        /// </summary>
        public static void StoreTrackInDb()
        {
            ExampleHelper.ExampleMethodPrint("Create a TrackModel from file and store it in the database", MethodInfo.GetCurrentMethod());
            TrackModel track = new TrackModel("..\\..\\Resource\\SevenMP3.mp3");

            _hid = track.GetAsDatabaseType().Id;
            ExampleHelper.DumpObjectProperties(track.GetAsDatabaseType());
            Console.WriteLine("Response : " + _trackRep.Save(track));
        }
        /// <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();
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// This example shows how to load from the repository a previously stored track.
        /// </summary>
        public static void LoadTrackFromDb()
        {
            ExampleHelper.ExampleMethodPrint("Load a TrackModel from the database", MethodInfo.GetCurrentMethod());
            TrackModel         track = new TrackModel();
            RepositoryResponse resp  = _trackRep.GetByKey <TrackModel.Track>(_hid, track);

            Console.WriteLine("Response : " + resp);
            if (resp >= 0)
            {
                ExampleHelper.DumpObjectProperties(track.GetAsDatabaseType());
            }
        }
        /// <summary>
        /// This example run <c>ContainsTag</c>, <c>ContainsUrl</c> and <c>GetPublicationTime</c> methods of the repository
        /// </summary>
        private static void MiscGetAndContainsExample()
        {
            ExampleHelper.ExampleMethodPrint("Show how some minor function of Get and Contains works", MethodInfo.GetCurrentMethod());
            bool resp = _repository.ContainsTag(tag.TagHash);

            Console.WriteLine("Contains Tag " + tag.TagHash + " ? " + resp);
            resp = _repository.ContainsTag("jasdkasjds");
            Console.WriteLine("Contains Tag jasdkasjds ? " + resp);
            Uri url = new Uri("http://localhost:18292");

            resp = _repository.ContainsUrl(tag.TagHash, url);
            Console.WriteLine("Resource " + tag.TagHash + " contains Url http://localhost:18292 ? " + resp);
            DateTime pubTime = _repository.GetPublicationTime(tag.TagHash, url);

            Console.WriteLine("Publication Time for Url " + url.ToString() + " on Resource " + tag.TagHash + " is " + pubTime);
        }
Ejemplo n.º 11
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());
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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 shows how to use the <c>Put</c> operation to insert new Dht element into an existing Resource
 /// </summary>
 private static void PutExample()
 {
     ExampleHelper.ExampleMethodPrint("Put a new DhtElement in a Resource", MethodInfo.GetCurrentMethod());
     _repository.Put(tag.TagHash, new Uri("http://127.0.0.1:18181"), DateTime.Now.AddDays(-1).AddHours(-1));
 }
 /// <summary>
 /// This test the <c>Expire</c> method of the repository
 /// </summary>
 private static void ExpireExample()
 {
     ExampleHelper.ExampleMethodPrint("Clean Expire Entity", MethodInfo.GetCurrentMethod());
     _repository.Expire();
 }
 /// <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));
 }