コード例 #1
0
        public virtual object New(Window window, ScreenRepository screenRepository)
        {
            var o = Activator.CreateInstance(type, window, screenRepository);
            //Get all fields, even from base types
            var fieldInfos = AllTypes(type).SelectMany(t => t.GetFields(Entity.BindingFlag));

            foreach (var fieldInfo in fieldInfos)
            {
                if (nonInjectedTypes.Any(t => t.IsAssignableFrom(fieldInfo.FieldType)))
                {
                    continue;
                }

                object injectedObject = null;
                if (typeof(IUIItem).IsAssignableFrom(fieldInfo.FieldType))
                {
                    var interceptor = new UIItemInterceptor(SearchCondition(fieldInfo, window.Framework), window, screenRepository.SessionReport);
                    injectedObject = DynamicProxyGenerator.Instance.CreateProxy(fieldInfo.FieldType, interceptor);
                }
                else if (typeof(AppScreenComponent).IsAssignableFrom(fieldInfo.FieldType))
                {
                    var componentScreenClass = new ScreenClass(fieldInfo.FieldType);
                    injectedObject = componentScreenClass.New(window, screenRepository);
                }

                if (injectedObject != null)
                {
                    fieldInfo.SetValue(o, injectedObject);
                }
            }

            return(o);
        }
コード例 #2
0
ファイル: ScreenClass.cs プロジェクト: jasongdove/White
        public virtual object New(Window window, ScreenRepository screenRepository)
        {
            var o = Activator.CreateInstance(type, window, screenRepository);
            //Get all fields, even from base types
            var fieldInfos = AllTypes(type).SelectMany(t=>t.GetFields(Entity.BindingFlag));
            foreach (var fieldInfo in fieldInfos)
            {
                if (nonInjectedTypes.Any(t=>t.IsAssignableFrom(fieldInfo.FieldType))) continue;

                object injectedObject = null;
                if (typeof(IUIItem).IsAssignableFrom(fieldInfo.FieldType))
                {
                    var interceptor = new UIItemInterceptor(SearchCondition(fieldInfo, window.Framework), window, screenRepository.SessionReport);
                    injectedObject = DynamicProxyGenerator.Instance.CreateProxy(fieldInfo.FieldType, interceptor);
                }
                else if (typeof(AppScreenComponent).IsAssignableFrom(fieldInfo.FieldType))
                {
                    var componentScreenClass = new ScreenClass(fieldInfo.FieldType);
                    injectedObject = componentScreenClass.New(window, screenRepository);
                }

                if (injectedObject != null) fieldInfo.SetValue(o, injectedObject);
            }

            return o;
        }
コード例 #3
0
        private T GetScreen <T>(Window window) where T : AppScreen
        {
            var screenClass = new ScreenClass(typeof(T));

            return((T)screenClass.New(window, this));
        }