示例#1
0
        private string ReadProperty(Project doc, string name, bool safe, Contract.ConfigHelper configHelper)
        {
            var node = (from n in doc.AllEvaluatedProperties
                        where string.Compare(n.Name, name, true) == 0
                        select n).LastOrDefault();

            if (node == null)
            {
                if (safe)
                {
                    return(null);
                }

                Bridge.Translator.TranslatorException.Throw(
                    "Unable to determine "
                    + name
                    + " in the project file with conditions " + EvaluationConditionsAsString());
            }

            var value = node.EvaluatedValue;

            value = configHelper.ConvertPath(value);

            return(value);
        }
        private void ReadH5Specific(Project project)
        {
            var configHelper = new Contract.ConfigHelper();

            SkipEmbeddingResources = ReadProperty(project, ProjectPropertyNames.H5_Specific.SkipEmbeddingResources, true, configHelper) is string s?bool.Parse(s) : false;

            SkipResourcesExtraction = ReadProperty(project, ProjectPropertyNames.H5_Specific.SkipResourcesExtraction, true, configHelper) is string s2?bool.Parse(s2) : false;

            SkipHtmlGeneration = ReadProperty(project, ProjectPropertyNames.H5_Specific.SkipHtmlGeneration, true, configHelper) is string s3?bool.Parse(s3) : false;
        }
示例#3
0
        private string GetRelativePath(string filespec, string folder)
        {
            Uri pathUri = new Uri(filespec);

            // Folders must end in a slash
            if (!folder.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                folder += Path.DirectorySeparatorChar;
            }

            Uri folderUri = new Uri(folder);

            var path = folderUri.MakeRelativeUri(pathUri).ToString();

            path = new Contract.ConfigHelper().ConvertPath(path, '/');

            return(Uri.UnescapeDataString(path));
        }
        protected virtual IList <string> GetSourceFiles(Project project)
        {
            Logger.ZLogTrace("Getting source files by xml...");
            var configHelper = new Contract.ConfigHelper();

            IList <string> sourceFiles = new List <string>();

            foreach (var projectItem in project.AllEvaluatedItems.Where(i => i.ItemType == "Compile"))
            {
                sourceFiles.Add(configHelper.ConvertPath(projectItem.EvaluatedInclude));
            }

            if (!sourceFiles.Any())
            {
                throw new TranslatorException("Unable to get source file list from project file '" + Location + "'. In order to use h5, you have to have at least one source code file " + "with the 'compile' property set (usually .cs files have it by default in C# projects).");
            }
            ;

            Logger.ZLogTrace("Getting source files by xml done");

            return(sourceFiles);
        }
        protected virtual string GetOutputPaths(Project project)
        {
            var configHelper = new Contract.ConfigHelper();

            var outputPath = ProjectProperties.OutputPath;

            if (outputPath == null && _shouldReadProjectFile)
            {
                // Read OutputPath if not defined already
                // Throw exception if not found
                outputPath = ReadProperty(project, ProjectPropertyNames.OUTPUT_PATH_PROP, false, configHelper);
            }

            outputPath = outputPath ?? "";

            ProjectProperties.OutputPath = outputPath;

            var outDir = ProjectProperties.OutDir;

            if (outDir is null && _shouldReadProjectFile)
            {
                // Read OutDir if not defined already
                outDir = ReadProperty(project, ProjectPropertyNames.OUT_DIR_PROP, true, configHelper);
            }

            // If OutDir value is not found then use OutputPath value
            ProjectProperties.OutDir = outDir ?? outputPath;

            var fullPath = ProjectProperties.OutDir;

            if (!Path.IsPathRooted(fullPath))
            {
                fullPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Location), fullPath));
            }

            fullPath = configHelper.ConvertPath(fullPath);

            return(fullPath);
        }