ActivityInfo.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 / Tracking / ActivityInfo.cs / 1305376 / ActivityInfo.cs

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

namespace System.Activities.Tracking 
{
    using System; 
    using System.Runtime.Serialization; 
    using System.Runtime;
    using System.Globalization; 

    [Fx.Tag.XamlVisible(false)]
    [DataContract]
    public sealed class ActivityInfo 
    {
        string name; 
        string id; 
        string instanceId;
        string typeName; 

        public ActivityInfo(string name, string id, string instanceId, string typeName)
        {
            if (string.IsNullOrEmpty(name)) 
            {
                throw FxTrace.Exception.ArgumentNullOrEmpty("name"); 
            } 
            if (string.IsNullOrEmpty(id))
            { 
                throw FxTrace.Exception.ArgumentNullOrEmpty("id");
            }
            if (string.IsNullOrEmpty(instanceId))
            { 
                throw FxTrace.Exception.ArgumentNullOrEmpty("instanceId");
            } 
            if (string.IsNullOrEmpty(typeName)) 
            {
                throw FxTrace.Exception.ArgumentNullOrEmpty("typeName"); 
            }
            this.Name = name;
            this.Id = id;
            this.InstanceId = instanceId; 
            this.TypeName = typeName;
        } 
 
        internal ActivityInfo(ActivityInstance instance)
        { 
            this.Instance = instance;
        }

        internal ActivityInstance Instance 
        {
            get; 
            private set; 
        }
 
        [DataMember]
        public string Name
        {
            get 
            {
                if (string.IsNullOrEmpty(this.name)) 
                { 
                    Fx.Assert(this.Instance != null, "Instance not set");
                    this.name = this.Instance.Activity.DisplayName; 
                }
                return this.name;
            }
            private set 
            {
                Fx.Assert(!string.IsNullOrEmpty(value), "Name cannot be null or empty"); 
                this.name = value; 
            }
        } 

        [DataMember]
        public string Id
        { 
            get
            { 
                if (String.IsNullOrEmpty(this.id)) 
                {
                    Fx.Assert(this.Instance != null, "Instance not set"); 
                    this.id = this.Instance.Activity.Id;
                }
                return this.id;
            } 
            private set
            { 
                Fx.Assert(!string.IsNullOrEmpty(value), "Id cannot be null or empty"); 
                this.id = value;
            } 
        }

        [DataMember]
        public string InstanceId 
        {
            get 
            { 
                if (string.IsNullOrEmpty(this.instanceId))
                { 
                    Fx.Assert(this.Instance != null, "Instance not set");
                    this.instanceId = this.Instance.Id;
                }
                return this.instanceId; 
            }
            private set 
            { 
                Fx.Assert(!string.IsNullOrEmpty(value), "InstanceId cannot be null or empty");
                this.instanceId = value; 
            }
        }

        [DataMember] 
        public string TypeName
        { 
            get 
            {
                if (string.IsNullOrEmpty(this.typeName)) 
                {
                    Fx.Assert(this.Instance != null, "Instance not set");
                    this.typeName = this.Instance.Activity.GetType().FullName;
                } 
                return this.typeName;
            } 
            private set 
            {
                Fx.Assert(!string.IsNullOrEmpty(value), "TypeName cannot be null or empty"); 
                this.typeName = value;
            }
        }
 
        public override string ToString()
        { 
            return string.Format(CultureInfo.CurrentCulture, 
                "Name={0}, ActivityId = {1}, ActivityInstanceId = {2}, TypeName={3}",
                this.Name, 
                this.Id,
                this.InstanceId,
                this.TypeName);
        } 

    } 
} 

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