private static IEnumerable <IFormat> GetFormats(IGeneratorOptions options) { //TODO: TBD: from here's it's not far to drop it in as a VERY loosely coupled resource in App, MainWindow, etc var interfaceType = typeof(IFormat); var assemblyTypes = interfaceType.Assembly.GetTypes().ToArray(); //Do not order the types themselves. var viewModelTypes = assemblyTypes.Where( t => t.IsPublic && t.IsClass && !t.IsAbstract && interfaceType.IsAssignableFrom(t)) .ToArray(); var formatters = viewModelTypes.Select(t => { var ctor = t.GetConstructor(new[] { typeof(IGeneratorOptions) }); Debug.Assert(ctor != null); var instance = ctor.Invoke(new object[] { options }); Debug.Assert(instance != null); return((IFormat)instance); }); /* Instead order the formatter instances. That'll work pretty well. Actually, * I'm kind of surprised that the extension method works here, considering there * is a Generic Constraint on its TFormat, wanting a class that implements IFormat, * not just the simple IFormat, per se. I'm not saying 'no', just surprised, is all. */ var ordered = formatters.OrderBy(f => f.GetDisplayOrder().Order).ToArray(); return(ordered); }
public async Task <ConcurrentBag <string> > GenerateAsync(IGeneratorOptions generatorOptions, IProgressTracker <Report>?progressTracker = null) { progressTracker ??= IgnoringProgressReporter.Default; var result = new ConcurrentBag <string>(); var generatorRuns = new BlockingCollection <GeneratorRun>(new ConcurrentBag <GeneratorRun>()); try { var cancellationToken = generatorOptions.CancellationToken; progressTracker.Report(new Report(ReportType.StartingGeneration)); var targetRuns = new ConcurrentBag <TargetRun>(); var prepareTask = Task.Run(async() => await this.PrepareAsync(generatorRuns, targetRuns, progressTracker, cancellationToken).ConfigureAwait(false), cancellationToken); var generateTask = Task.Run(async() => await this.GenerateAsync(generatorRuns, progressTracker, cancellationToken).ConfigureAwait(false), cancellationToken); await Task.WhenAll(prepareTask, generateTask).ConfigureAwait(false); if (cancellationToken.IsCancellationRequested) { progressTracker.Report(new Report(ReportType.Cancelled)); return(new ConcurrentBag <string>()); } await FinalizeAsync(progressTracker, targetRuns, result).ConfigureAwait(false); progressTracker.Report(new Report(ReportType.CompletedGeneration)); return(result); } catch (Exception exception) { generatorRuns.CompleteAdding(); progressTracker.Report(new Report(ReportType.Error, exception)); throw new GenerationException("Error", exception); } }
public Generator( IHostingEnvironment hostingEnvironment, IGeneratorOptions options, ICoreGenerator coreGenerator) { _hostingEnvironment = hostingEnvironment; _options = options; _coreGenerator = coreGenerator; }
internal Generator(IGeneratorOptions options) { IncludeName = options.NameIncluded; IncludeAddress = options.AddressInclude; IncludeDOB = options.DOBIncluded; Genders = options.GenderFilter; IncludeSSN = options.SSNIncluded; IncludeSSNDashes = options.SSNDashed; MaximumAge = options.MaximumAge; MinimumAge = options.MinimumAge; if (IncludeName && options.ExternalNameData == null) { LoadInternalNameData(Genders); } else if (IncludeName) { LoadExternalNameData(options.ExternalNameData); } if (IncludeAddress && options.ExternalAddressData == null) { LoadInternalAddressData(); } else if (IncludeAddress) { LoadExternalAddressData(options.ExternalAddressData); } if (IncludeSSN && options.ExternalSSNAreaCodeData == null) { LoadInternalSSNAreaCodeData(); } else if (IncludeSSN) { LoadExternalSSNAreaCodeData(options.ExternalSSNAreaCodeData); } }
/// <summary> /// Constructor /// </summary> /// <param name="options"></param> /// <param name="baseDisplayName"></param> /// <param name="formatter"></param> public FormatViewModel(IGeneratorOptions options, string baseDisplayName, Func <Guid, TextCase, string> formatter) { _baseDisplayName = baseDisplayName; _formatter = formatter; _options = options; //Starting out from the nominal default. FormattedText = _formatter(options.Current, options.Case); const StringComparison comparisonType = StringComparison.InvariantCultureIgnoreCase; _options.PropertyChanged += (s, e) => { var propertyName = e.PropertyName; if (string.Equals(propertyName, "Current", comparisonType) || string.Equals(propertyName, "Case", comparisonType)) { FormattedText = _formatter(options.Current, options.Case); } }; }
public CPlusPlusStaticConstStructFormatViewModel(IGeneratorOptions options) : base(options, "static const struct GUID = { ... }", Formatter) { }
public DigitsFormatViewModel(IGeneratorOptions options) : base(options, "Digits", Formatter) { }
/********************************************************************************************** ** Constructor ** **********************************************************************************************/ public Generator(IGeneratorOptions options) { this.options = options; this.parser = new Parser(); // Add event handler delegates this.parser.OnStart += new StartHandler(Parser_OnStart); this.parser.OnComplete += new CompleteHandler(Parser_OnComplete); this.parser.OnImportFound += new ImportHandler(Parser_OnImportFound); this.parser.OnClassFound += new ClassHandler(Parser_OnClassFound); this.parser.OnInterfaceFound += new InterfaceHandler(Parser_OnInterfaceFound); this.parser.OnMethodFound += new MethodHandler(Parser_OnMethodFound); this.parser.OnGetterFound += new GetterHandler(Parser_OnGetterFound); this.parser.OnSetterFound += new SetterHandler(Parser_OnSetterFound); this.parser.OnPropertyFound += new PropertyHandler(Parser_OnPropertyFound); }
public CoreGenerator(IGeneratorOptions options, IFilesProvider filesProvider) { _options = options; _filesProvider = filesProvider; }
public RegistryFormatViewModel(IGeneratorOptions options) : base(options, @"Registry Format (ie. {{xxxxxxxx-xxxx ... xxxx }})", Formatter) { }
public VisualBasicDotNetGuidAttributeFormatViewModel(IGeneratorOptions options) : base(options, @"<Guid(""xxxxxxxx-xxxx ... xxxx"")>", Formatter) { }
public ParenthesesFormatViewModel(IGeneratorOptions options) : base(options, @"Parentheses", Formatter) { }
public HyphensFormatViewModel(IGeneratorOptions options) : base(options, @"Hypens", Formatter) { }
// ReSharper disable once UnusedMember.Global public ProjectGuidBracesFormatViewModel(IGeneratorOptions options) : base(options, GetXmlWithContent(XmlTag, $"{{xxxxxxxx-xxxx ... xxxx}}"), Formatter) { }
public CSharpAssemblyGuidAttributeFormatViewModel(IGeneratorOptions options) : base(options, @"[assembly: Guid(""xxxxxxxx-xxxx ... xxxx"")]", Formatter) { }
public CurlyBracesFormatViewModel(IGeneratorOptions options) : base(options, @"Braces", Formatter) { }
public CPlusPlusDefineGuidFormatViewModel(IGeneratorOptions options) : base(options, "DEFINE_GUID(...)", Formatter) { }
public CPlusPlusImplementOleCreateFormatViewModel(IGeneratorOptions options) : base(options, "IMPLEMENT_OLECREATE(...)", Formatter) { }