public ProjectParser GetXmlParser(Options options) { var serviceBuilder = new ServiceBuilder(); serviceBuilder.Setup(options); serviceBuilder.Build(); var rootPath = GetRootPath(options); var parentFolder = GetParentFolder(options); var namingConvention = GetNamingConvention(options); var parser = new ProjectParser() { ParentFolder = parentFolder, RootPath = rootPath, NamingConvention = namingConvention }; var policyParser = new PolicyParser(serviceBuilder.GetPolicyService()); var dataSourceParser = new DataSourceParser(serviceBuilder.GetDataSourceService()); var reportParser = new ReportParser(serviceBuilder.GetReportService(), new[] { policyParser }); var folderParser = new FolderParser(serviceBuilder.GetFolderService(), new IParser[] { policyParser, dataSourceParser, reportParser }); parser.ChildParsers.Add(dataSourceParser); parser.ChildParsers.Add(reportParser); parser.ChildParsers.Add(folderParser); return(parser); }
/// <summary> /// Initialises the rendering model /// </summary> /// <param name="rendering"></param> public override void Initialize(Rendering rendering) { try { var dataSourceParser = new DataSourceParser(); var dataSource = dataSourceParser.Parse(rendering.DataSource); ViewModel = InitialiseViewModel(rendering, dataSource); base.Initialize(rendering); } catch (Exception ex) { var logService = default(ILogService); try { logService = ServiceLocator.Current.GetInstance <ILogService>(); } catch (Exception) { } // the ILogService interface has not been configured if (logService != null) { logService.Error(ex.ToString(), this); } this.HasError = true; this.ErrorMessage = ex.Message; } }
public void ParseDataSourceNodeAndForwardToRoot() { var stub = new Mock <DataSourceService>(); stub.Setup(s => s.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())).Verifiable(); var service = stub.Object; var parser = new DataSourceParser(service); var xmlDoc = new XmlDocument(); using (Stream stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("RsPackage.Testing.Resources.BasicSample.xml")) using (StreamReader reader = new StreamReader(stream)) xmlDoc.Load(reader); var root = xmlDoc.FirstChild.NextSibling; parser.Root = new ProjectParser() { NamingConvention = new TitleToCamelCase() }; parser.Execute(root); Assert.That(parser.Root.DataSources.ContainsKey("MyDataSource"), Is.True); Assert.That(parser.Root.DataSources["MyDataSource"], Is.EqualTo("/MyDataSource")); }
public void ParseDataSourceNode() { var mock = new Mock <DataSourceService>(); mock.Setup(s => s.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())).Verifiable(); var service = mock.Object; var parser = new DataSourceParser(service); var xmlDoc = new XmlDocument(); using (Stream stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("RsPackage.Testing.Resources.BasicSample.xml")) using (StreamReader reader = new StreamReader(stream)) xmlDoc.Load(reader); var root = xmlDoc.FirstChild.NextSibling; parser.Root = new ProjectParser() { NamingConvention = new TitleToCamelCase() }; parser.Execute(root); Mock.Get(service).Verify(s => s.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>()), Times.Once); }
public void Dispose() { // Disposing Data Source if (DataSourceParser != null) { DataSourceParser.Dispose(); } if (WorkItemGenerator != null) { WorkItemGenerator.Dispose(); } if (Reporter != null) { Reporter.Dispose(); } }
private void LoadFieldNames(XmlElement node) { if (ProgressPart != null) { ProgressPart.Text = "Loading Field Names..."; } if (DataSourceType == DataSourceType.MHT) { if (node.Attributes.Count == 1 && String.CompareOrdinal(node.Attributes[0].Name, c_sampleFileAttributeTag) == 0 && File.Exists(node.Attributes[0].Value)) { DataSourceParser = new MHTParser(new MHTStorageInfo(node.Attributes[0].Value)); } DataSourceParser.ParseDataSourceFieldNames(); DataSourceParser.StorageInfo.FieldNames.Clear(); foreach (XmlElement fieldNode in node.ChildNodes) { if (String.CompareOrdinal(fieldNode.Name, c_fieldNodeTag) == 0 && fieldNode.Attributes.Count == 2 && String.CompareOrdinal(fieldNode.Attributes[0].Name, c_nameAttributeTag) == 0 && String.CompareOrdinal(fieldNode.Attributes[1].Name, c_canDeleteFieldNameAttributeTag) == 0) { string fieldName = fieldNode.Attributes[0].Value; bool canDelete = false; if (bool.TryParse(fieldNode.Attributes[1].Value, out canDelete)) { DataSourceParser.StorageInfo.FieldNames.Add(new SourceField(fieldName, canDelete)); } } else if (String.CompareOrdinal(fieldNode.Name, c_stepsFieldNodeTag) == 0 && fieldNode.Attributes.Count == 1 && String.CompareOrdinal(fieldNode.Attributes[0].Name, c_nameAttributeTag) == 0) { MHTStorageInfo info = DataSourceParser.StorageInfo as MHTStorageInfo; info.StepsField = fieldNode.Attributes[0].Value; } } } }
private List <DataSource> GetDataSources() { var parser = new DataSourceParser(this.Path); return(parser.Get(this.Report)); }