/// <summary> /// Sets the decoded well-known attribute data (except the early data) on the bag in a thread safe manner. /// Stored decoded data is immutable and cannot be updated further. /// </summary> /// <returns>Returns true if decoded data were stored into the bag on this thread.</returns> public bool SetDecodedWellKnownAttributeData(WellKnownAttributeData data) { WellKnownAttributeData.Seal(data); var setOnOurThread = Interlocked.CompareExchange(ref _decodedWellKnownAttributeData, data, null) == null; NotePartComplete(CustomAttributeBagCompletionPart.DecodedWellKnownAttributeData); return(setOnOurThread); }
/// <summary> /// Gets or creates the decoded data object. /// </summary> /// <remarks> /// This method must be called only when some decoded data will be stored into it subsequently. /// </remarks> public T GetOrCreateData <T>() where T : WellKnownAttributeData, new() { if (this.lazyDecodeData == null) { this.lazyDecodeData = new T(); } return((T)lazyDecodeData); }
public bool SetDecodedWellKnownAttributeData(WellKnownAttributeData data) { WellKnownAttributeData.Seal(data); // Early decode must complete before full decode Debug.Assert(IsPartComplete(CustomAttributeBagCompletionPart.EarlyDecodedWellKnownAttributeData)); var setOnOurThread = Interlocked.CompareExchange(ref _decodedWellKnownAttributeData, data, null) == null; NotePartComplete(CustomAttributeBagCompletionPart.DecodedWellKnownAttributeData); return(setOnOurThread); }
internal static void Seal(WellKnownAttributeData data) { #if DEBUG if (data != null) { Debug.Assert(!data._isSealed); Debug.Assert(data._anyDataStored); data._isSealed = true; } #endif }
internal static void Seal(WellKnownAttributeData data) { #if DEBUG if (data != null) { Debug.Assert(!data.isSealed); Debug.Assert(data.anyDataStored); data.isSealed = true; } #endif }