Example #1
0
        /// <summary>
        /// Loads the modules into the view if authorization passes.
        /// </summary>
        /// <param name="modules"></param>
        private void LoadModules(IList <Module> modules)
        {
            // Get reference to view's module containers.
            IDictionary <string, Control> moduleContainers = _view.ModuleContainers;

            // Now go through all the modules and determine if ok to add.
            foreach (Module module in modules)
            {
                // Ensure security.
                string roles = module.Instance.Roles;
                if (string.IsNullOrEmpty(roles) || Auth.IsUserInRoles(module.Instance.Roles))
                {
                    // Have the view load instance of module.
                    Control     control    = _view.LoadModule(module);
                    IModuleView moduleView = control as IModuleView;

                    if (moduleView != null)
                    {
                        // Set moduleview(UI component) reference to the module.
                        moduleView.Module = module;

                        // Now get it's container name.
                        string containerName = module.Instance.ContainerName.ToLower().Trim();
                        if (moduleContainers.ContainsKey(containerName))
                        {
                            // Add to container.
                            Control container = moduleContainers[containerName];
                            container.Controls.Add(control);
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Loads the modules into the view if authorization passes.
        /// </summary>
        /// <param name="modules"></param>
        private void LoadModule(Module module)
        {
            string roles = module.Instance.Roles;

            if (string.IsNullOrEmpty(roles) || RoleHelper.IsUserInRoles(module.Instance.Roles))
            {
                Control     control    = _view.LoadModule(module);
                IModuleView moduleView = control as IModuleView;

                if (moduleView != null)
                {
                    moduleView.Module = module;

                    // Always load to the body container.
                    _view.ModuleContainerMain.Controls.Add(control);
                }
            }
        }