Exemple #1
0
        private bool ReadVersionFile(ParsedPath versionFileName)
        {
            XDocument versionDoc         = XDocument.Load(versionFileName);
            var       buildValueTypeAttr = versionDoc.Root.Attribute("BuildValueType");

            if (buildValueTypeAttr == null)
            {
                this.buildValueType = BuildValueType.JDate;
            }
            else
            {
                this.buildValueType = (BuildValueType)Enum.Parse(typeof(BuildValueType), buildValueTypeAttr.Value, ignoreCase: true);
            }

            tags = versionDoc.Root.Elements().Where(x => x.Name != "Files").ToDictionary <XElement, string, string>(
                x => x.Name.ToString(), x => x.Value);

            if (!tags.ContainsKey("Major") || !tags.ContainsKey("Minor") ||
                !tags.ContainsKey("Build") || !tags.ContainsKey("Revision"))
            {
                WriteError("Version file must at least contain at least Major, Minor, Build, Revision tags");
                return(false);
            }

            string timeZoneId;

            if (tags.TryGetValue("TimeZone", out timeZoneId))
            {
                try
                {
                    this.timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("TimeZone '{0}' was not found".CultureFormat(timeZoneId), ex);
                }
            }

            this.today = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, this.timeZoneInfo);

            var filesNode = versionDoc.Root.Element("Files");

            if (filesNode == null)
            {
                WriteError("Version file must contain a Files node");
                return(false);
            }

            fileList = filesNode.Descendants().Select(x => (string)x).ToArray();

            return(true);
        }
Exemple #2
0
        private bool ReadVersionFile(ParsedPath versionFileName)
        {
            XDocument versionDoc = XDocument.Load(versionFileName);
            var buildValueTypeAttr = versionDoc.Root.Attribute("BuildValueType");

            if (buildValueTypeAttr == null)
            {
                this.buildValueType = BuildValueType.JDate;
            }
            else
            {
                this.buildValueType = (BuildValueType)Enum.Parse(typeof(BuildValueType), buildValueTypeAttr.Value, ignoreCase: true);
            }

            tags = versionDoc.Root.Elements().Where(x => x.Name != "Files").ToDictionary<XElement, string, string>(
                x => x.Name.ToString(), x => x.Value);

            if (!tags.ContainsKey("Major") || !tags.ContainsKey("Minor") ||
                !tags.ContainsKey("Build") || !tags.ContainsKey("Revision"))
            {
                WriteError("Version file must at least contain at least Major, Minor, Build, Revision tags");
                return false;
            }

            string timeZoneId;

            if (tags.TryGetValue("TimeZone", out timeZoneId))
            {
                try
                {
                    this.timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("TimeZone '{0}' was not found".CultureFormat(timeZoneId), ex);
                }
            }

            this.today = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, this.timeZoneInfo);

            var filesNode = versionDoc.Root.Element("Files");

            if (filesNode == null)
            {
                WriteError("Version file must contain a Files node");
                return false;
            }

            fileList = filesNode.Descendants().Select(x => (string)x).ToArray();

            return true;
        }