Пример #1
0
    public static TSettingsManager New <TSettingsManager>(IConfigurationManager manager = null)
    {
        if (manager == null)
        {
            manager = SettingsContext.Current.Manager ?? throw new ArgumentNullException(nameof(manager), ERRORMSG);
        }

        try
        {
            return(Creator <TSettingsManager> .BuildNewInstance(manager));
        }
        catch (TypeInitializationException ex) when(ex.InnerException != null)
        {
            //Catch the exception our Creator CTOR throws and unwrap it.
            ExceptionDispatchInfo.Capture(ex.InnerException).Throw();

            throw; //Won't execute but needed to keep the compiler happy.
        }
    }