/// <summary> /// Gets the modeler specified in the provided Settings. /// </summary> /// <param name="settings">The code generation settings</param> /// <returns>Modeler specified in Settings.Modeler</returns> public static Modeler GetModeler() { Logger.Instance.Log(Category.Info, Resources.InitializingModeler); if (Settings.Instance == null) { throw new ArgumentNullException("settings", "settings or settings.Modeler cannot be null."); } if (string.IsNullOrEmpty(Settings.Instance.Modeler)) { throw new ArgumentException( string.Format(CultureInfo.InvariantCulture, Resources.ParameterValueIsMissing, "Modeler")); } Modeler modeler = null; var config = AutoRestConfiguration.Get(); modeler = LoadTypeFromAssembly <Modeler>(config.Modelers, Settings.Instance.Modeler); Settings.PopulateSettings(modeler, Settings.Instance.CustomSettings); Logger.Instance.Log(Category.Info, Resources.ModelerInitialized, Settings.Instance.Modeler, modeler.GetType().GetAssembly().GetName().Version); return(modeler); }
public static IAnyPlugin GetPlugin(string pluginName = null) { if (pluginName == null) { pluginName = Settings.Instance.CodeGenerator; } Logger.Instance.Log(Category.Info, Resources.InitializingCodeGenerator); if (string.IsNullOrEmpty(pluginName)) { throw new ArgumentException( string.Format(CultureInfo.InvariantCulture, Resources.ParameterValueIsMissing, "CodeGenerator")); } IAnyPlugin plugin = null; if (pluginName.EqualsIgnoreCase("None")) { plugin = new NoOpPlugin(); } else { var config = AutoRestConfiguration.Get(); plugin = LoadTypeFromAssembly <IAnyPlugin>(config.Plugins, pluginName); Settings.PopulateSettings(plugin.Settings, Settings.Instance.CustomSettings); } Logger.Instance.Log(Category.Info, Resources.GeneratorInitialized, pluginName, plugin.GetType().GetAssembly().GetName().Version); return(plugin); }