Пример #1
0
    public static void Main()
    {
        // Create a new instance of the class.
        QueueExample example = new QueueExample();

        // Create a nontransactional queue on the local computer.
        CreateQueue(".\\exampleQueue", false);

        example.UseQueue();

        return;
    }
Пример #2
0
    public static void Main()
    {
        // Create a new instance of the class.
        QueueExample example = new QueueExample();

        try
        {
            // Create a nontransactional queue on the local computer.
            // Note that the queue might not be immediately accessible, and
            // therefore this example might throw an exception of type
            // System.Messaging.MessageQueueException when trying to send a
            // message to the newly created queue.
            CreateQueue(".\\exampleQueue", false);

            // Create a nontransactional queue on the local computer. This
            // queue will be used to receive acknowledgement messages.
            CreateQueue(".\\exampleAdminQueue", false);

            // Create a transactional queue on the local computer.
            CreateQueue(".\\exampleTransQueue", true);

            // Send a message to a queue.
            example.Send_ObjectString();

            // Send a message to a transactional queue.
            example.Send_ObjectTransactiontype();

            // Send a message to a transactional queue.
            example.Send_ObjectStringTransactiontype();

            // Send a message to a transactional queue.
            example.Send_ObjectStringTransaction();

            // Demonstrate PeekById.
            example.PeekById_String();

            // Demonstrate PeekById.
            example.PeekById_StringTimespan();

            // Demonstrate PeekByCorrelationId.
            example.PeekByCorrelationId_StringTimespan();

            // Receive a message from a transactional queue.
            example.Receive_TimespanTransactiontype();

            // Receive a message from a transactional queue.
            example.Receive_Transactiontype();

            // Demonstrate ReceiveByCorrelationId.
            example.ReceiveByCorrelationId_StringTimespan();

            // Demonstrate ReceiveByCorrelationId.
            example.ReceiveByCorrelationId_StringTransactiontype();

            // Demonstrate ReceiveByCorrelationId.
            example.ReceiveByCorrelationId_StringTimespanTransactiontype();

            // Demonstrate ReceiveByCorrelationId.
            example.ReceiveByCorrelationId_StringTimespanTransaction();

            // Demonstrate ReceiveByCorrelationId.
            example.ReceiveByCorrelationId_StringTransaction();

            // Demonstrate ReceiveById.
            example.ReceiveById_StringTransactionType();

            // Demonstrate ReceiveById.
            example.ReceiveById_String();

            // Demonstrate ReceiveById.
            example.ReceiveById_StringTransaction();

            // Demonstrate ReceiveById.
            example.ReceiveById_StringTimespanTransaction();

            // Demonstrate ReceiveById.
            example.ReceiveById_StringTimespanTransactiontype();

            // Demonstrate ReceiveById.
            example.ReceiveById_StringTimespan();

            // Demonstrate GetAllMessages.
            example.GetAllMessages();

            // Demonstrate GetEnumerator.
            example.GetEnumerator();

            // Demonstrate SetPermissions.
            example.SetPermissions_StringAccessrights();

            // Demonstrate SetPermissions.
            example.SetPermissions_Accesscontrolentry();

            // Demonstrate SetPermissions.
            example.SetPermissions_StringAccessrightsAccesscontrolentrytype();

            // Demonstrate SetPermissions.
            example.SetPermissions_Accesscontrollist();

            // Demonstrate ResetPermissions.
            example.ResetPermissions();

            // Demonstrate Refresh.
            example.Refresh();

            // Demonstrate Purge.
            example.Purge();
        }
        catch (System.Exception e)
        {
            // Write the exception information to the console.
            Console.WriteLine(e);
        }
    }
Пример #3
0
        public static void Main(string[] args)
        {
            var numbers = new List <int>()
            {
                1, 5, 6, 5, 8, 4, 1, 5
            };                                             //ListExample
            var names = new HashSet <string>()
            {
                "Aditya", "Aditya", "Sharma"
            };                                                               //demonstation of hashset where it does not accepts duplicate values
            var decivalue = new SortedSet <double>()
            {
                1.2, 5.6, 6.3, 0.3, 5, 8, 4.2, 1, 5
            };                                                                             //sortedset Example
            BlockingCollection <int> bCollection = new BlockingCollection <int>(10);

            bCollection.Add(1);
            bCollection.Add(2);
            foreach (int item in bCollection.GetConsumingEnumerable())
            {
                Console.WriteLine(item);
            }

            foreach (var a in decivalue)
            {
                Console.WriteLine(a);
            }
            Console.WriteLine("\n");
            foreach (var n in numbers)
            {
                Console.WriteLine(n);
            }
            Console.WriteLine("\n");
            foreach (var name in names)
            {
                Console.WriteLine(name);
            }

            Console.WriteLine("\n");

            StackExample s = new StackExample();

            s.Fnames.Push("Aditya");
            s.Fnames.Push("Narayan");
            s.Fnames.Push("Sharma");
            foreach (var Fname in s.Fnames)
            {
                Console.WriteLine(Fname);
            }
            Console.WriteLine("Peek Element is:" + s.Fnames.Peek());
            Console.WriteLine("Poping the peek Element:" + s.Fnames.Pop());
            Console.WriteLine("Peek Element is:" + s.Fnames.Peek());

            Console.WriteLine("\n");
            QueueExample q = new QueueExample();

            q.Lnames.Enqueue("Sharma");
            q.Lnames.Enqueue("Reddy");
            q.Lnames.Enqueue("Naidu");
            foreach (var Lname in q.Lnames)
            {
                Console.WriteLine(Lname);
            }
            Console.WriteLine("Peek Element is:" + q.Lnames.Peek());
            Console.WriteLine("Poping the peek Element:" + q.Lnames.Dequeue());
            Console.WriteLine("Peek Element is:" + q.Lnames.Peek());

            Console.WriteLine("\n");

            var nodes = new LinkedList <string>(); //Creating a linked list of string

            nodes.AddLast("Taj Mahal");
            nodes.AddLast("Qutur Minar");
            nodes.AddLast("Ganga River");
            nodes.AddFirst("Golden Temple");

            foreach (var a in nodes)
            {
                Console.WriteLine(a); //Demonstrating the AddFirst and AddLast methods
            }
            Console.WriteLine("\n");
            //I want to insert new element between Ganga River
            LinkedListNode <string> node = nodes.Find("Ganga River");

            nodes.AddBefore(node, "Laxman Jula");
            nodes.AddAfter(node, "Ram Jula");

            foreach (var c in nodes)
            {
                Console.WriteLine(c);
            }
            //DictionaryExample
            DictionaryExample dic = new DictionaryExample();

            dic.Employee.Add("101", "Sonoo");
            dic.Employee.Add("202", "Peter");
            dic.Employee.Add("303", "James");
            dic.Employee.Add("404", "Ratan");
            dic.Employee.Add("505", "Irfan");

            Console.WriteLine("\n");
            foreach (KeyValuePair <string, string> kv in dic.Employee)
            {
                Console.WriteLine("Key:" + kv.Key + "Vlaue:" + kv.Value);
            }
            //SortedList Example
            SortedListExample Sl = new SortedListExample();

            Sl.students.Add(5, "Aditya");
            Sl.students.Add(6, "Daksh");
            Sl.students.Add(7, "Aditya M");
            Sl.students.Add(3, "Chetan");
            Sl.students.Add(10, "Ajay");

            Console.WriteLine("\n");
            foreach (KeyValuePair <int, string> sll in Sl.students)
            {
                Console.WriteLine(sll.Key + " " + sll.Value);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            //Which example to run
            var exampleToRun = Examples.ArrayListInitialization;

            switch (exampleToRun)
            {
            case Examples.ArrayListShow:
                ArrayListExample.ShowArrayList();
                break;

            case Examples.ArrayListIntergers:
                ArrayListExample.UseIntegers();
                break;

            case Examples.ArrayListDelete:
                ArrayListExample.DeleteElement();
                break;

            case Examples.ArrayListInitialization:
                ArrayListExample.ConstructorInitialization();
                break;

            case Examples.StackShow:
                StackExample.ShowStack();
                break;

            case Examples.StackPop:
                StackExample.PopElement();
                break;

            case Examples.StackPeek:
                StackExample.PeekElement();
                break;

            case Examples.QueueShow:
                QueueExample.ShowQueue();
                break;

            case Examples.QueueDequeue:
                QueueExample.DequeueElement();
                break;

            case Examples.QueuePeek:
                QueueExample.PeekElement();
                break;

            case Examples.HashtableShow:
                HashTableExample.ShowHashTable();
                break;

            case Examples.HashtablePrintKeys:
                HashTableExample.PrintKeys();
                break;

            case Examples.HashtableValueByKey:
                HashTableExample.GetValueByKey();
                break;

            case Examples.HashtableDuplicateKeys:
                HashTableExample.DuplicateKeys();
                break;

            case Examples.HashtableDuplicateValues:
                HashTableExample.DuplicateValues();
                break;

            case Examples.HashtableInitialization:
                HashTableExample.ConstructorInitialization();
                break;

            default:
                break;
            }

            Console.Read();
        }
Пример #5
0
        static void Main(string[] args)
        {
            var exampleToRun = Examples.HashSetShow;

            switch (exampleToRun)
            {
            // task 1 Collections
            case Examples.ArrayListShow:
                ArrayListExample.ShowArrayList();
                break;

            case Examples.ArrayListShowTo:
                ArrayListExample.ShowArrayListTo();
                break;

            case Examples.StackPush:
                Stack.PushStack();
                break;

            case Examples.StackPop:
                Stack.PopElement();
                break;

            case Examples.QueueShow:
                QueueExample.ShowQueue();
                break;

            case Examples.QueueDelete:
                QueueExample.DequeueElement();
                break;

            case Examples.QueuePeek:
                QueueExample.PeekElement();
                break;

            case Examples.HashtableShow:
                HashTableExample.ShowHashTable();
                break;

            case Examples.HashtablePrintKeys:
                HashTableExample.PrintKeys();
                break;

            case Examples.HashtableValueByKey:
                HashTableExample.GetValueByKey();
                break;

            case Examples.HashtableDuplicateKeys:
                HashTableExample.DuplicateKeys();
                break;

            case Examples.HashtableDuplicateValues:
                HashTableExample.DuplicateValues();
                break;

            case Examples.HashtableInitialization:
                HashTableExample.ConstructorInitialization();
                break;

            // task 1 GenericCollections
            case Examples.ListShow:
                ListExample.ShowList();
                break;

            case Examples.ListCompileError:
                ListExample.CompileError();
                break;

            case Examples.GenericStackShow:
                GenericStackExample.ShowGenericStack();
                break;

            case Examples.GenericStackCompileError:
                GenericStackExample.CompileError();
                break;

            case Examples.GenericQueueShow:
                GenericQueueExample.ShowGenericQueue();
                break;

            case Examples.GenericQueueCompileError:
                GenericQueueExample.CompileError();
                break;

            case Examples.HashSetShow:
                HashSetExample.ShowHashSet();
                break;

            case Examples.HashSetContainsRemove:
                HashSetExample.ContainsAndRemove();
                break;

            case Examples.HashSetUnion:
                HashSetExample.UnionSets();
                break;

            case Examples.HashSetExcept:
                HashSetExample.ExceptSets();
                break;

            case Examples.HashSetIntersect:
                HashSetExample.IntersectSets();
                break;

            // task 2 Dictionary
            case Examples.DictionaryShow:
                DictionaryExample.ShowDictionary();
                break;

            case Examples.DictionaryDelete:
                DictionaryExample.DeleteDictionary();
                break;

            // task 3 Linked list
            case Examples.LinkedListShow:
                LinkedListExample.ShowLinkedList();
                break;

            case Examples.LinkedListRemoveNode:
                LinkedListExample.RemoveNode();
                break;

            default:
                break;
            }

            Console.Read();
        }
Пример #6
0
        static void Main(string[] args)
        {
            //List Example
            //List<Customer> customers = new List<Customer>();
            //Customer mike = new Customer() { Name = "Mike", Age = 29 };
            //customers.Add(mike);

            //Linked List Example
            //Console.WriteLine("Linked List");
            //SingleLinkedList singleLinkedList = new SingleLinkedList();
            //singleLinkedList.CreateList();
            //singleLinkedList.Menu();


            //Sorted List Example
            //Console.WriteLine("Sorted List");
            //EmployeeTracker employeeTracker = new EmployeeTracker();
            //employeeTracker.DisplayEmployeesNameAge();

            //Observable Collection Example
            //Console.WriteLine("Observable Collection");
            //MovieTracker movieTracker = new MovieTracker();
            //movieTracker.GetFastFuriousFilmCollection();

            //Dictionary
            //Console.WriteLine("Dictionary");
            //DictionaryExamples dictionaryExamples = new DictionaryExamples();
            //dictionaryExamples.DisplayAnimalCategorization();
            //dictionaryExamples.DisplayMonthSeason();
            //dictionaryExamples.DisplayEmployeeIdName();

            //HashSet
            //Console.WriteLine("Hash Set");
            //CountriesTracker countriesTracker = new CountriesTracker();
            //countriesTracker.CheckHasCountries();

            //Stack
            //Console.WriteLine("Stack");
            //StackExample stack = new StackExample();
            //stack.PushOnToStack();

            //Queue
            Console.WriteLine("Queue");
            QueueExample queue = new QueueExample();

            queue.EnqueueOnQueue();

            ////Binary Tree
            ////ASCII characters table: https://www.dotnetperls.com/ascii-table
            Console.WriteLine("Binary Tree");
            DataStructuresCode.BinaryTree.BinaryTree binaryTree = new DataStructuresCode.BinaryTree.BinaryTree();
            binaryTree.CreateTree();
            binaryTree.Display();
            Console.WriteLine();

            //Pre-order starts at root and works its way down left side of tree
            Console.WriteLine("Pre-order: ");
            binaryTree.PreOrder();
            Console.WriteLine("");

            //In-order starts at the farthest-left node and works its way to the farthest-right
            Console.WriteLine("In-order: ");
            binaryTree.InOrder();
            Console.WriteLine();

            //Post-order starts with the farthest-left tree and works its way to the root tree-by-tree
            Console.WriteLine("Post-order: ");
            binaryTree.PostOrder();
            Console.WriteLine();

            //Level-order works its way node-to-node by level
            Console.WriteLine("Level order: ");
            binaryTree.LevelOrder();
            Console.WriteLine();

            Console.WriteLine($"Height of tree is {binaryTree.Height()}");
        }
Пример #7
0
 /// <summary>
 /// Awake is called when the script instance is being loaded.
 /// </summary>
 void Awake()
 {
     instance = this;
 }