using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel;
using System.Reflection;
using PostSharp.Aspects;

namespace EQNetwork.Aspects
{
    [Serializable]
    public class TrackPropertyChangedAttribute : LocationInterceptionAspect
    {
        public TrackPropertyChangedAttribute()
        {
            AspectPriority = 600;
        }

        public override void OnSetValue(LocationInterceptionArgs args)
        {
            object oldValue = args.GetCurrentValue();
            base.OnSetValue(args);
            object newValue = args.GetCurrentValue();
            if (args.Instance is PropertyChangeTracker)
            {
                if (!Equals(oldValue, newValue))
                    ((PropertyChangeTracker)args.Instance).AddPropertyChange(args.LocationName);
            }
        }
    }
}
