일반적인 Entity class에 INotifyPropertyChanged 를 적용하는 Interceptor이다.
Inheritance: LazyInitializer
        public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
        {
            try
            {
                log.Info("Get Intercepted Proxy object. id={0}", id);

                LazyInitializer initializer =
                    new DataBindingInterceptor(EntityName, PersistentClass, id,
                                               GetIdentifierMethod, SetIdentifierMethod,
                                               ComponentIdType, session);

                object generatedProxy;
                var    list = new List <Type>(Interfaces);
                list.Add(typeof(INotifyPropertyChanged));
                var interfaces = list.ToArray();
                //var list = new ArrayList(Interfaces);
                //list.Add(typeof(INotifyPropertyChanged));
                //var interfaces = (System.Type[])list.ToArray(typeof(System.Type));

                if (IsClassProxy)
                {
                    generatedProxy = DefaultProxyGenerator.CreateClassProxy(PersistentClass,
                                                                            interfaces,
                                                                            ProxyGenerationOptions.Default,
                                                                            initializer);
                }
                else
                {
                    generatedProxy = DefaultProxyGenerator.CreateInterfaceProxyWithoutTarget(interfaces[0], interfaces, initializer);
                }

                initializer._constructed = true;
                return((INHibernateProxy)generatedProxy);
            }
            catch (Exception ex)
            {
                log.ErrorException("Creating a proxy instance is failed. id=" + id, ex);
                throw new HibernateException("Creating a proxy instance is failed. id=" + id, ex);
            }
        }
Example #2
0
		public override INHibernateProxy GetProxy(object id, ISessionImplementor session)
		{
			try
			{
				log.Info("Get Intercepted Proxy object. id={0}", id);

				LazyInitializer initializer =
					new DataBindingInterceptor(EntityName, PersistentClass, id,
											   GetIdentifierMethod, SetIdentifierMethod,
											   ComponentIdType, session);

				object generatedProxy;
				var list = new List<Type>(Interfaces);
				list.Add(typeof(INotifyPropertyChanged));
				var interfaces = list.ToArray();
				//var list = new ArrayList(Interfaces);
				//list.Add(typeof(INotifyPropertyChanged));
				//var interfaces = (System.Type[])list.ToArray(typeof(System.Type));

				if(IsClassProxy)
					generatedProxy = DefaultProxyGenerator.CreateClassProxy(PersistentClass,
																			interfaces,
																			ProxyGenerationOptions.Default,
																			initializer);
				else
					generatedProxy = DefaultProxyGenerator.CreateInterfaceProxyWithoutTarget(interfaces[0], interfaces, initializer);

				initializer._constructed = true;
				return (INHibernateProxy)generatedProxy;
			}
			catch(Exception ex)
			{
				log.ErrorException("Creating a proxy instance is failed. id=" + id, ex);
				throw new HibernateException("Creating a proxy instance is failed. id=" + id, ex);
			}
		}