예제 #1
0
        /// <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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        internal static void Seal(WellKnownAttributeData data)
        {
#if DEBUG
            if (data != null)
            {
                Debug.Assert(!data._isSealed);
                Debug.Assert(data._anyDataStored);
                data._isSealed = true;
            }
#endif
        }
예제 #5
0
        internal static void Seal(WellKnownAttributeData data)
        {
#if DEBUG
            if (data != null)
            {
                Debug.Assert(!data.isSealed);
                Debug.Assert(data.anyDataStored);
                data.isSealed = true;
            }
#endif
        }