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 ReplaceNullWithInstanceOfAttribute : LocationInterceptionAspect
    {
        Type _type;
        public ReplaceNullWithInstanceOfAttribute(Type type)
        {
            AspectPriority = 200;
            _type = type;
        }

        public override void OnSetValue(LocationInterceptionArgs args)
        {
            if (args.Value == null)
                args.Value = Activator.CreateInstance(_type);
            base.OnSetValue(args);
        }
    }
}
