Example #1
0
        private void PopulateComponentsScriptReferences(DesignerViewConfigModel designerViewConfigModel)
        {
            if (designerViewConfigModel == null)
            {
                return;
            }

            if (designerViewConfigModel.Components != null && designerViewConfigModel.Components.Count > 0)
            {
                if (designerViewConfigModel.Scripts == null)
                {
                    designerViewConfigModel.Scripts = new List <string>();
                }

                designerViewConfigModel.Scripts = ComponentsDependencyResolver.GetScripts(designerViewConfigModel.Components, designerViewConfigModel.Scripts);
            }
        }
Example #2
0
        /// <summary>
        /// Generates the view configuration if its missing from the file system.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="viewLocations">Locations where view files can be found.</param>
        /// <param name="viewFilesMappings">Map of the view file location for each view.</param>
        /// <returns>Config for the given view.</returns>
        protected DesignerViewConfigModel GenerateViewConfig(string view, IEnumerable <string> viewLocations, Dictionary <string, string> viewFilesMappings)
        {
            var viewFilePath = this.GetViewFilePath(view, viewLocations, viewFilesMappings);

            if (!string.IsNullOrEmpty(viewFilePath))
            {
                using (var fileStream = VirtualPathManager.OpenFile(viewFilePath))
                {
                    var components = ComponentsDependencyResolver.ExtractComponents(fileStream);
                    var scripts    = ComponentsDependencyResolver.GetScripts(components, null);

                    // If view that exists has been parsed and no components are used in it - no point in cycling trough the other views
                    return(new DesignerViewConfigModel()
                    {
                        Scripts = scripts, Components = components, IsGenerated = true
                    });
                }
            }

            return(null);
        }