1 // Copyright (c) Microsoft. All rights reserved. 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 4 using System; 5 using System.Collections.Generic; 6 using System.Text; 7 using System.IO; 8 9 using Microsoft.Build.Framework; 10 11 namespace Microsoft.Build.BuildEngine 12 { 13 /// <summary> 14 /// A cache entry representing a build result (task items + build success/failure) 15 /// </summary> 16 internal class BuildResultCacheEntry : BuildItemCacheEntry 17 { 18 #region Constructors 19 20 /// <summary> 21 /// Default constructor 22 /// </summary> BuildResultCacheEntry()23 internal BuildResultCacheEntry() 24 { 25 } 26 27 /// <summary> 28 /// Public constructor 29 /// </summary> 30 /// <param name="name"></param> 31 /// <param name="taskItems"></param> 32 /// <param name="buildResult"></param> BuildResultCacheEntry(string name, BuildItem[] buildItems, bool buildResult)33 internal BuildResultCacheEntry(string name, BuildItem[] buildItems, bool buildResult) 34 : base(name, buildItems) 35 { 36 this.buildResult = buildResult; 37 } 38 39 #endregion 40 41 #region Properties 42 43 private bool buildResult; 44 45 /// <summary> 46 /// Build result of this target (success, failure, skipped) 47 /// </summary> 48 internal bool BuildResult 49 { 50 get { return buildResult; } 51 set { buildResult = value; } 52 } 53 54 #endregion 55 56 #region Methods 57 58 /// <summary> 59 /// Returns true if the given cache entry contains equivalent contents 60 /// </summary> 61 /// <param name="other"></param> 62 /// <returns></returns> IsEquivalent(CacheEntry other)63 internal override bool IsEquivalent(CacheEntry other) 64 { 65 if ((other == null) || (other.GetType() != this.GetType())) 66 { 67 return false; 68 } 69 70 if (!base.IsEquivalent(other)) 71 { 72 return false; 73 } 74 75 return (this.BuildResult == ((BuildResultCacheEntry)other).BuildResult); 76 } 77 #endregion 78 79 #region CustomSerializationToStream WriteToStream(BinaryWriter writer)80 internal override void WriteToStream(BinaryWriter writer) 81 { 82 base.WriteToStream(writer); 83 writer.Write(buildResult); 84 } 85 CreateFromStream(BinaryReader reader)86 internal override void CreateFromStream(BinaryReader reader) 87 { 88 base.CreateFromStream(reader); 89 buildResult = reader.ReadBoolean(); 90 } 91 #endregion 92 } 93 } 94