Add() публичный Метод

Connects a tag index to a tag in another version.
public Add ( DefinitionSet version1, int index1, DefinitionSet version2, int index2 ) : void
version1 DefinitionSet The first version.
index1 int The tag index in the first version.
version2 DefinitionSet The second version.
index2 int The tag index in the second version.
Результат void
Пример #1
0
        /// <summary>
        /// Parses a map from a CSV.
        /// </summary>
        /// <param name="reader">The reader to read from.</param>
        /// <returns>The map that was read.</returns>
        public static TagVersionMap ParseTagVersionMap(TextReader reader)
        {
            var result = new TagVersionMap();

            // Skip the first line, we don't need it
            if (reader.ReadLine() == null)
                return result;

            // Read the timestamp list and resolve each one
            var timestampLine = reader.ReadLine();
            if (timestampLine == null)
                return result;
            var timestamps = timestampLine.Split(',').Select(t =>
            {
                long r;
                if (long.TryParse(t, NumberStyles.HexNumber, null, out r))
                    return r;
                return -1;
            });
            var versions = timestamps.Select(t =>
            {
                DefinitionSet closest;
                return Definition.DetectFromTimestamp(t, out closest);
            }).ToArray();

            // Read each line and store the tag indexes in the result map
            while (true)
            {
                var line = reader.ReadLine();
                if (line == null)
                    break;
                if (string.IsNullOrWhiteSpace(line))
                    continue;

                // Parse each tag index as a hex number
                var tags = line.Split(',');
                var tagIndexes = tags.Select(t =>
                {
                    int r;
                    if (int.TryParse(t, NumberStyles.HexNumber, null, out r))
                        return r;
                    return -1;
                }).ToArray();

                // Now connect all of them to the first tag
                for (var i = 1; i < tagIndexes.Length; i++)
                {
                    if (tagIndexes[i] >= 0)
                        result.Add(versions[0], tagIndexes[0], versions[i], tagIndexes[i]);
                }
            }
            return result;
        }
Пример #2
0
        /// <summary>
        /// Parses a map from a CSV.
        /// </summary>
        /// <param name="reader">The reader to read from.</param>
        /// <returns>The map that was read.</returns>
        public static TagVersionMap ParseTagVersionMap(TextReader reader)
        {
            var result = new TagVersionMap();

            // Skip the first line, we don't need it
            if (reader.ReadLine() == null)
            {
                return(result);
            }

            // Read the timestamp list and resolve each one
            var timestampLine = reader.ReadLine();

            if (timestampLine == null)
            {
                return(result);
            }
            var timestamps = timestampLine.Split(',').Select(t =>
            {
                if (long.TryParse(t, NumberStyles.HexNumber, null, out long r))
                {
                    return(r);
                }
                return(-1);
            });
            var versions = timestamps.Select(t =>
            {
                return(CacheVersionDetection.DetectFromTimestamp(t, out CacheVersion closest));
            }).ToArray();

            // Read each line and store the tag indices in the result map
            while (true)
            {
                var line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                // Parse each tag index as a hex number
                var tags       = line.Split(',');
                var tagIndices = tags.Select(t =>
                {
                    if (int.TryParse(t, NumberStyles.HexNumber, null, out int r))
                    {
                        return(r);
                    }
                    return(-1);
                }).ToArray();

                // Now connect all of them to the first tag
                for (var i = 1; i < tagIndices.Length; i++)
                {
                    if (tagIndices[i] >= 0)
                    {
                        result.Add(versions[0], tagIndices[0], versions[i], tagIndices[i]);
                    }
                }
            }
            return(result);
        }