public LiveModelsProvider(ILogger logger, IModelsBuilderConfig config, ModelsGenerator modelGenerator, ModelsGenerationError mbErrors) { _logger = logger; _config = config ?? throw new ArgumentNullException(nameof(config)); _modelGenerator = modelGenerator; _mbErrors = mbErrors; }
static void Main(string[] args) { var builder = new ConfigurationBuilder(); builder.AddUserSecrets <Program>(); var configuration = builder.Build(); var root = configuration["root"]; var asmNames = new string[] { "QiaoDan.Core.dll", "QiaoDan.ViewModels.Abstractions.dll", "QiaoDan.Admin.ViewModels.dll", "QiaoDan.OA.Core.dll", "QiaoDan.OA.ViewModels.dll", "QiaoDan.HR.Core.dll", "QiaoDan.HR.ViewModels.dll", } ; ModelsGenerator.Generate( asmNames.Select(n => Assembly.LoadFrom(Path.Combine(root, n))).Append(typeof(Program).Assembly), "../ts.g", opt => { opt.TypeFilter = t => t.GetInterface("IViewModel") != null || t.IsEnum || (t.IsAbstract && t.IsSealed); opt.PropertyFilter = p => !p.GetCustomAttributes().Any(a => a.GetType().Name == "JsonIgnoreAttribute"); opt.CodeSnippets = t => { if (t.GetCustomAttributes().Any(a => a.GetType().Name == "DynamicValidateAttribute")) { return(@$ "static _assemblyName = " "{t.Assembly.GetName().Name}" "; static _className = " "{t.FullName}" ";");
public void Test() { var mgi = new ModelsGeneratorInput() { ClassName = "RuntimeGeneratedModel", //Convert to Param. Params = Params.ToParam().ToList() }; var modelGenerator = new ModelsGenerator( //Can build one or more models with one ModelsGenerator with common SourceFileContext. new ModelsGeneratorInput[] { mgi }, namespaceStr: "MyGeneratedNamespace", baseClassName: typeof(IRuntimeGeneratedModel).FullName ); var codeGenResult = modelGenerator.Generate(); //Register used type. codeGenResult.Context.UsedType(typeof(IRuntimeGeneratedModel)); var asm = codeGenResult.Compile(); var generatedType = asm.GetType("MyGeneratedNamespace.RuntimeGeneratedModel"); var generatedModel = (IRuntimeGeneratedModel)Activator.CreateInstance(generatedType); generatedModel.Num1 = 1; generatedModel.Num2 = 2; generatedModel.Num3 = 3; var res = MethodToInvoke( generatedModel.Num1, generatedModel.Num2, generatedModel.Num3 ); Assert.AreEqual(6, res); }
static void Main(string[] args) { var readerParameters = new ReaderParameters(); var result = readerParameters.ParseArguments(args); switch (result) { case ParserResult.Invalid: Console.Write(readerParameters.Usage); break; case ParserResult.Failure: Console.Write(readerParameters.ErrorMessage); break; case ParserResult.Success: try { ModelsGenerator.Generate(readerParameters); Console.WriteLine("Completed successfully."); } catch (Exception exception) { Console.WriteLine(exception.Message); Console.WriteLine(exception.StackTrace); } break; } Console.ReadKey(); }
public ModelsBuilderDashboardController(IOptions <ModelsBuilderSettings> config, ModelsGenerator modelsGenerator, OutOfDateModelsStatus outOfDateModels, ModelsGenerationError mbErrors) { _config = config.Value; _modelGenerator = modelsGenerator; _outOfDateModels = outOfDateModels; _mbErrors = mbErrors; _dashboardReport = new DashboardReport(config, outOfDateModels, mbErrors); }
public ModelsBuilderDashboardController(IModelsBuilderConfig config, ModelsGenerator modelsGenerator, OutOfDateModelsStatus outOfDateModels, ModelsGenerationError mbErrors) { //_umbracoServices = umbracoServices; _config = config; _modelGenerator = modelsGenerator; _outOfDateModels = outOfDateModels; _mbErrors = mbErrors; _dashboardReport = new DashboardReport(config, outOfDateModels, mbErrors); }
/// <summary> /// Initializes a new instance of the <see cref="AutoModelsNotificationHandler"/> class. /// </summary> public AutoModelsNotificationHandler( ILogger <AutoModelsNotificationHandler> logger, IOptions <ModelsBuilderSettings> config, ModelsGenerator modelGenerator, ModelsGenerationError mbErrors, IMainDom mainDom) { _logger = logger; _config = config.Value ?? throw new ArgumentNullException(nameof(config)); _modelGenerator = modelGenerator; _mbErrors = mbErrors; _mainDom = mainDom; }
/// <summary> /// Initializes a new instance of the <see cref="AutoModelsNotificationHandler"/> class. /// </summary> public AutoModelsNotificationHandler( ILogger <AutoModelsNotificationHandler> logger, IOptionsMonitor <ModelsBuilderSettings> config, ModelsGenerator modelGenerator, ModelsGenerationError mbErrors, IMainDom mainDom) { _logger = logger; //We cant use IOptionsSnapshot here, cause this is used in the Core runtime, and that cannot use a scoped service as it has no scope _config = config.CurrentValue ?? throw new ArgumentNullException(nameof(config)); _modelGenerator = modelGenerator; _mbErrors = mbErrors; _mainDom = mainDom; }
public void SetUp() { _modelsGenerator = MockRepository.GeneratePartialMock <ModelsGenerator>(); }
public DictionaryComponent(IDictionaryBuilderConfiguration configuration, ModelsGenerator modelsGenerator) { _configuration = configuration; _modelsGenerator = modelsGenerator; }