Ejemplo n.º 1
0
 /// <nodoc/>
 public override bool Equals(object obj)
 {
     if ((obj == null) || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         BuildManifestData data = (BuildManifestData)obj;
         return(data.Version.Equals(Version) &&
                data.Timestamp.Equals(Timestamp) &&
                Enumerable.SequenceEqual(data.Outputs, Outputs));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses a string and forms a <see cref="BuildManifestData"/> struct. The string must follow the format specified by <see cref="ToString"/> method.
        /// </summary>
        public static bool TryParse(string value, out BuildManifestData data)
        {
            int numberOfObjectsWithinBuildManifestData = 3;

            data = default;

            string[] splits = value.Split(new[] { Separator }, StringSplitOptions.None);

            bool valid = splits.Length >= numberOfObjectsWithinBuildManifestData &&
                         (splits.Length - numberOfObjectsWithinBuildManifestData) % 3 == 0;

            if (!valid)
            {
                return(false);
            }

            string version = splits[0];

            if (!long.TryParse(splits[1], out long timestamp))
            {
                return(false);
            }

            List <BuildManifestFile> outputs = new List <BuildManifestFile>();

            if (!int.TryParse(splits[2], out var outputLen))
            {
                return(false);
            }

            if (outputLen * 3 != splits.Length - numberOfObjectsWithinBuildManifestData)
            {
                return(false);
            }

            for (int i = numberOfObjectsWithinBuildManifestData; i < splits.Length; i += 3)
            {
                outputs.Add(new BuildManifestFile(
                                splits[i],
                                splits[i + 1],
                                splits[i + 2]));
            }

            data = new BuildManifestData(version,
                                         timestamp,
                                         outputs);

            return(true);
        }