Exemple #1
0
        public void SetUp()
        {
            _xmlWorkspace =
                new XmlWorkspace
            {
                ID        = "schemaTests",
                ModelName = "SchemaTests"
            };

            _xmlTestDescriptorSimple =
                new XmlTestDescriptor
            {
                Name      = "qaSimpleGeometry(0)",
                TestClass = new XmlClassDescriptor
                {
                    TypeName =
                        "EsriDE.ProSuite.QA.Tests.QaSimpleGeometry",
                    AssemblyName  = "EsriDE.ProSuite.QA.Tests",
                    ConstructorId = 0
                }
            };

            _xmlTestDescriptorMinArea =
                new XmlTestDescriptor
            {
                Name      = "QaMinArea(0)",
                TestClass = new XmlClassDescriptor
                {
                    TypeName =
                        "EsriDE.ProSuite.QA.Tests.QaMinArea",
                    AssemblyName  = "EsriDE.ProSuite.QA.Tests",
                    ConstructorId = 0
                }
            };
        }
Exemple #2
0
 private static IWorkspace ReadWorkspaceFromConfig(ProjectConfigurationInfo info)
 {
     return(info.Configuration.FormatProvider switch
     {
         ProjectFormatProviderType.Gitree => GitreeWorkspace.CreateFromConfigurationInfo(info),
         ProjectFormatProviderType.BattleScribeXml => XmlWorkspace.CreateFromConfigurationInfo(info),
         _ => throw new InvalidOperationException(
             $"Unknown {nameof(ProjectConfiguration.FormatProvider)}:" +
             $" {info.Configuration.FormatProvider}"),
     });
Exemple #3
0
        private XmlWorkspace CreateXmlWorkspace(DirectoryInfo sourceDir)
        {
            var workspace = XmlWorkspace.CreateFromDirectory(sourceDir.FullName);

            Log.Debug("Found {Count} documents at source", workspace.Documents.Length);
            foreach (var(kind, docs) in workspace.DocumentsByKind)
            {
                Log.Debug("- {Count}x {Kind}", docs.Length, kind);
            }
            foreach (var doc in workspace.Documents)
            {
                Log.Verbose("- {Kind} {Name} at {Path}", doc.Kind, doc.Name, doc.Filepath);
            }

            return(workspace);
        }
Exemple #4
0
        private IReadOnlyCollection <DatafileInfo> LoadFolderImpl()
        {
            var path = FolderPath;

            if (string.IsNullOrWhiteSpace(path))
            {
                return(new DatafileInfo[0]);
            }
            var workspace = XmlWorkspace.CreateFromDirectory(path);
            var infos     = workspace.Documents
                            .Where(x => x.Kind == XmlDocumentKind.Gamesystem || x.Kind == XmlDocumentKind.Catalogue)
                            .Select(xml => new DatafileInfo(xml))
                            .ToList();

            return(infos);
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataSource"/> class.
        /// </summary>
        /// <param name="xmlWorkspace">The XML workspace.</param>
        public DataSource([NotNull] XmlWorkspace xmlWorkspace)
            : this(xmlWorkspace.ModelName, xmlWorkspace.ID)
        {
            Assert.ArgumentNotNull(xmlWorkspace, nameof(xmlWorkspace));

            DatabaseName = xmlWorkspace.Database;
            SchemaOwner  = xmlWorkspace.SchemaOwner;

            if (StringUtils.IsNotEmpty(xmlWorkspace.CatalogPath))
            {
                _catalogPath     = xmlWorkspace.CatalogPath.Trim();
                _workspaceAsText = _catalogPath;
            }
            else if (StringUtils.IsNotEmpty(xmlWorkspace.ConnectionString))
            {
                _connectionString = xmlWorkspace.ConnectionString.Trim();
                _workspaceAsText  = _connectionString;

                if (StringUtils.IsNotEmpty(xmlWorkspace.FactoryProgId))
                {
                    _factoryProgId = xmlWorkspace.FactoryProgId.Trim();

                    try
                    {
                        string catalogPath = WorkspaceUtils.TryGetCatalogPath(OpenWorkspace());

                        if (!string.IsNullOrEmpty(catalogPath))
                        {
                            _catalogPath     = catalogPath;
                            _workspaceAsText = _catalogPath;
                        }

                        _referencesValidWorkspace = true;
                    }
                    catch (Exception)
                    {
                        _referencesValidWorkspace = false;
                    }
                }
            }
            else
            {
                _workspaceAsText = string.Empty;
            }
        }
Exemple #6
0
        private void ConvertFiles(ProjectConfigurationInfo configInfo, XmlWorkspace workspace)
        {
            var treeWriter = new GitreeWriter();

            foreach (var document in workspace.GetDocuments(SourceKind.Gamesystem, SourceKind.Catalogue))
            {
                var sourceKind    = document.Kind.GetSourceKindOrUnknown();
                var filenameNoExt = Path.GetFileNameWithoutExtension(document.Filepath);
                var folderPath    = Path.Combine(configInfo.GetFullPath(sourceKind), filenameNoExt);
                var folder        = Directory.CreateDirectory(folderPath);
                Log.Information("Converting file {Name} into {Folder}", filenameNoExt, folder);
                Log.Verbose("- Reading...");
                var sourceNode = document.GetRoot();
                Log.Verbose("- Reading finished. Converting...");
                var gitree = sourceNode.ConvertToGitree();
                Log.Verbose("- Converting finished. Saving to Gitree directory structure...");
                treeWriter.WriteItem(gitree, folder);
                Log.Debug("- Saved");
            }
        }
 public static XmlWorkspace CreateXmlWorkspace() =>
 XmlWorkspace.CreateFromDocuments(
     GetDataResourceNames()
     .Select(x => LoadXmlDocumentFromResource(x))
     .ToImmutableArray());