Esempio n. 1
0
		public virtual IList CreateList(Type listType, object obj, string propertyName)
		{
			IList newList = null;
			IInterceptableList mList;
#if NET2
            if (listType.IsGenericType && listType.IsInterface)
            {
                Type subType = listType.GetGenericArguments ()[0];
                

                Type genericType = typeof(InterceptableGenericsList<>).MakeGenericType(subType);

                mList = (IInterceptableList) Activator.CreateInstance(genericType);
				mList.Interceptable = (IInterceptable) obj;
				mList.PropertyName = propertyName;
				newList = mList;				
            }
            else if (listType == typeof(IList))
#else
            if (listType == typeof(IList))
#endif			
			{
                mList = new InterceptableList((IInterceptable)obj,propertyName);				
				newList = mList;
			}
			else if (typeof(IList).IsAssignableFrom(listType))
			{
				if (listType.IsInterface)
				{
					throw new Exception("List property type error! Can't specyify list property type specify as interface other than IList. Please specify property type as IList or a concrete class."); // do not localize
				}
				if (listType.IsAbstract)
				{
					throw new Exception("List property type error! Can't specyify list property type as abstract class. Please specify property type as IList or a concrete class."); // do not localize
				}
				if (typeof(IInterceptableList).IsAssignableFrom(listType))
				{
					mList = (IInterceptableList) Activator.CreateInstance(listType);
					mList.Interceptable = (IInterceptable) obj;
					mList.PropertyName = propertyName;
					newList = mList;
				}
				else
				{
					mList = Context.ProxyFactory.CreateListProxy(listType, this.Context.ObjectFactory);
					mList.Interceptable = (IInterceptable) obj;
					mList.PropertyName = propertyName;
					newList = mList;					
				}
			}
			else
			{
				throw new Exception("List property type error! List property type must implement IList interface."); // do not localize
			}
			return newList;
		}
Esempio n. 2
0
 public InterceptableGenericsList()
 {
     list = new InterceptableList();
     list.Interceptor.List = this;
 }