Example #1
0
        static void Main(string[] args)
        {
            ITracer       tracer         = new Tracer.Tracer();
            ISerializer   serializerJSON = new SerializerJSON();
            ISerializer   serializerXML  = new SerializerXML();
            IOutputWriter writer         = new OutputWriter.OutputWriter();

            //Process
            var test = new Foo(tracer);

            test.MyMethod();
            Thread thread = new Thread(test.MyMethod);

            thread.Start();
            thread.Join();

            //Serialize
            string       result = serializerXML.Serialize(tracer.GetTraceResult());
            StreamWriter fs     = new StreamWriter("test.xml");

            //Write
            writer.Write(result, fs);
            writer.Write(result);

            //Serialize
            result = serializerJSON.Serialize(tracer.GetTraceResult());
            StreamWriter fs2 = new StreamWriter("test.json");

            //Write
            writer.Write(result, fs2);
            writer.Write(result);

            fs.Close();
            fs2.Close();
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            object p = services.AddControllers().AddNewtonsoftJson();
            var    appSettingsSections = Configuration.GetSection("AppSettings");
            var    appSettings         = appSettingsSections.Get <CieloApiCredencialsModel>();

            services.AddSingleton(new Merchant(appSettings.CieloId, appSettings.CieloKey));
            ISerializerJSON json = new SerializerJSON();

            services.AddSingleton(new CieloApi(CieloEnvironment.SANDBOX, Merchant.SANDBOX, json));
        }
Example #3
0
        private async Task <HttpResponseMessage> CreateRequestAsync <T>(string resource, T value, Method method = Method.POST, IDictionary <string, string> headers = null)
        {
            StringContent content = null;

            if (value != null)
            {
                string json = SerializerJSON.Serialize <T>(value);
                content = new StringContent(json, Encoding.UTF8, "application/json");
            }

            return(await ExecuteAsync(resource, headers, method, content));
        }
Example #4
0
        public void ConfigEnvironment()
        {
            ISerializerJSON json = new SerializerJSON();

            _api         = new CieloApi(CieloEnvironment.SANDBOX, Merchant.SANDBOX, json);
            _validDate   = DateTime.Now.AddYears(1);
            _invalidDate = DateTime.Now.AddYears(-1);

            _nome       = "Hugo Alves";
            _nomeCartao = "Hugo de Brito V R Alves";
            _descricao  = "Teste Cielo";
        }
Example #5
0
        private async Task <T> GetResponseAsync <T>(HttpResponseMessage response)
        {
            await CheckResponseAsync(response);

            return(SerializerJSON.Deserialize <T>(response.Content));
        }