I want to convert Deserialize my static class with json setting file.
public class Welcome
{
public ConfigurationProvider ConfigurationProvider { get; set; }
}
[JsonObject(MemberSerialization.OptIn)]
public class ConfigurationProvider
{
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public static AppConfig Rcom { get; }
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public static AppConfig Ccst { get; }
static ConfigurationProvider()
{
Rcom=new AppConfig("RCOM");
Ccst=new AppConfig("CCST");
}
}
public class AppConfig
{
public GarConfiguration GarConfiguration { get; }
public VacationRentalRedisKeysConfiguration VacationRentalRedisKeysConfiguration { get; }
public AppConfig(string type)
{
if (type == "RCOM")
{
GarConfiguration = new GarConfiguration(type);
VacationRentalRedisKeysConfiguration = new VacationRentalRedisKeysConfiguration
{
DefaultVacationRentalThemeKey = "RcomKey",
CheckVacationRentalThemeKey=true
};
}
else
{
GarConfiguration = new GarConfiguration(type);
VacationRentalRedisKeysConfiguration = new VacationRentalRedisKeysConfiguration
{
DefaultVacationRentalThemeKey = "CCSTKey",
CheckVacationRentalThemeKey=false
};
}
}
}
public class GarConfiguration
{
public GarSearch GarSearch { get; }
public GarConfiguration(string type)
{
if (type == "RCOM")
{
GarSearch = new GarSearch
{
RequestSplitedMinCount = 40,
RequestSplitedCount = 5,
RequestSplitedMaxTimeOutInMilliSecond = 3000,
RequiredSplitedRequest = true,
RequiredSplitedRequestMaxTimeOut = true,
AppName = type
};
}
else
{
GarSearch = new GarSearch
{
RequestSplitedMinCount = 40,
RequestSplitedCount = 5,
RequestSplitedMaxTimeOutInMilliSecond = 5000,
RequiredSplitedRequest = true,
RequiredSplitedRequestMaxTimeOut = true,
AppName = type
};
}
}
}
public class GarSearch
{
public long RequestSplitedMinCount { get; set; }
public long RequestSplitedCount { get; set; }
public long RequestSplitedMaxTimeOutInMilliSecond { get; set; }
public bool RequiredSplitedRequest { get; set; }
public bool RequiredSplitedRequestMaxTimeOut { get; set; }
public string AppName { get; set; }
}
public class VacationRentalRedisKeysConfiguration
{
public bool CheckVacationRentalThemeKey { get; set; }
public string DefaultVacationRentalThemeKey { get; set; }
}
Above is my sample class.
I need this config because if I am not getting the JSON setting file then it runs from this default setting else it will run from that JSON setting file.
I need this static because not want to create multiple instance for this.
when I Deserialize my class I get result like class Deserialize proeprly but not able to access static member Not able to get static memeber values