/// <summary> /// Convert enum to wire format /// </summary> private byte _ToValue(DateFormatType value) { switch (value) { case DateFormatType.MonthDayYear: { return(1); } case DateFormatType.DayMonthYear: { return(2); } case DateFormatType.YearMonthDay: { return(3); } case DateFormatType.YearDayMonth: { return(4); } case DateFormatType.MonthYearDay: { return(5); } case DateFormatType.DayYearMonth: { return(6); } default: { throw new Exception("Unrecognized date format " + value.ToString()); } } }
/// <summary> /// Convert enumeration to string /// </summary> public static string ToString(DateFormatType value) { // Switch through the langauges switch (value) { case DateFormatType.DayMonthYear: { return(DayMonthYear); } case DateFormatType.DayYearMonth: { return(DayYearMonth); } case DateFormatType.MonthDayYear: { return(MonthDayYear); } case DateFormatType.MonthYearDay: { return(MonthYearDay); } case DateFormatType.YearDayMonth: { return(YearDayMonth); } case DateFormatType.YearMonthDay: { return(YearMonthDay); } } // Unknown value throw new Exception("Unrecognized date format type \"" + value.ToString() + "\""); }
private static NSerializer GetSerializerAs(FieldFormatterType type, FieldAccessType accessType, DateFormatType dateFormatType, bool withNulls) { var currentDirectory = Directory.GetParent(Directory.GetCurrentDirectory()); var config = new Dictionary <string, object> { { ConfigurationManager.MetadataDirKey, Path.Combine(currentDirectory.Parent?.Parent?.ToString(), "Resources") }, { ConfigurationManager.IncludeNullValuesKey, withNulls }, { ConfigurationManager.FieldFormattingMethodKey, type.ToString() }, { ConfigurationManager.FieldAccessTypeKey, accessType.ToString() }, { ConfigurationManager.DateFormatKey, dateFormatType.ToString() } }; var configurationProvider = new MockConfigurationProvider(config); var environment = new MockEnvironment(); var cache = new MockCache(); return(NSerializerBuilder.Build() .WithCache(cache) .WithConfigurationProvider(configurationProvider) .WithEnvironment(environment) .Get()); }
/// <summary> /// Convert enumeration to string /// </summary> public static string ToString(DateFormatType value) { // Switch through the langauges switch (value) { case DateFormatType.DayMonthYear: { return DayMonthYear; } case DateFormatType.DayYearMonth: { return DayYearMonth; } case DateFormatType.MonthDayYear: { return MonthDayYear; } case DateFormatType.MonthYearDay: { return MonthYearDay; } case DateFormatType.YearDayMonth: { return YearDayMonth; } case DateFormatType.YearMonthDay: { return YearMonthDay; } } // Unknown value throw new Exception("Unrecognized date format type \"" + value.ToString() + "\""); }
/// <summary> /// Convert enum to wire format /// </summary> private byte _ToValue(DateFormatType value) { switch (value) { case DateFormatType.MonthDayYear: { return 1; } case DateFormatType.DayMonthYear: { return 2; } case DateFormatType.YearMonthDay: { return 3; } case DateFormatType.YearDayMonth: { return 4; } case DateFormatType.MonthYearDay: { return 5; } case DateFormatType.DayYearMonth: { return 6; } default: { throw new Exception("Unrecognized date format " + value.ToString()); } } }