Below are the changes which I did it in my application. Added FeatureToggle package in the code. And Created New Printing Class(Sample class only for) Extending SimpleFeatureToggle.
using FeatureToggle;
namespace AspDotNetCoreExample.Models
{
public class Printing : SimpleFeatureToggle {}
}
appSettings.json added featureToggle Key and it is set as true. So the Printing class will read it and enable feature toggling.
{
"FeatureToggle": {
"Printing": "true"
}
}
** Startup.cs Registered my Printing Service in ConfigureServices Method. I have passed the configuration file(appSettings.json) into Printing class.
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
// Set provider config so file is read from content root path
var provider = new AppSettingsProvider { Configuration = Configuration };
services.Configure<AppSettings(Configuration.GetSection("AppSettings"));
services.AddSingleton(new Printing { ToggleValueProvider = provider });
services.AddTransient<IMapper, Mapper>();
// Add framework services.
services.AddMvc();
}
// In Mapper Class, to check the feature toggle is enabled or not and to enable the features.
namespace STAR.Marketing.Portal.Web
{
public class Mapper: Mapper
{
private readonly Printing _print;
public Mapper(Printing print) //Dependency Injection to get Printing
{
_print = print;
}
public string Enabled()
{
return _print.FeatureEnabled; // To check the feature is enabled but getting the Error System.FileIOException
}
}
}
What are the mistakes I have done in the above code? Why I am getting this error in my code, System.FileIOException.?