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 Microsoft.Synchronization;
using System.Text;

namespace CustomFilterSyncSample
{
    public class CustomersInstate : IBaseFilter<Customer>
    {
        public CustomersInstate(string state)
        {
            if (string.IsNullOrEmpty(state) || state.Length != 2)
            {
                throw new ArgumentException("State should be a string of size 2.");
            }

            _state = state;
        }

        public bool IsInFilter(Customer item)
        {
            return item != null && item.State.Equals(_state);
        }

        public bool IsIdentical(ISyncFilter otherFilter)
        {
            CustomersInstate customersInstate = otherFilter as CustomersInstate;

            return customersInstate != null && _state.Equals(customersInstate._state);

        }

        //This sample does not support Serialize/Deserialize of Change Batch with Filters.
        public byte[] Serialize()
        {
            throw new NotImplementedException();
        }
       
        string  _state;
    }
}