TrackingCondition.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 / WF / RunTime / Tracking / TrackingCondition.cs / 1305376 / TrackingCondition.cs

                            using System; 
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text; 
using System.Xml;
using System.Xml.Schema; 
using System.IO; 
using System.Reflection;
using System.Diagnostics; 
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Globalization;
 
//using System.Workflow.Activities;
using System.Workflow.ComponentModel; 
using System.Workflow.Runtime; 
using System.Workflow.Runtime.Hosting;
using Hosting = System.Workflow.Runtime.Hosting; 


namespace System.Workflow.Runtime.Tracking
{ 
    [Serializable]
    public abstract class TrackingCondition 
    { 
        #region Properties
 
        public abstract string Value { get; set; }

        public abstract string Member { get; set; }
 
        public abstract ComparisonOperator Operator { get; set; }
 
        #endregion 

        #region Internal Abstract Match Methods 

        internal abstract bool Match(object obj);

        #endregion 

    } 
 
    /// 
    /// Describes critieria that is used constrain locations. 
    /// 
    [Serializable]
    public class ActivityTrackingCondition : TrackingCondition
    { 
        #region Private Data Members
 
        private string _property; 
        private string _val;
        private ComparisonOperator _op = ComparisonOperator.Equals; 

        #endregion

        #region Constructors 
        /// 
        /// Default constructor 
        ///  
        public ActivityTrackingCondition()
        { 
        }

        /// 
        /// Constuct with a list of property names and a value. 
        /// 
        /// "." delineated list of property names. 
        /// Value for the condition. 
        /// Throws ArgumentNullException, ArgumentException.
        public ActivityTrackingCondition(string member, string value) 
        {
            //
            // value can be null but the propery name(s) cannot
            if (null == member) 
                throw new ArgumentNullException("member");
 
            _property = member; 

            SetValue(value); 
        }

        #endregion
 
        #region Properties
 
        public override string Value 
        {
            get { return _val; } 
            set { SetValue(value); }
        }

        public override string Member 
        {
            get { return _property; } 
            set { _property = value; } 
        }
 
        public override ComparisonOperator Operator
        {
            get { return _op; }
            set { _op = value; } 
        }
 
        #endregion 

        #region Internal Methods 

        internal override bool Match(object obj)
        {
            if (null == obj) 
                throw new ArgumentNullException("obj");
 
            object o = PropertyHelper.GetProperty(_property, obj); 

            if (ComparisonOperator.Equals == _op) 
            {
                if (null == o)
                    return (null == _val);
                else 
                    return (0 == string.Compare(o.ToString(), _val, StringComparison.Ordinal));
            } 
            else 
            {
                if (null == o) 
                    return (null != _val);
                else
                    return (0 != string.Compare(o.ToString(), _val, StringComparison.Ordinal));
            } 
        }
 
        #endregion 

        #region Private Methods 

        private void SetValue(string value)
        {
            _val = value; 
        }
 
        #endregion 
    }
 
    public enum ComparisonOperator
    {
        Equals = 0,
        NotEquals = 1, 
    }
} 

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

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