Example #1
0
        internal static CacheEntry CreateFromStream(BinaryReader reader)
        {
            CacheEntryTypes entryType = (CacheEntryTypes)reader.ReadByte();
            CacheEntry      entry     = null;

            switch (entryType)
            {
            case CacheEntryTypes.BuildItem:
                entry = new BuildItemCacheEntry();
                break;

            case CacheEntryTypes.BuildResult:
                entry = new BuildResultCacheEntry();
                break;

            case CacheEntryTypes.Property:
                entry = new PropertyCacheEntry();
                break;

            default:
                ErrorUtilities.VerifyThrow(false, "Should not get to the default of CacheEntryCustomSerializer CreateFromStream");
                break;
            }

            entry.CreateFromStream(reader);
            return(entry);
        }
Example #2
0
        /// <summary>
        /// Returns true if the given cache entry contains equivalent contents
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        internal override bool IsEquivalent(CacheEntry other)
        {
            if ((other == null) || (other.GetType() != this.GetType()))
            {
                return(false);
            }

            BuildItemCacheEntry otherEntry = (BuildItemCacheEntry)other;

            if (this.Name != otherEntry.Name)
            {
                return(false);
            }

            if ((this.BuildItems == null && otherEntry.BuildItems != null) ||
                (this.BuildItems != null && otherEntry.BuildItems == null))
            {
                return(false);
            }

            if ((this.BuildItems == null) && (otherEntry.BuildItems == null))
            {
                return(true);
            }

            if (this.BuildItems.Length != otherEntry.BuildItems.Length)
            {
                return(false);
            }

            for (int i = 0; i < this.BuildItems.Length; i++)
            {
                if ((this.BuildItems[i] == null && otherEntry.BuildItems[i] != null) ||
                    (this.BuildItems[i] != null && otherEntry.BuildItems[i] == null))
                {
                    return(false);
                }

                if ((this.BuildItems[i].FinalItemSpecEscaped != otherEntry.BuildItems[i].FinalItemSpecEscaped) ||
                    (this.BuildItems[i].GetCustomMetadataCount() != otherEntry.BuildItems[i].GetCustomMetadataCount()))
                {
                    return(false);
                }

                ArrayList otherEntryMetadataNames = new ArrayList(otherEntry.BuildItems[i].GetAllCustomMetadataNames());

                foreach (string metadataName in this.BuildItems[i].GetAllCustomMetadataNames())
                {
                    if ((!otherEntryMetadataNames.Contains(metadataName)) ||
                        (this.BuildItems[i].GetEvaluatedMetadataEscaped(metadataName) != otherEntry.BuildItems[i].GetEvaluatedMetadataEscaped(metadataName)))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }