Observable.ImplementINotify C# (CSharp) Method

ImplementINotify() public static method

public static ImplementINotify ( Type objectType ) : Type
objectType Type
return Type
        public static Type ImplementINotify(Type objectType)
        {
            var tempAssemblyName = new AssemblyName(Guid.NewGuid().ToString());
            var dynamicAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(
                tempAssemblyName, AssemblyBuilderAccess.RunAndCollect);
            var moduleBuilder = dynamicAssembly.DefineDynamicModule(
                tempAssemblyName.Name,
                tempAssemblyName + ".dll");
            var typeBuilder = moduleBuilder.DefineType(
                objectType.FullName, TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract);
            typeBuilder.AddInterfaceImplementation(objectType);
            typeBuilder.AddInterfaceImplementation(typeof(INotifyPropertyChanged));
            typeBuilder.AddInterfaceImplementation(typeof(INotifyPropertyChanging));
            var newType = typeBuilder.CreateType();
            return newType;
        }
    }