示例#1
0
        public void RegisterViewContainer <T>() where T : class, IViewContainer
        {
            _injection.Register <T>(InstanceType.SingleInstance);

            var            viewContainer = _injection.Get <T>();
            IList <IStack> stacks        = new List <IStack>();

            // Load list of stacks depending on ViewContainer
            if (viewContainer as ISingleContainer != null)
            {
                stacks.Add(((ISingleContainer)viewContainer).Stack);
            }
            else if (viewContainer as IMasterDetailContainer != null)
            {
                stacks.Add(((IMasterDetailContainer)viewContainer).MasterStack);
                stacks.Add(((IMasterDetailContainer)viewContainer).DetailStack);
            }
            else if (viewContainer as ITabbedContainer != null)
            {
                foreach (var stack in ((ITabbedContainer)viewContainer).Children)
                {
                    stacks.Add(stack);
                }
            }
            else
            {
                throw new ArgumentException($"{nameof(T)} is not a valid {nameof(IViewContainer)}. Please use one of Exrin's default types");
            }

            // Register stacks and ViewContainer Associations
            foreach (var stack in stacks)
            {
                if (!_stacks.ContainsKey(stack.StackIdentifier))
                {
                    _stacks.Add(stack.StackIdentifier, stack);
                }

                if (!_stackViewContainers.ContainsKey(stack.StackIdentifier))
                {
                    _stackViewContainers.Add(stack.StackIdentifier, viewContainer.Identifier);
                }
            }

            // Register ViewContainers
            if (!_viewContainers.ContainsKey(viewContainer.Identifier))
            {
                _viewContainers.Add(viewContainer.Identifier, viewContainer);
            }
        }
示例#2
0
 private void RegisterModel <T>() where T : class, IBaseModel
 {
     _injection.Register <T>(InstanceType.SingleInstance);
 }