public void CompareMatchReturnsBreakingWhenNamedArgumentParameterNameChanged() { var oldArgument = Model.UsingModule <ConfigurationModule>().Create <TestArgumentDefinition>() .Set(x => x.ArgumentType = ArgumentType.Named); var oldArguments = new[] { oldArgument }; var oldAttribute = Model.UsingModule <ConfigurationModule>().Create <TestAttributeDefinition>() .Set(x => x.Arguments = oldArguments); var newArgument = Model.UsingModule <ConfigurationModule>().Create <TestArgumentDefinition>().Set( x => { x.ArgumentType = ArgumentType.Named; x.Value = oldArgument.Value; }); var newArguments = new[] { newArgument }; var newAttribute = Model.UsingModule <ConfigurationModule>().Create <TestAttributeDefinition>() .Set(x => x.Arguments = newArguments); var match = new ItemMatch <IAttributeDefinition>(oldAttribute, newAttribute); var options = OptionsFactory.BuildOptions(); var sut = new AttributeComparer(); var actual = sut.CompareMatch(match, options).ToList(); _output.WriteResults(actual); actual.Should().HaveCount(1); actual[0].ChangeType.Should().Be(SemVerChangeType.Breaking); actual[0].OldItem.Should().BeAssignableTo <IArgumentDefinition>(); actual[0].NewItem.Should().BeNull(); }
public async Task EvaluatesChangeOfMethodAttribute( string oldAttribute, string newAttribute, AttributeCompareOption compareOptions, SemVerChangeType expected) { var oldCode = new List <CodeSource> { new(NoParameters.Replace("public string MyMethod", oldAttribute + " public string MyMethod")) }; var newCode = new List <CodeSource> { new(NoParameters.Replace("public string MyMethod", newAttribute + " public string MyMethod")) }; var options = OptionsFactory.BuildOptions(); options.CompareAttributes = compareOptions; var result = await _calculator.CalculateChanges(oldCode, newCode, options, CancellationToken.None) .ConfigureAwait(false); result.ChangeType.Should().Be(expected); }
protected override void ConfigureOptions(OptionsFactory options) { }
public SendCommunicationSubscription(QueueClient queueClient, string dbConnectionString) { this.queueClient = queueClient; this.options = OptionsFactory.NewDbOptions <CommunicationsContext>(dbConnectionString); }
protected override void ConfigureOptions(OptionsFactory options) { options.Check("Foo or bar?") .Choice("Foo", "foo", () => _foo = true) .Choice("Bar", "bar", () => _bar = true); }
protected override void ConfigureOptions(OptionsFactory options) { options.Input("Allyourbase?", s => _text = s); }
protected override void ConfigureOptions(OptionsFactory options) { options.Input("Welcome to Hello World generator. Please enter the name: ", s => _name = s); }
//private readonly Dictionary<string, Action> _projectFactories; //public EmptyGenerator() //{ // _projectFactories = new Dictionary<string, Action>() // { // [OptionValues.NewProject] = CreateNewProject // }; //} //private string _projectName; //private string _projectType; //protected override IEnumerable<ConfigurationOption> SetupOptions() //{ // // Split into SimpleList and ComplexList // // Simple list is for stuff where choices only return one value performC:\P\P\Tempest\src\Tempest.Core\Utils\StringExtensions.csed by list // // Complex list is for stuff where choices all do their own thing // // Better polymorphism and API. // // Afternote: // // Really? Better API? Why can't an option do one thing, and the choice do another thing, at the same time? // yield return // Options // .List("Welcome to empty .NET Core generator!", value => _projectType = value) // .Choice("New project", OptionValues.NewProject); // yield return // Options // .Input("Please choose the name for your generator", value => { _projectName = value; }) // .When(() => _projectType == OptionValues.NewProject); //} //protected override void ExecuteCore() //{ // Set.TargetSubDirectory(_projectName); // _projectFactories[_projectType](); //} //private void CreateNewProject() //{ // //Globally.TransformToken("ReplaceMe", _projectName); // // Uncomment/comment either below as needed // //CopyFromTemplates(); // //CopyFromResources(); //} /// <summary> /// Generate project using embedded resources /// </summary> //private void CopyFromResources() //{ // Func<string, string> resource = templateFile => $"Tempest.Generator.Empty.Template.{templateFile}"; // Copy.Resource(resource("project.json")).ToFile("project2.json"); // Copy.Resource(resource("Program.cs")).ToFile("Program2.cs"); // Copy.Resource(resource("ReplaceMeGreeter.cs")).ToFile(() => $"{_projectName}_.cs"); //} /// <summary> /// Generate project using templates /// </summary> //private void CopyFromTemplates() //{ // Copy.TemplatePattern("./*.cs").ToFiles(); // //Copy.Templates(templatesRelativePath: "relative/Path/With/**/pattern", includeSubDirectories: true) // // .ToLocation(""); // Copy.Template("project.json").ToFile("project.json"); // //Copy.Template("Program.cs").ToFile("Program.cs"); // //Copy.Template("ReplaceMeGreeter.cs").ToFile(() => $"{_projectName}.cs"); //} /// <summary> /// Parameters used for possible input options /// </summary> //private static class OptionValues //{ // public const string NewProject = "new"; //} protected override void ConfigureOptions(OptionsFactory options) { throw new NotImplementedException(); }
protected override void ConfigureOptions(OptionsFactory options) { options.List("Foo or bar?").Choice("Foo", "foo", () => _foo = true).Choice("Bar", "bar"); options.Input("Output?", s => _text = s); }
public NotificationPublisher(string dbConnectionString, string serviceBusConnectionString, string topicName) { this.topicName = topicName; this.serviceBusConnectionString = serviceBusConnectionString; this.options = OptionsFactory.NewDbOptions <ContactsContext>(dbConnectionString); }
public DialogButtonLogic(IGameController gameController, DialogsFactory dialogsConfiguration, OptionsFactory optionsConfiguration) { dialogsFactory = dialogsConfiguration; optionFactory = optionsConfiguration; this.gameController = gameController; concurrentDialog = dialogsFactory.CreateFirst(); gameController.ShowDialog(); gameController.FillFildOfDialog(concurrentDialog); }
public static void Main(string[] args) { _connectionString = OptionsFactory.GetConnectionString(); //Get connection string options _fileStoreOptions = OptionsFactory.GetFileStoreOptions(); //Get file store options _dbContext = new ApplicationDbContext( //Create database context new DbContextOptionsBuilder <ApplicationDbContext>() .UseSqlServer(_connectionString.DefaultConnection).Options); //Fill default picture data using (FileStream fs = new FileStream("NoPicture.png", FileMode.Open, FileAccess.Read)) { using (MemoryStream ms = new MemoryStream()) { fs.CopyTo(ms); _defaultImagedata = ms.ToArray(); } } bool error = false; //If an error was thrown. InitializeFileSystem(); //Make folders if they don't exist. var filenames = Directory.GetFiles(_fileStoreOptions.DumpPath); if (filenames.Length == 0) { System.Diagnostics.Debug.WriteLine("No new files to add."); return; } foreach (var fp in filenames) //Create DB entries and copy files to correct locations. { try { CopyFileToMediaLibrary(fp); } catch (UnsupportedFileException ex) //If unsupported type move to rejected path. { var adminMessage = CreateAdminMessage(string.Format("Failed to add {0} to database. File type {1} incompatible.", ex.FileName, ex.MediaType), ErrorStatus.error); _dbContext.AdminMessages.Add(adminMessage); //Rejected path string rejectpath = Path.Combine(_fileStoreOptions.RejectedPath, Path.GetFileName(fp)); //Move rejected file File.Move(fp, rejectpath); error = true; continue; } catch (Exception ex) //Halt program if other error. { var adminMessage = CreateAdminMessage(string.Format("ContentScanner failed with the following error: {0}", ex.Message), ErrorStatus.error); _dbContext.AdminMessages.Add(adminMessage); error = true; throw ex; } } if (error) { System.Diagnostics.Debug.WriteLine("Process ended with errors."); //Report program ended with errors. } else { System.Diagnostics.Debug.WriteLine("Process ended successfully."); //Report program ended without errors. } }
protected override void ConfigureOptions(OptionsFactory options) { options.Input("Output?", s => _text = s); }
protected override void ConfigureOptions(OptionsFactory options) { _testHelper.OptionsAction?.Invoke(options, _generatorOptions); }
protected abstract void ConfigureOptions(OptionsFactory options);
public StreamContent(ApplicationDbContext dbContext) { _dbContext = dbContext; _fileStore = OptionsFactory.GetFileStoreOptions(); }
protected override void ConfigureOptions(OptionsFactory options) { options.List("Foo or bar?", s => _text = s).Choice("Foo", "foo").Choice("Bar", "bar"); }
static void Main(string[] args) { Options options = null; try { // Get the args. options = OptionsFactory.GetOptions(args); } catch (Exception) { Console.WriteLine("An error occured."); Console.WriteLine("Usage :"); OptionsFactory.cmdParser.HelpOption.ShowHelp(OptionsFactory.cmdParser.Options); throw; } // Read input file. Console.WriteLine("Reading file {0}", options.Input); XDocument input = XDocument.Load(options.Input); if (options.IsVerbose) { Console.Write(input.ToString()); } // Validate input file if requested if (options.Xsd != null) { Console.WriteLine("Validating file with {0}", options.Xsd); XDocument xsd = XDocument.Load(options.Xsd); if (options.IsVerbose) { Console.Write(xsd.ToString()); } XmlSchemaSet xsdSchemas = new XmlSchemaSet(); bool hasErrors = false; xsdSchemas.Add(string.Empty, XmlReader.Create(new StringReader(xsd.ToString()))); input.Validate(xsdSchemas, (o, e) => { Console.WriteLine("Errors validating XML : {0}", e.Message); hasErrors = true; }); if (hasErrors) { Console.WriteLine("Exiting"); Environment.Exit(0); } } Console.WriteLine("Transforming file with {0}", options.Xslt); XDocument xslt = XDocument.Load(options.Xslt); if (options.IsVerbose) { Console.Write(xslt.ToString()); } XDocument output = new XDocument(); using (XmlWriter writer = output.CreateWriter()) { // Load the style sheet. XslCompiledTransform xsltCompiled = new XslCompiledTransform(); xsltCompiled.Load(XmlReader.Create(new StringReader(xslt.ToString()))); // Execute the transform and output the results to a writer. xsltCompiled.Transform(output.CreateReader(), writer); } Console.WriteLine("Output of the transformation to {0}", options.Output); Console.Write(output.ToString()); if (options.IsVerbose) { output.Save(options.Output); } Console.WriteLine("Exiting"); }