Exemplo n.º 1
0
        /// <summary>
        /// Creates and loads the specified view.
        /// </summary>
        private ViewBase GetView(View viewEntity, Type viewType)
        {
            try
            {
                ViewBase view = (ViewBase)Activator.CreateInstance(viewType, viewEntity);

                if (webContext.PluginHolder.GetPluginByViewType(viewType, out PluginLogic pluginLogic))
                {
                    pluginLogic.PrepareView(view);
                }

                if (view.StoredOnServer)
                {
                    if (webContext.Storage.ViewAvailable)
                    {
                        LoadViewFromStorage(view, viewEntity.Path);
                    }
                    else
                    {
                        LoadViewFromServer(view, viewEntity.Path);
                    }
                }

                view.Build();
                view.Bind(webContext.ConfigDatabase);
                return(view);
            }
            catch (Exception ex)
            {
                webContext.Log.WriteError(ex, Locale.IsRussian ?
                                          "Ошибка при загрузке представления с ид. {0} по пути {1}" :
                                          "Error loading view with ID {0} by the path {1}",
                                          viewEntity.ViewID, viewEntity.Path);
                return(null);
            }
        }