Handle.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Handle.cs / 1305376 / Handle.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.Activities 
{
    using System; 
    using System.Runtime; 
    using System.Runtime.Serialization;
 
    [DataContract]
    public abstract class Handle
    {
        [DataMember(EmitDefaultValue = false)] 
        ActivityInstance owner;
 
        // We check uninitialized because it should be false more often 
        [DataMember(EmitDefaultValue = false)]
        bool isUninitialized; 

        protected Handle()
        {
            this.isUninitialized = true; 
        }
 
        public ActivityInstance Owner 
        {
            get 
            {
                return this.owner;
            }
        } 

        public string ExecutionPropertyName 
        { 
            get
            { 
                return this.GetType().FullName;
            }
        }
 
        [DataMember(EmitDefaultValue = false)]
        internal bool CanBeRemovedWithExecutingChildren 
        { 
            get;
            set; 
        }

        internal bool IsInitialized
        { 
            get
            { 
                return !this.isUninitialized; 
            }
        } 

        internal static string GetPropertyName(Type handleType)
        {
            Fx.Assert(TypeHelper.AreTypesCompatible(handleType, typeof(Handle)), "must pass in a Handle-based type here"); 
            return handleType.FullName;
        } 
 
        internal void Initialize(HandleInitializationContext context)
        { 
            this.owner = context.OwningActivityInstance;
            this.isUninitialized = false;

            OnInitialize(context); 
        }
 
        internal void Reinitialize(ActivityInstance owner) 
        {
            this.owner = owner; 
        }

        internal void Uninitialize(HandleInitializationContext context)
        { 
            OnUninitialize(context);
            this.isUninitialized = true; 
        } 

        protected virtual void OnInitialize(HandleInitializationContext context) 
        {
        }

        protected virtual void OnUninitialize(HandleInitializationContext context) 
        {
        } 
 
        protected void ThrowIfUninitialized()
        { 
            if (this.isUninitialized)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.HandleNotInitialized));
            } 
        }
    } 
} 

 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK