Beispiel #1
0
 /// <summary>Fills the <paramref name="contentItem"/> with the properties from the <paramref name="script"/>.</summary>
 /// <param name="script">The script.</param>
 /// <param name="contentItem">The content item.</param>
 private static void FillContentItem(JackrabbitScript script, ContentItem contentItem)
 {
     contentItem.Content = script.ScriptPath;
     contentItem.Metadata["PathPrefixName"] = script.PathPrefixName;
     contentItem.Metadata["Provider"]       = script.Provider;
     contentItem.Metadata["Priority"]       = script.Priority.ToString(CultureInfo.InvariantCulture);
 }
Beispiel #2
0
        /// <summary>Adds the script.</summary>
        /// <param name="moduleId">The module ID.</param>
        /// <param name="script">The script.</param>
        public void AddScript(int moduleId, JackrabbitScript script)
        {
            var contentItem = new ContentItem {
                ContentTypeId = this.JackrabbitScriptContentType.ContentTypeId, ModuleID = moduleId,
            };

            FillContentItem(script, contentItem);
            this.contentController.AddContentItem(contentItem);
        }
Beispiel #3
0
        /// <summary>Updates the script.</summary>
        /// <param name="script">The script.</param>
        public void UpdateScript(JackrabbitScript script)
        {
            var contentItem = this.contentController.GetContentItem(script.Id);

            if (contentItem == null)
            {
                return;
            }

            FillContentItem(script, contentItem);
            this.contentController.UpdateContentItem(contentItem);
        }
Beispiel #4
0
        /// <summary>Creates the script view model.</summary>
        /// <param name="script">The script.</param>
        /// <returns>A new <see cref="ViewJackrabbitViewModel.ScriptViewModel" /> instance.</returns>
        private ViewJackrabbitViewModel.ScriptViewModel CreateScriptViewModel(JackrabbitScript script)
        {
            var fullScriptPath = script.ScriptPath;
            var prefixPath     = string.IsNullOrEmpty(script.PathPrefixName) ? null : this.DependencyLoader.Paths.Find(p => p.Name == script.PathPrefixName);

            if (prefixPath != null)
            {
                fullScriptPath = prefixPath.Path + script.ScriptPath;
            }

            return(new ViewJackrabbitViewModel.ScriptViewModel(
                       script.Id,
                       script.PathPrefixName,
                       script.ScriptPath,
                       fullScriptPath,
                       script.Provider,
                       script.Priority ?? (int)FileOrder.Js.DefaultPriority));
        }