public void factory_should_throw_exception_if_arguments_are_invalid() { var factory = new ParserFactory(); var contacts = string.Empty; Assert.Throws(typeof(ArgumentNullException), () => factory.Create(contacts, null)); }
/// <summary> /// The entry point method. /// </summary> /// <param name="args">The command line arguments.</param> private static void Main(string[] args) { var pargs = ProgramArguments.Parse(args); Contract.Assert(pargs.ParseTablePath != null); var termFactory = new TrivialTermFactory(); var productionFormat = new TermProductionFormat(termFactory); var parserFactory = new ParserFactory( new SpoofaxParseTableFormat(termFactory, productionFormat), new TrivialParseNodeFactory(), new AsFixTreeBuilder(termFactory, productionFormat)); var parser = parserFactory.Create(pargs.ParseTablePath); ITerm ast; using (var reader = new StreamReader(FileExt.OpenInput(pargs.InputPath))) { ast = parser.Parse(reader); } // TODO: Print the ast. Program.trace.TraceData(TraceEventType.Information, 0, ast); }
public void factory_should_return_string_parser_if_contacts_are_passed_in() { var factory = new ParserFactory(); var contacts = "*****@*****.**"; var parser = factory.Create(contacts, null); Assert.IsInstanceOfType(typeof(StringParser), parser, "Wrong parser type returned"); }
public Parser(ParserFactory parserFactory) { this.parser = parserFactory.Create(); this.store = new DefaultGraphStore(); this.locations = new Dictionary<object, SourceSpan>(); this.parser.GraphBuilder = new NodeGraphBuilder(store); this.parser.SyntaxMatched += new EventHandler<SyntaxMatchedEventArgs>(parser_SyntaxMatched); }
public void factory_should_throw_exception_if_file_format_is_not_supported() { var factory = new ParserFactory(); var contacts = string.Empty; var mockUploadedTextFile = new Mock<HttpPostedFileBase>(); mockUploadedTextFile.Expect(f => f.FileName).Returns("textfile.xls"); Assert.Throws(typeof(NotImplementedException), () => factory.Create(contacts, mockUploadedTextFile.Object)); }
public void factory_should_return_text_file_parser_for_uploaded_text_files() { var factory = new ParserFactory(); var contacts = string.Empty; var mockUploadedTextFile = new Mock<HttpPostedFileBase>(); mockUploadedTextFile.Expect(f => f.FileName).Returns("textfile.txt"); var parser = factory.Create(contacts, mockUploadedTextFile.Object); Assert.IsInstanceOfType(typeof(TextFileParser), parser, "Wrong parser type returned"); }
/// <summary> /// Create a deserializer instance for specified type /// </summary> /// <param name="type">Type representing a Bond schema</param> public Deserializer(Type type) : this(type, ParserFactory <R> .Create(type)) { }
public void Create_Parser_Incorrect_Type_Should_ArgumentException() { Assert.ThrowsException <ArgumentException>(() => ParserFactory.Create((ParserType)999)); }
public void Create_TrxParser_Should_Be_Created() { var parser = ParserFactory.Create(ParserType.Trx); Assert.IsTrue(parser is TrxBuildResultParser); }
public Transcoder(Type type) : this(type, ParserFactory <R> .Create(type)) { }
public Transcoder(RuntimeSchema schema) : this(schema, ParserFactory <R> .Create(schema)) { }
/// <summary> /// Create a deserializer instance for specified type, using a custom object factory /// </summary> /// <param name="type">Type representing a Bond schema</param> /// <param name="factory">Factory to create objects during deserialization</param> public Deserializer(Type type, IFactory factory) : this(type, ParserFactory <R> .Create(type), factory, inlineNested : true) { }
private static IParser CreateSharpParser(string fileName) { return(ParserFactory.Create(OpenSharpModel(fileName))); }
/// <summary> /// Create a deserializer instance for specified type, using a custom object factory /// </summary> /// <param name="type">Type representing a Bond schema</param> /// <param name="factory">Factory providing expressions to create objects during deserialization</param> /// <param name="inlineNested">Inline nested types if possible (optimizes for reduction of execution time /// at the expense of initialization time and memory)</param> public Deserializer(Type type, Factory factory, bool inlineNested) : this(type, ParserFactory <R> .Create(type), null, factory, inlineNested) { }
public Transcoder <R, W> Transcoder <R, W>(RuntimeSchema schema) { return(new Transcoder <R, W>(schema, ParserFactory <R> .Create(schema, PayloadBondedFactory))); }
/// <summary> /// Create a deserializer instance for specified type and payload schema /// </summary> /// <param name="type">Type representing a Bond schema</param> /// <param name="schema">Schema of the payload</param> public Deserializer(Type type, RuntimeSchema schema) : this(type, ParserFactory <R> .Create(schema)) { }
static void Main(string[] args) { var solutionFiles = Directory.EnumerateFiles(".", "*.sln", SearchOption.TopDirectoryOnly).ToArray(); if (1 != solutionFiles.Length) { Error("Needs to be run from a directory with exactly one *.sln file in it."); } var solutionPath = Path.GetFullPath(solutionFiles.First()); switch (parseCommandLine()) { case (_, HelpResult help): Console.WriteLine(help.Text); Environment.Exit(help.IsResultOfInvalidInput ? -1 : 0); break; case (var helpOverview, Configuration configuration): if (configuration.OldProjectName.Any(CommonExtensions.IsDirectorySeparator)) { Error( $"Do not specify paths for input/'old' project names, please.{Environment.NewLine}{Environment.NewLine}{helpOverview}"); } configuration.OldProjectName = removeProjectFileExtension(configuration.OldProjectName); configuration.NewProjectName = removeProjectFileExtension(configuration.NewProjectName); new Application(configuration, solutionPath).Run(); break; default: Error( "Something went seriously wrong. Please create an issue at https://github.com/ModernRonin/ProjectRenamer with as much detail as possible."); break; } (string, object) parseCommandLine() { var parser = ParserFactory.Create("renameproject", "Rename C# projects comfortably, including renaming directories, updating references, keeping your git history intact, creating a git commit and updating paket, if needed."); var cfg = parser.DefaultVerb <Configuration>(); cfg.Parameter(c => c.DontCreateCommit) .WithLongName("no-commit") .WithShortName("nc") .WithHelp("don't create a commit after renaming has finished"); cfg.Parameter(c => c.DoRunBuild) .WithLongName("build") .WithShortName("b") .WithHelp( "run a build after renaming (but before committing) to make sure everything worked fine."); cfg.Parameter(c => c.DontRunPaketInstall) .WithLongName("no-paket") .WithShortName("np") .WithHelp("don't run paket install (if your solution uses paket as a local tool)"); cfg.Parameter(c => c.DontReviewSettings) .WithLongName("no-review") .WithShortName("nr") .WithHelp("don't review all settings before starting work"); cfg.Parameter(c => c.OldProjectName) .WithLongName("old-name") .WithShortName("o") .ExpectAt(0) .WithHelp( "the name of the existing project - don't provide path or extension, just the name as you see it in VS."); cfg.Parameter(c => c.NewProjectName) .WithLongName("new-name") .WithShortName("n") .ExpectAt(1) .WithHelp("the new desired project name, again without path or extension"); cfg.Parameter(c => c.ExcludedDirectory) .MakeOptional() .ExpectAt(2) .WithLongName("exclude") .WithShortName("e") .WithHelp( "exclude this directory from project reference updates; must be a relative path to the current directory"); return(parser.HelpOverview, parser.Parse(args)); } string removeProjectFileExtension(string projectName) => projectName.EndsWith(Constants.ProjectFileExtension, StringComparison.InvariantCultureIgnoreCase) ? projectName[..^ Constants.ProjectFileExtension.Length]
public virtual void Init() { var factory = new ParserFactory(CommandConfig); this._parser = factory.Create(true); }
/// <summary> /// Create a deserializer instance for specified type and payload schema, using a custom object factory /// </summary> /// <param name="type">Type representing a Bond schema</param> /// <param name="schema">Schema of the payload</param> /// <param name="factory">Factory providing expressions to create objects during deserialization</param> /// <param name="inlineNested">Inline nested types if possible (optimizes for reduction of execution time /// at the expense of initialization time and memory)</param> public Deserializer(Type type, RuntimeSchema schema, Factory factory, bool inlineNested) : this(type, ParserFactory <R> .Create(schema), null, factory, inlineNested) { }
/// <summary> /// Create a deserializer instance for specified type and payload schema, using a custom object factory /// </summary> /// <param name="type">Type representing a Bond schema</param> /// <param name="schema">Schema of the payload</param> /// <param name="factory">Factory providing expressions to create objects during deserialization</param> public Deserializer(Type type, RuntimeSchema schema, Factory factory) : this(type, ParserFactory <R> .Create(schema), null, factory) { }
/// <summary> /// Create a deserializer instance for specified type, using a custom object factory /// </summary> /// <param name="type">Type representing a Bond schema</param> /// <param name="factory">Factory to create objects during deserialization</param> public Deserializer(Type type, IFactory factory) : this(type, ParserFactory <R> .Create(type), factory) { }
/// <summary> /// Create a deserializer instance for specified type and payload schema /// </summary> /// <param name="type">Type representing a Bond schema</param> /// <param name="schema">Schema of the payload</param> public Deserializer(Type type, RuntimeSchema schema) : this(type, ParserFactory <R> .Create(schema), factory : null, inlineNested : true) { }