Skip to content

Instantly share code, notes, and snippets.

View morales-franco's full-sized avatar

Franco morales-franco

  • Argentina
View GitHub Profile
@morales-franco
morales-franco / c10.cs
Created April 20, 2019 16:27
customSectionInAppConfigs
using System.Configuration;
namespace JungleApp.Batch.Infraestructure
{
//Configuration of AppCountriesSection in the app.config
class ConfigurationAppCountriesSection : ConfigurationSection
{
private const string _CountriesCollectionName = "Countries";
[ConfigurationProperty(_CountriesCollectionName)]
public ICommunicator GetCommunicator(string typeName)
{
Type communicatorType = Type.GetType(typeName);
if (communicatorType == null)
throw new NullReferenceException();
ICommunicator communicator = Activator.CreateInstance(communicatorType, new object[] { new ConnectionParameters()
{
IP = "My IP",
Thread.CurrentThread.CurrentCulture = new CultureInfo("es-ES");
string valueToConvert = "24/12/2020 23:50";
Console.WriteLine($"(1) Change Current Culture to { Thread.CurrentThread.CurrentCulture.Name }");
Console.WriteLine($"(1) Try to convert { valueToConvert } using { Thread.CurrentThread.CurrentCulture.Name } culture - Default Culture Format [dd/MM/yyyy]...");
var parseValue = Convert.ToDateTime(valueToConvert);
Console.WriteLine("-->Success!");
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
try