InstancePersistenceEvent.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / System.Runtime.DurableInstancing / System / Runtime / DurableInstancing / InstancePersistenceEvent.cs / 1305376 / InstancePersistenceEvent.cs

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

namespace System.Runtime.DurableInstancing 
{
    using System.Threading; 
    using System.Xml.Linq; 

    public abstract class InstancePersistenceEvent : IEquatable 
    {
        internal InstancePersistenceEvent(XName name)
        {
            if (name == null) 
            {
                throw Fx.Exception.ArgumentNull("name"); 
            } 
            Name = name;
        } 

        public XName Name { get; private set; }

        public bool Equals(InstancePersistenceEvent persistenceEvent) 
        {
            return !object.ReferenceEquals(persistenceEvent, null) && persistenceEvent.Name == Name; 
        } 

        public override bool Equals(object obj) 
        {
            return Equals(obj as InstancePersistenceEvent);
        }
 
        public override int GetHashCode()
        { 
            return Name.GetHashCode(); 
        }
 
        public static bool operator ==(InstancePersistenceEvent left, InstancePersistenceEvent right)
        {
            if (object.ReferenceEquals(left, right))
            { 
                return true;
            } 
            else if (object.ReferenceEquals(left, null)) 
            {
                return false; 
            }
            else
            {
                return left.Equals(right); 
            }
        } 
 
        public static bool operator !=(InstancePersistenceEvent left, InstancePersistenceEvent right)
        { 
            return !(left == right);
        }
    }
 
    public abstract class InstancePersistenceEvent : InstancePersistenceEvent
        where T : InstancePersistenceEvent, new() 
    { 
        static T instance;
 
        protected InstancePersistenceEvent(XName name)
            : base(name)
        {
        } 

        public static T Value 
        { 
            get
            { 
                if (instance == null)
                {
                    Interlocked.CompareExchange(ref instance, new T(), null);
                } 
                return instance;
            } 
        } 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//---------------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//---------------------------------------------------------------

namespace System.Runtime.DurableInstancing 
{
    using System.Threading; 
    using System.Xml.Linq; 

    public abstract class InstancePersistenceEvent : IEquatable 
    {
        internal InstancePersistenceEvent(XName name)
        {
            if (name == null) 
            {
                throw Fx.Exception.ArgumentNull("name"); 
            } 
            Name = name;
        } 

        public XName Name { get; private set; }

        public bool Equals(InstancePersistenceEvent persistenceEvent) 
        {
            return !object.ReferenceEquals(persistenceEvent, null) && persistenceEvent.Name == Name; 
        } 

        public override bool Equals(object obj) 
        {
            return Equals(obj as InstancePersistenceEvent);
        }
 
        public override int GetHashCode()
        { 
            return Name.GetHashCode(); 
        }
 
        public static bool operator ==(InstancePersistenceEvent left, InstancePersistenceEvent right)
        {
            if (object.ReferenceEquals(left, right))
            { 
                return true;
            } 
            else if (object.ReferenceEquals(left, null)) 
            {
                return false; 
            }
            else
            {
                return left.Equals(right); 
            }
        } 
 
        public static bool operator !=(InstancePersistenceEvent left, InstancePersistenceEvent right)
        { 
            return !(left == right);
        }
    }
 
    public abstract class InstancePersistenceEvent : InstancePersistenceEvent
        where T : InstancePersistenceEvent, new() 
    { 
        static T instance;
 
        protected InstancePersistenceEvent(XName name)
            : base(name)
        {
        } 

        public static T Value 
        { 
            get
            { 
                if (instance == null)
                {
                    Interlocked.CompareExchange(ref instance, new T(), null);
                } 
                return instance;
            } 
        } 
    }
} 

// 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