示例#1
0
        static void Main(string[] args)
        {
            // Using class on a Library project
            MyMath calculo = new MyMath();
            double value   = calculo.Soma(20, 50);

            // Using struct
            MyStruct newStruct = new MyStruct("Teste");

            // Passagem de Parâmetro - Valor
            double number = 20;

            Console.WriteLine("Valor Inicial: " + number);
            AlterarValor(number);
            Console.WriteLine("Valor 'Alterado': " + number);

            // Passagem de Parâmetro - Referência
            Console.WriteLine("\nValor Inicial: " + number);
            RefAlterarValor(ref number);
            Console.WriteLine("Valor Alterado: " + number);

            // Passagem de Parâmetro - Out
            Console.WriteLine("\nValor Inicial: " + number);
            OutAlterarValor(out number);
            Console.WriteLine("Valor Alterado: " + number);

            // Passagem de Parâmetro - Params
            ManyEntries01("Mateus", "Marcos", "Lucas");
            string[] names = { "Mateus", "Marcos", "Lucas", "João" };
            ManyEntries02(names);
            ManyEntries03("Mateus", "Marcos", "Lucas", "João", "Evangelhos");

            // Testes JSON
            HandlerJSON jsonTest = new HandlerJSON();

            jsonTest.ExtractJsonData(jsonPath);

            // Throwing Personalized Exception
            try {
                throw new MyException("10");
            } catch (MyException ex) {
                Console.WriteLine(ex.Message);
            }

            // Showing project results
            Console.WriteLine("\nReference different project. Sum of values = " + value);
            Console.WriteLine("\nFirst use of structs. Struct name: " + newStruct.Name);

            // Desired output
            // "{ \"service_id\" : \"5c48a0ae585a6bf74393b81f\", \"month\" : 5 , \"count\" : 7083, \"month\" : 5 }"
            Console.WriteLine("");
            String input = "{{ \"id\" : {\"service_id\": ObjectId(\"5c48a0ae585a6bf74393b81f\"), \"month\": 5}, \"count\":7083, \"month\": 5}}";

            Console.WriteLine("Input String: " + input);
            String output = input.Replace("{ \"id\" : {", " ").Replace("ObjectId(", "").Replace(")", "").Replace("}}", "}").Replace("},", ",");

            Console.WriteLine("Output String: " + output);

            Console.ReadKey();
        }
示例#2
0
 protected override void MessageJSON(string message)
 {
     try
     {
         if (message != null)
         {
             HandlerJSON?.Invoke(message);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
示例#3
0
 protected override void MessageJSON(string message)
 {
     try
     {
         if (message != null)
         {
             HandlerJSON?.Invoke(message);
             //if (result.HasValue && result.Value)
             //{
             //    using (var c = new ConfirmMessage(this.keyAccess, this.privateKey))
             //    {
             //        c.Ok(message.ID, message.To);
             //    }
             //}
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }