private static MappingResolver MapFiles(string source, string target, string definitionFolder) { var definitionName = Path.GetFileNameWithoutExtension(source); var definitionStore = DefinitionFactory.Open(definitionName, definitionFolder); using (var sourceStream = File.OpenRead(source)) using (var targetStream = File.OpenRead(target)) { var sourceAnalyzer = AnalyzerFactory.Create(sourceStream); var targetAnalyzer = AnalyzerFactory.Create(targetStream); var sourceType = definitionStore[sourceAnalyzer.LayoutHash]; var targetType = definitionStore[targetAnalyzer.LayoutHash]; if (sourceType == null) { return(null); } sourceAnalyzer = AnalyzerFactory.Create(sourceType, sourceStream); if (targetType != null) { targetAnalyzer = AnalyzerFactory.Create(targetType, targetStream); } var resolver = new MappingResolver(definitionName, sourceAnalyzer, targetAnalyzer); return(resolver); } }
public void AnalyzeCartItemsTestThrowsNullReferenceException49() { Analyzer analyzer; analyzer = AnalyzerFactory.Create(); this.AnalyzeCartItemsTest(analyzer); }
public void test_WHEN_expression_is_array_THEN_array_analyzer_is_created() { Expression <Func <SPListItem, object[]> > expr = x => new[] { x["Count"] }; var analyzerFactory = new AnalyzerFactory(null, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <ArrayAnalyzer>()); }
public void test_WHEN_expression_is_orelse_THEN_orelse_analyzer_is_created() { Expression <Func <SPListItem, bool> > expr = x => (int)x["Count"] == 1 || (int)x["Count"] == 1; var analyzerFactory = new AnalyzerFactory(null, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <OrElseAnalyzer>()); }
public void test_WHEN_expression_IS_in_THEN_in_analyzer_IS_created() { Expression <Func <SPListItem, bool> > expr = x => (new[] { 0, 1, 2 }).Contains((int)x[new Guid("{1DF87A41-D795-4C0F-915F-DC3D54B296AA}")]); var analyzerFactory = new AnalyzerFactory(null, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <InAnalyzer>()); }
public void test_WHEN_expression_IS_contains_THEN_contains_analyzer_IS_created() { Expression <Func <SPListItem, bool> > expr = x => ((string)x["Count"]).Contains("foo"); var analyzerFactory = new AnalyzerFactory(null, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <ContainsAnalyzer>()); }
public void test_WHEN_expression_IS_beginswith_THEN_beginswith_analyzer_IS_created() { Expression <Func <SPListItem, bool> > expr = x => ((string)x["Count"]).StartsWith("foo"); var analyzerFactory = new AnalyzerFactory(null, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <BeginsWithAnalyzer>()); }
public void test_WHEN_expression_is_neq_THEN_neq_analyzer_is_created() { Expression <Func <SPListItem, bool> > expr = x => (int)x["Count"] != 1; var operandBuilder = new OperandBuilder(); var analyzerFactory = new AnalyzerFactory(operandBuilder, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <NeqAnalyzer>()); }
public void test_WHEN_expression_is_not_includes_explicit_cast_string_based_syntax_THEN_not_includes_analyzer_is_created() { Expression <Func <SPListItem, bool> > expr = x => !((DataTypes.Integer)x["Count"]).Includes(1); var operandBuilder = new OperandBuilder(); var analyzerFactory = new AnalyzerFactory(operandBuilder, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <NotIncludesAnalyzer>()); }
public void test_WHEN_expression_is_not_includes_with_lookupId_THEN_not_includes_analyzer_is_created() { Expression <Func <SPListItem, bool> > expr = x => !((int)x["Count"]).Includes(1, true); var operandBuilder = new OperandBuilder(); var analyzerFactory = new AnalyzerFactory(operandBuilder, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <NotIncludesAnalyzer>()); }
private void SelectTargetFile(object sender, EventArgs e) { _targetStream?.Dispose(); targetGridView.Rows.Clear(); var fileName = string.Empty; using (var dialog = new OpenFileDialog()) { dialog.Title = "Select the file to use as reference."; dialog.Filter = "DBC files (*.dbc, *.db2)|*.dbc;*.db2"; if (dialog.ShowDialog() == DialogResult.OK) { fileName = dialog.FileName; } } if (string.IsNullOrEmpty(fileName)) { return; } textBox2.Text = fileName; _targetStream = File.OpenRead(fileName); _targetFileAnalyzer = AnalyzerFactory.Create(_targetStream); if (Properties.Settings.Default.LoadTargetDefinition) { var definitionName = Path.GetFileNameWithoutExtension(fileName); if (!_definitionContainer.TryGetValue(definitionName, out var definitionStore) || definitionStore == null) { definitionStore = _definitionContainer[definitionName] = DefinitionFactory.Open(definitionName); } var fileType = definitionStore[_targetFileAnalyzer.LayoutHash]; _targetFileAnalyzer = AnalyzerFactory.Create(fileType, _targetStream); // Add to GUI ShowTypeToGUI(_targetFileAnalyzer.RecordType, targetGridView); } else { var definitionName = Path.GetFileNameWithoutExtension(fileName); if (_definitionContainer.TryGetValue(definitionName, out var definitionStore)) { if (definitionStore.ContainsKey(_targetFileAnalyzer.LayoutHash)) { throw new InvalidOperationException("Structure is already known"); } } } }
public void test_WHEN_expression_is_isnull_THEN_isnull_analyzer_is_created() { var operandBuilder = MockRepository.GenerateStub <IOperandBuilder>(); operandBuilder.Stub(b => b.CreateValueOperandForNativeSyntax(null)).Return(new NullValueOperand()).IgnoreArguments(); Expression <Func <SPListItem, bool> > expr = x => x["Count"] == null; var analyzerFactory = new AnalyzerFactory(operandBuilder, null); var analyzer = analyzerFactory.Create(expr); Assert.That(analyzer, Is.InstanceOf <IsNullAnalyzer>()); }
private void SelectSourceFile(object sender, EventArgs e) { _sourceStream?.Dispose(); sourceGridView.Rows.Clear(); var fileName = string.Empty; using (var dialog = new OpenFileDialog()) { dialog.Title = "Select the file to use as reference."; dialog.Filter = "DBC files (*.dbc, *.db2)|*.dbc;*.db2"; if (dialog.ShowDialog() == DialogResult.OK) { fileName = dialog.FileName; } } if (string.IsNullOrEmpty(fileName)) { return; } textBox1.Text = fileName; var definitionName = Path.GetFileNameWithoutExtension(fileName); if (!_definitionContainer.TryGetValue(definitionName, out var definitionStore) || definitionStore == null) { definitionStore = _definitionContainer[definitionName] = DefinitionFactory.Open(definitionName); } _sourceStream = File.OpenRead(fileName); var fileAnalyzer = AnalyzerFactory.Create(_sourceStream); var fileType = definitionStore[fileAnalyzer.LayoutHash]; _sourceFileAnalyzer = AnalyzerFactory.Create(fileType, _sourceStream); // Add to GUI ShowTypeToGUI(_sourceFileAnalyzer.RecordType, sourceGridView); }
static async Task Main(string[] args) { try { await Parser.Default.ParseArguments <Options>(args).WithParsedAsync(async opt => { await AnalyzerFactory.Create(opt.Hierarchy, opt.Verbose).Analyze(opt.SolutionPath); }); } catch (Exception e) { Console.WriteLine(e.Message); Environment.Exit(1); } }