示例#1
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (base.Equals(obj))
            {
                return(true);
            }

            MemoryPath other = obj as MemoryPath;

            if (other != null)
            {
                if (this.hashCode == other.hashCode &&
                    this.CallLevel == other.CallLevel &&
                    this.Global == other.Global &&
                    this.Length == other.Length)
                {
                    for (int x = 0; x < Length; x++)
                    {
                        PathSegment thisSegment  = this.PathSegments[x];
                        PathSegment otherSegment = other.PathSegments[x];

                        if (!thisSegment.Equals(otherSegment))
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Gets the or create path modification.
        /// </summary>
        /// <param name="modifiedPath">The modified path.</param>
        /// <returns>Collection to store all modified indexes which belongs to given path</returns>
        public MemoryIndexModificationList GetOrCreatePathModification(MemoryPath modifiedPath)
        {
            MemoryIndexModificationList modificationList;

            if (!assignedPaths.TryGetValue(modifiedPath, out modificationList))
            {
                modificationList = new MemoryIndexModificationList();
                assignedPaths.Add(modifiedPath, modificationList);
            }

            return(modificationList);
        }
示例#3
0
        /// <summary>
        /// Prevents a default instance of the <see cref="MemoryPath"/> class from being created
        /// in order to make new path use one of static methods in this class.
        ///
        /// New path will extends existing path by new segment.
        /// </summary>
        /// <param name="parentPath">The parent path.</param>
        /// <param name="pathSegment">The path segment.</param>
        private MemoryPath(MemoryPath parentPath, PathSegment pathSegment)
        {
            List <PathSegment> path = new List <PathSegment>(parentPath.PathSegments);

            path.Add(pathSegment);

            IsDirect  = parentPath.IsDirect && pathSegment.IsDirect;
            Global    = parentPath.Global;
            CallLevel = parentPath.CallLevel;

            PathSegments = new ReadOnlyCollection <PathSegment>(path);

            this.hashCode = computeSegmentHashCode(parentPath.hashCode, pathSegment);
        }
示例#4
0
 /// <summary>
 /// Makes the path which extends given path by indicies with given names.
 /// </summary>
 /// <param name="parentPath">The parent path.</param>
 /// <param name="names">The names.</param>
 /// <returns>New path which extends given path by indicies with given names</returns>
 public static MemoryPath MakePathIndex(MemoryPath parentPath, IEnumerable <string> names)
 {
     return(new MemoryPath(parentPath, new IndexPathSegment(names)));
 }
示例#5
0
 /// <summary>
 /// Makes the path which extends given path by an unknown index.
 /// </summary>
 /// <param name="parentPath">The parent path.</param>
 /// <returns>New path which extends given path by an unknown index</returns>
 public static MemoryPath MakePathUnknownIndex(MemoryPath parentPath)
 {
     return(new MemoryPath(parentPath, new IndexPathSegment(false)));
 }
示例#6
0
 /// <summary>
 /// Makes the path which extends given path by any index.
 /// </summary>
 /// <param name="parentPath">The parent path.</param>
 /// <returns>New path which extends given path by any index</returns>
 public static MemoryPath MakePathAnyIndex(MemoryPath parentPath)
 {
     return(new MemoryPath(parentPath, new IndexPathSegment(true)));
 }
示例#7
0
 /// <summary>
 /// Makes the path which extends given path by any field.
 /// </summary>
 /// <param name="parentPath">The parent path.</param>
 /// <returns>New path which extends given path by any field</returns>
 public static MemoryPath MakePathAnyField(MemoryPath parentPath)
 {
     return(new MemoryPath(parentPath, new FieldPathSegment(true)));
 }