Sync101 with Custom Filtering

Shows how to track custom filters and how to use a standard custom provider to send changes from a filter-tracking replica to two different filtered replicas.

C# (58.2 KB)
 
 
 
 
 
(0)
1,322 times
Add to favorites
5/13/2011
E-mail Twitter del.icio.us Digg Facebook
using System;
using System.Text;


namespace CustomFilterSyncSample
{
    public class Customer:ICloneable
    {
        public Customer()
        {
            _id = _instanceCount++;
        }
        
        public uint Id
        {
            get
            {
                return _id;
            }

            set
            {
                _id = value;
            }
        }

        public string PhoneNumber
        {
            get
            {
                return _phoneNumber;
            }

            set
            {
                _phoneNumber = value;
            }
        }

        public string State
        {
            get
            {
                return _state;
            }

            set
            {
                if (string.IsNullOrEmpty(value) || value.Length != 2)
                {
                    throw new ArgumentException("State should be a string of size 2.");
                }
                _state = value;
            }
        }

        public ushort Rating
        {
            get
            {
                return _rating;
            }

            set
            {
                if (value == 0 || value > 5)
                {
                    throw new ArgumentException("Rating should be between 1-5.");
                }
                _rating = value;
            }
        }

        public override string ToString()
        {
            StringBuilder buffer = new StringBuilder();
            buffer.AppendFormat("ID: {0, -3} Phone: {1}; State: {2}; Rating: {3}", _id, _phoneNumber, _state, _rating);
            return buffer.ToString();
        }

        uint        _id;
        string      _phoneNumber;
        string      _state;
        ushort      _rating;
        static uint _instanceCount = 0;

        #region ICloneable Members
        internal Customer(
        uint        id,
        string      phoneNumber,
        string      state,
        ushort      rating):base()
        {
            _id = id;
            _phoneNumber = phoneNumber;
            _state = state;
            _rating = rating;
        }
        public object Clone()
        {
            return new Customer(_id,
                _phoneNumber,
                _state,
                _rating);
        }

        #endregion
    }
}