From 38986f3bfd66f3936170c67508e7252adeae5aaf Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 12 Nov 2019 13:33:02 +1100 Subject: [PATCH 01/11] Abstracts out IStylesheet, IStylesheetProperty --- .../Models/IStylesheet.cs | 30 +++++++++++++++++ .../Models/IStylesheetProperty.cs | 11 +++++++ src/Umbraco.Abstractions/Models/Stylesheet.cs | 6 ++-- .../Models/StylesheetProperty.cs | 2 +- .../Repositories/IStylesheetRepository.cs | 4 +-- .../Implement/StylesheetRepository.cs | 33 +++++++++++-------- src/Umbraco.Core/Services/IFileService.cs | 8 ++--- .../Services/Implement/FileService.cs | 24 +++++++------- .../Repositories/StylesheetRepositoryTest.cs | 32 ++++++++++-------- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 4 +++ .../Cache/DistributedCacheBinder_Handlers.cs | 4 +-- src/Umbraco.Web/Editors/CodeFileController.cs | 6 ++-- 12 files changed, 111 insertions(+), 53 deletions(-) create mode 100644 src/Umbraco.Abstractions/Models/IStylesheet.cs create mode 100644 src/Umbraco.Abstractions/Models/IStylesheetProperty.cs diff --git a/src/Umbraco.Abstractions/Models/IStylesheet.cs b/src/Umbraco.Abstractions/Models/IStylesheet.cs new file mode 100644 index 0000000000..737118d646 --- /dev/null +++ b/src/Umbraco.Abstractions/Models/IStylesheet.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using Umbraco.Core.Models.Entities; + +namespace Umbraco.Core.Models +{ + public interface IStylesheet : IFile, IRememberBeingDirty + { + /// + /// Returns a list of umbraco back office enabled stylesheet properties + /// + /// + /// An umbraco back office enabled stylesheet property has a special prefix, for example: + /// + /// /** umb_name: MyPropertyName */ p { font-size: 1em; } + /// + IEnumerable Properties { get; } + + /// + /// Adds an Umbraco stylesheet property for use in the back office + /// + /// + void AddProperty(IStylesheetProperty property); + + /// + /// Removes an Umbraco stylesheet property + /// + /// + void RemoveProperty(string name); + } +} diff --git a/src/Umbraco.Abstractions/Models/IStylesheetProperty.cs b/src/Umbraco.Abstractions/Models/IStylesheetProperty.cs new file mode 100644 index 0000000000..c44a147d54 --- /dev/null +++ b/src/Umbraco.Abstractions/Models/IStylesheetProperty.cs @@ -0,0 +1,11 @@ +using Umbraco.Core.Models.Entities; + +namespace Umbraco.Core.Models +{ + public interface IStylesheetProperty : IRememberBeingDirty + { + string Alias { get; set; } + string Name { get; } + string Value { get; set; } + } +} diff --git a/src/Umbraco.Abstractions/Models/Stylesheet.cs b/src/Umbraco.Abstractions/Models/Stylesheet.cs index df5786a340..48f00a1650 100644 --- a/src/Umbraco.Abstractions/Models/Stylesheet.cs +++ b/src/Umbraco.Abstractions/Models/Stylesheet.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.Models /// [Serializable] [DataContract(IsReference = true)] - public class Stylesheet : File + public class Stylesheet : File, IStylesheet { public Stylesheet(string path) : this(path, null) @@ -120,7 +120,7 @@ namespace Umbraco.Core.Models /// /** umb_name: MyPropertyName */ p { font-size: 1em; } /// [IgnoreDataMember] - public IEnumerable Properties + public IEnumerable Properties { get { return _properties.Value; } } @@ -129,7 +129,7 @@ namespace Umbraco.Core.Models /// Adds an Umbraco stylesheet property for use in the back office /// /// - public void AddProperty(StylesheetProperty property) + public void AddProperty(IStylesheetProperty property) { if (Properties.Any(x => x.Name.InvariantEquals(property.Name))) { diff --git a/src/Umbraco.Abstractions/Models/StylesheetProperty.cs b/src/Umbraco.Abstractions/Models/StylesheetProperty.cs index 089f89deb6..bc895113bc 100644 --- a/src/Umbraco.Abstractions/Models/StylesheetProperty.cs +++ b/src/Umbraco.Abstractions/Models/StylesheetProperty.cs @@ -12,7 +12,7 @@ namespace Umbraco.Core.Models /// [Serializable] [DataContract(IsReference = true)] - public class StylesheetProperty : BeingDirtyBase, IValueObject + public class StylesheetProperty : BeingDirtyBase, IValueObject, IStylesheetProperty { private string _alias; private string _value; diff --git a/src/Umbraco.Core/Persistence/Repositories/IStylesheetRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IStylesheetRepository.cs index 1643e6e7a7..10771eb6d0 100644 --- a/src/Umbraco.Core/Persistence/Repositories/IStylesheetRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/IStylesheetRepository.cs @@ -3,9 +3,9 @@ using Umbraco.Core.Models; namespace Umbraco.Core.Persistence.Repositories { - public interface IStylesheetRepository : IReadRepository, IWriteRepository + public interface IStylesheetRepository : IReadRepository, IWriteRepository { - bool ValidateStylesheet(Stylesheet stylesheet); + bool ValidateStylesheet(IStylesheet stylesheet); Stream GetFileContentStream(string filepath); void SetFileContent(string filepath, Stream content); long GetFileSize(string filepath); diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/StylesheetRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/StylesheetRepository.cs index 52ff14b0dc..d5db3e2cf4 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/StylesheetRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/StylesheetRepository.cs @@ -10,15 +10,19 @@ namespace Umbraco.Core.Persistence.Repositories.Implement /// /// Represents the Stylesheet Repository /// - internal class StylesheetRepository : FileRepository, IStylesheetRepository + internal class StylesheetRepository : FileRepository, IStylesheetRepository { - public StylesheetRepository(IFileSystems fileSystems) + private readonly IIOHelper _ioHelper; + + public StylesheetRepository(IFileSystems fileSystems, IIOHelper ioHelper) : base(fileSystems.StylesheetsFileSystem) - { } + { + _ioHelper = ioHelper; + } #region Overrides of FileRepository - public override Stylesheet Get(string id) + public override IStylesheet Get(string id) { // get the relative path within the filesystem // (though... id should be relative already) @@ -51,16 +55,19 @@ namespace Umbraco.Core.Persistence.Repositories.Implement } - public override void Save(Stylesheet entity) + public override void Save(IStylesheet entity) { - base.Save(entity); + // TODO: Casting :/ Do we need GetFileContent below? Need to look into it later + var stylesheet = (Stylesheet)entity; + + base.Save(stylesheet); // ensure that from now on, content is lazy-loaded - if (entity.GetFileContent == null) - entity.GetFileContent = file => GetFileContent(file.OriginalPath); + if (stylesheet.GetFileContent == null) + stylesheet.GetFileContent = file => GetFileContent(file.OriginalPath); } - public override IEnumerable GetMany(params string[] ids) + public override IEnumerable GetMany(params string[] ids) { //ensure they are de-duplicated, easy win if people don't do this as this can cause many excess queries ids = ids @@ -92,14 +99,14 @@ namespace Umbraco.Core.Persistence.Repositories.Implement /// If null or not specified, will return the stylesheets at the root path relative to the IFileSystem /// /// - public IEnumerable GetStylesheetsAtPath(string rootPath = null) + public IEnumerable GetStylesheetsAtPath(string rootPath = null) { return FileSystem.GetFiles(rootPath ?? string.Empty, "*.css").Select(Get); } private static readonly List ValidExtensions = new List { "css" }; - public bool ValidateStylesheet(Stylesheet stylesheet) + public bool ValidateStylesheet(IStylesheet stylesheet) { // get full path string fullPath; @@ -115,8 +122,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement // validate path and extension var validDir = SystemDirectories.Css; - var isValidPath = Current.IOHelper.VerifyEditPath(fullPath, validDir); - var isValidExtension = Current.IOHelper.VerifyFileExtension(stylesheet.Path, ValidExtensions); + var isValidPath = _ioHelper.VerifyEditPath(fullPath, validDir); + var isValidExtension = _ioHelper.VerifyFileExtension(stylesheet.Path, ValidExtensions); return isValidPath && isValidExtension; } diff --git a/src/Umbraco.Core/Services/IFileService.cs b/src/Umbraco.Core/Services/IFileService.cs index 5fe52559ee..eba7b98ef2 100644 --- a/src/Umbraco.Core/Services/IFileService.cs +++ b/src/Umbraco.Core/Services/IFileService.cs @@ -31,21 +31,21 @@ namespace Umbraco.Core.Services /// Gets a list of all objects /// /// An enumerable list of objects - IEnumerable GetStylesheets(params string[] names); + IEnumerable GetStylesheets(params string[] names); /// /// Gets a object by its name /// /// Name of the stylesheet incl. extension /// A object - Stylesheet GetStylesheetByName(string name); + IStylesheet GetStylesheetByName(string name); /// /// Saves a /// /// to save /// Optional id of the user saving the stylesheet - void SaveStylesheet(Stylesheet stylesheet, int userId = Constants.Security.SuperUserId); + void SaveStylesheet(IStylesheet stylesheet, int userId = Constants.Security.SuperUserId); /// /// Deletes a stylesheet by its name @@ -59,7 +59,7 @@ namespace Umbraco.Core.Services /// /// to validate /// True if Stylesheet is valid, otherwise false - bool ValidateStylesheet(Stylesheet stylesheet); + bool ValidateStylesheet(IStylesheet stylesheet); /// /// Gets a list of all objects diff --git a/src/Umbraco.Core/Services/Implement/FileService.cs b/src/Umbraco.Core/Services/Implement/FileService.cs index 2cdff9a8e4..a6615ca574 100644 --- a/src/Umbraco.Core/Services/Implement/FileService.cs +++ b/src/Umbraco.Core/Services/Implement/FileService.cs @@ -49,7 +49,7 @@ namespace Umbraco.Core.Services.Implement /// Gets a list of all objects /// /// An enumerable list of objects - public IEnumerable GetStylesheets(params string[] names) + public IEnumerable GetStylesheets(params string[] names) { using (var scope = ScopeProvider.CreateScope(autoComplete: true)) { @@ -62,7 +62,7 @@ namespace Umbraco.Core.Services.Implement /// /// Name of the stylesheet incl. extension /// A object - public Stylesheet GetStylesheetByName(string name) + public IStylesheet GetStylesheetByName(string name) { using (var scope = ScopeProvider.CreateScope(autoComplete: true)) { @@ -75,11 +75,11 @@ namespace Umbraco.Core.Services.Implement /// /// to save /// - public void SaveStylesheet(Stylesheet stylesheet, int userId = Constants.Security.SuperUserId) + public void SaveStylesheet(IStylesheet stylesheet, int userId = Constants.Security.SuperUserId) { using (var scope = ScopeProvider.CreateScope()) { - var saveEventArgs = new SaveEventArgs(stylesheet); + var saveEventArgs = new SaveEventArgs(stylesheet); if (scope.Events.DispatchCancelable(SavingStylesheet, this, saveEventArgs)) { scope.Complete(); @@ -91,7 +91,7 @@ namespace Umbraco.Core.Services.Implement saveEventArgs.CanCancel = false; scope.Events.Dispatch(SavedStylesheet, this, saveEventArgs); - Audit(AuditType.Save, userId, -1, ObjectTypes.GetName(UmbracoObjectTypes.Stylesheet)); + Audit(AuditType.Save, userId, -1, UmbracoObjectTypes.Stylesheet.GetName()); scope.Complete(); } } @@ -112,7 +112,7 @@ namespace Umbraco.Core.Services.Implement return; } - var deleteEventArgs = new DeleteEventArgs(stylesheet); + var deleteEventArgs = new DeleteEventArgs(stylesheet); if (scope.Events.DispatchCancelable(DeletingStylesheet, this, deleteEventArgs)) { scope.Complete(); @@ -123,7 +123,7 @@ namespace Umbraco.Core.Services.Implement deleteEventArgs.CanCancel = false; scope.Events.Dispatch(DeletedStylesheet, this, deleteEventArgs); - Audit(AuditType.Delete, userId, -1, ObjectTypes.GetName(UmbracoObjectTypes.Stylesheet)); + Audit(AuditType.Delete, userId, -1, UmbracoObjectTypes.Stylesheet.GetName()); scope.Complete(); } } @@ -133,7 +133,7 @@ namespace Umbraco.Core.Services.Implement /// /// to validate /// True if Stylesheet is valid, otherwise false - public bool ValidateStylesheet(Stylesheet stylesheet) + public bool ValidateStylesheet(IStylesheet stylesheet) { using (var scope = ScopeProvider.CreateScope(autoComplete: true)) { @@ -1116,12 +1116,12 @@ namespace Umbraco.Core.Services.Implement /// /// Occurs before Delete /// - public static event TypedEventHandler> DeletingStylesheet; + public static event TypedEventHandler> DeletingStylesheet; /// /// Occurs after Delete /// - public static event TypedEventHandler> DeletedStylesheet; + public static event TypedEventHandler> DeletedStylesheet; /// /// Occurs before Save @@ -1146,12 +1146,12 @@ namespace Umbraco.Core.Services.Implement /// /// Occurs before Save /// - public static event TypedEventHandler> SavingStylesheet; + public static event TypedEventHandler> SavingStylesheet; /// /// Occurs after Save /// - public static event TypedEventHandler> SavedStylesheet; + public static event TypedEventHandler> SavedStylesheet; /// /// Occurs before Save diff --git a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs index 6fae1d4749..2358fb257d 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/StylesheetRepositoryTest.cs @@ -6,6 +6,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core.IO; using Umbraco.Core.Models; +using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.Repositories.Implement; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; @@ -30,6 +31,11 @@ namespace Umbraco.Tests.Persistence.Repositories _fileSystem.AddFile("styles.css", stream); } + private IStylesheetRepository CreateRepository() + { + return new StylesheetRepository(_fileSystems, new IOHelper()); + } + [Test] public void Can_Instantiate_Repository() { @@ -37,7 +43,7 @@ namespace Umbraco.Tests.Persistence.Repositories using (ScopeProvider.CreateScope()) { // Act - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); // Assert @@ -51,7 +57,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); // Act var stylesheet = new Stylesheet("test-add.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; @@ -69,7 +75,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); // Act var stylesheet = new Stylesheet("test-update.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; @@ -96,10 +102,10 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); // Act - var stylesheet = new Stylesheet("test-update.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; + IStylesheet stylesheet = new Stylesheet("test-update.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; repository.Save(stylesheet); @@ -123,7 +129,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); // Act var stylesheet = new Stylesheet("test-update.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; @@ -142,7 +148,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); // Act var stylesheet = new Stylesheet("test-delete.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; @@ -163,7 +169,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); // Act var stylesheet = repository.Get("styles.css"); @@ -182,7 +188,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); var stylesheet = new Stylesheet("styles-v2.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; repository.Save(stylesheet); @@ -205,7 +211,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); var stylesheet = new Stylesheet("styles-v2.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; repository.Save(stylesheet); @@ -228,7 +234,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Arrange using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); // Act var exists = repository.Exists("styles.css"); @@ -245,9 +251,9 @@ namespace Umbraco.Tests.Persistence.Repositories using (ScopeProvider.CreateScope()) { - var repository = new StylesheetRepository(_fileSystems); + var repository = CreateRepository(); - var stylesheet = new Stylesheet("test-path-1.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; + IStylesheet stylesheet = new Stylesheet("test-path-1.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; repository.Save(stylesheet); Assert.IsTrue(_fileSystem.FileExists("test-path-1.css")); diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index b9fd0f6640..5b0e486a52 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -99,6 +99,8 @@ namespace Umbraco.Tests.Testing protected ILogger Logger => Factory.GetInstance(); + protected IIOHelper IOHelper { get; private set; } + protected IProfiler Profiler => Factory.GetInstance(); protected virtual IProfilingLogger ProfilingLogger => Factory.GetInstance(); @@ -129,6 +131,7 @@ namespace Umbraco.Tests.Testing var (logger, profiler) = GetLoggers(Options.Logger); var proflogger = new ProfilingLogger(logger, profiler); + IOHelper = new IOHelper(); var appCaches = GetAppCaches(); var globalSettings = SettingsForTests.GetDefaultGlobalSettings(); var typeLoader = GetTypeLoader(appCaches.RuntimeCache, globalSettings, proflogger, Options.TypeLoader); @@ -137,6 +140,7 @@ namespace Umbraco.Tests.Testing Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + Composition.RegisterUnique(IOHelper); Composition.RegisterUnique(typeLoader); Composition.RegisterUnique(logger); Composition.RegisterUnique(profiler); diff --git a/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs b/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs index 3b2cf3e23d..c56b7a094f 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs @@ -380,8 +380,8 @@ namespace Umbraco.Web.Cache } // TODO: our weird events handling wants this for now - private void FileService_DeletedStylesheet(IFileService sender, DeleteEventArgs e) { } - private void FileService_SavedStylesheet(IFileService sender, SaveEventArgs e) { } + private void FileService_DeletedStylesheet(IFileService sender, DeleteEventArgs e) { } + private void FileService_SavedStylesheet(IFileService sender, SaveEventArgs e) { } #endregion diff --git a/src/Umbraco.Web/Editors/CodeFileController.cs b/src/Umbraco.Web/Editors/CodeFileController.cs index ae870f695e..c5ded5cada 100644 --- a/src/Umbraco.Web/Editors/CodeFileController.cs +++ b/src/Umbraco.Web/Editors/CodeFileController.cs @@ -190,7 +190,7 @@ namespace Umbraco.Web.Editors var stylesheet = Services.FileService.GetStylesheetByName(virtualPath); if (stylesheet != null) { - var display = Mapper.Map(stylesheet); + var display = Mapper.Map(stylesheet); display.FileType = Core.Constants.Trees.Stylesheets; display.Path = Url.GetTreePathFromFilePath(stylesheet.Path); display.Id = System.Web.HttpUtility.UrlEncode(stylesheet.Path); @@ -511,7 +511,7 @@ namespace Umbraco.Web.Editors name => new Script(name)); } - private Stylesheet CreateOrUpdateStylesheet(CodeFileDisplay display) + private IStylesheet CreateOrUpdateStylesheet(CodeFileDisplay display) { return CreateOrUpdateFile(display, ".css", Current.FileSystems.StylesheetsFileSystem, name => Services.FileService.GetStylesheetByName(name), @@ -521,7 +521,7 @@ namespace Umbraco.Web.Editors } private T CreateOrUpdateFile(CodeFileDisplay display, string extension, IFileSystem fileSystem, - Func getFileByName, Action saveFile, Func createFile) where T : Core.Models.File + Func getFileByName, Action saveFile, Func createFile) where T : Core.Models.IFile { //must always end with the correct extension display.Name = EnsureCorrectFileExtension(display.Name, extension); From 545a427d1165da1b49b22b7134a14140719ffa13 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 12 Nov 2019 13:49:56 +1100 Subject: [PATCH 02/11] abstracts out IScript, stops casting stuff --- src/Umbraco.Abstractions/Models/IScript.cs | 7 ++ src/Umbraco.Abstractions/Models/Script.cs | 7 +- .../Repositories/IScriptRepository.cs | 7 +- .../Repositories/IStylesheetRepository.cs | 3 + .../Implement/ScriptRepository.cs | 29 +++--- .../Implement/StylesheetRepository.cs | 2 +- src/Umbraco.Core/Services/IFileService.cs | 44 ++++----- .../Services/Implement/FileService.cs | 90 ++++++------------- .../Repositories/ScriptRepositoryTest.cs | 30 ++++--- src/Umbraco.Web/Editors/CodeFileController.cs | 4 +- .../Models/Mapping/CodeFileMapDefinition.cs | 16 ++-- 11 files changed, 110 insertions(+), 129 deletions(-) create mode 100644 src/Umbraco.Abstractions/Models/IScript.cs diff --git a/src/Umbraco.Abstractions/Models/IScript.cs b/src/Umbraco.Abstractions/Models/IScript.cs new file mode 100644 index 0000000000..9fdc321107 --- /dev/null +++ b/src/Umbraco.Abstractions/Models/IScript.cs @@ -0,0 +1,7 @@ +namespace Umbraco.Core.Models +{ + public interface IScript : IFile + { + + } +} diff --git a/src/Umbraco.Abstractions/Models/Script.cs b/src/Umbraco.Abstractions/Models/Script.cs index b6e49f72ee..be96c04ddd 100644 --- a/src/Umbraco.Abstractions/Models/Script.cs +++ b/src/Umbraco.Abstractions/Models/Script.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.Models /// [Serializable] [DataContract(IsReference = true)] - public class Script : File + public class Script : File, IScript { public Script(string path) : this(path, (Func) null) @@ -25,9 +25,6 @@ namespace Umbraco.Core.Models /// /// Overrides the default Entity identity check. /// - public override bool HasIdentity - { - get { return string.IsNullOrEmpty(Path) == false; } - } + public override bool HasIdentity => string.IsNullOrEmpty(Path) == false; } } diff --git a/src/Umbraco.Core/Persistence/Repositories/IScriptRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IScriptRepository.cs index ea88cb7618..70226777b5 100644 --- a/src/Umbraco.Core/Persistence/Repositories/IScriptRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/IScriptRepository.cs @@ -3,11 +3,14 @@ using Umbraco.Core.Models; namespace Umbraco.Core.Persistence.Repositories { - public interface IScriptRepository : IReadRepository, IWriteRepository