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;


namespace CustomFilterSyncSample
{
    public class CustomersWithRating : IBaseFilter<Customer>
    {
        public CustomersWithRating(ushort rating)
        {
            if (rating == 0 || rating > 5)
            {
                throw new ArgumentException("Rating should be between 1-5.");
            }
            _rating = rating;
        }

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

        public bool IsIdentical(ISyncFilter otherFilter)
        {
            CustomersWithRating custWithRating = otherFilter as CustomersWithRating;

            return custWithRating != null && _rating == custWithRating._rating;

        }

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

        ushort _rating;
    }
}