diff --git a/.hgignore b/.hgignore index 6dff0fc474..dafb4b142a 100644 --- a/.hgignore +++ b/.hgignore @@ -51,3 +51,4 @@ src/Umbraco.Web.UI/Views/*.cshtml src/Umbraco.Web.UI/Views/*.vbhtml src/Umbraco.Tests/config/umbracoSettings.config src/Umbraco.Web.UI/App_Plugins/* +src/Packages/* \ No newline at end of file diff --git a/src/.nuget/NuGet.Config b/src/.nuget/NuGet.Config new file mode 100644 index 0000000000..6a318ad9b7 --- /dev/null +++ b/src/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/.nuget/NuGet.exe b/src/.nuget/NuGet.exe new file mode 100644 index 0000000000..ddc91051bc Binary files /dev/null and b/src/.nuget/NuGet.exe differ diff --git a/src/.nuget/NuGet.targets b/src/.nuget/NuGet.targets new file mode 100644 index 0000000000..b44341f9b2 --- /dev/null +++ b/src/.nuget/NuGet.targets @@ -0,0 +1,150 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + + + + + $(SolutionDir).nuget + packages.config + + + + + $(NuGetToolsPath)\nuget.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 $(NuGetExePath) + + $(TargetDir.Trim('\\')) + + -RequireConsent + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " + $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(ResolveReferencesDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs new file mode 100644 index 0000000000..c75614a2db --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs @@ -0,0 +1,9 @@ +using Umbraco.Core.Models; + +namespace Umbraco.Core.Persistence.Repositories +{ + public interface IMacroRepository : IRepository + { + + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/MacroRepository.cs b/src/Umbraco.Core/Persistence/Repositories/MacroRepository.cs new file mode 100644 index 0000000000..cf83fe283b --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/MacroRepository.cs @@ -0,0 +1,67 @@ +using System.Collections.Generic; +using Umbraco.Core.Models; +using Umbraco.Core.Persistence.Caching; +using Umbraco.Core.Persistence.Querying; +using Umbraco.Core.Persistence.UnitOfWork; + +namespace Umbraco.Core.Persistence.Repositories +{ + internal class MacroRepository : RepositoryBase, IMacroRepository + { + public MacroRepository(IUnitOfWork work) : base(work) + { + } + + public MacroRepository(IUnitOfWork work, IRepositoryCacheProvider cache) : base(work, cache) + { + } + + #region Overrides of RepositoryBase + + protected override IMacro PerformGet(string id) + { + throw new System.NotImplementedException(); + } + + protected override IEnumerable PerformGetAll(params string[] ids) + { + throw new System.NotImplementedException(); + } + + protected override IEnumerable PerformGetByQuery(IQuery query) + { + throw new System.NotImplementedException(); + } + + protected override bool PerformExists(string id) + { + throw new System.NotImplementedException(); + } + + protected override int PerformCount(IQuery query) + { + throw new System.NotImplementedException(); + } + + #endregion + + #region Overrides of IUnitOfWorkRepository + + protected override void PersistNewItem(IMacro item) + { + throw new System.NotImplementedException(); + } + + protected override void PersistUpdatedItem(IMacro item) + { + throw new System.NotImplementedException(); + } + + protected override void PersistDeletedItem(IMacro item) + { + throw new System.NotImplementedException(); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/AbstractSerializationService.cs b/src/Umbraco.Core/Serialization/AbstractSerializationService.cs new file mode 100644 index 0000000000..6e8ee40dad --- /dev/null +++ b/src/Umbraco.Core/Serialization/AbstractSerializationService.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace Umbraco.Core.Serialization +{ + public abstract class AbstractSerializationService + { + /// + /// A sequence of registered with this serialization service. + /// + public IEnumerable Formatters { get; set; } + + /// + /// Finds an with a matching , and deserializes the to an object graph. + /// + /// + /// + /// + /// + public abstract object FromStream(Stream input, Type outputType, string intent = null); + + /// + /// Finds an with a matching , and serializes the object graph to an . + /// + /// + /// + /// + public abstract IStreamedResult ToStream(object input, string intent = null); + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/Formatter.cs b/src/Umbraco.Core/Serialization/Formatter.cs new file mode 100644 index 0000000000..286034dccb --- /dev/null +++ b/src/Umbraco.Core/Serialization/Formatter.cs @@ -0,0 +1,21 @@ +using System; + +namespace Umbraco.Core.Serialization +{ + public class Formatter : IFormatter + { + #region Implementation of IFormatter + + public string Intent + { + get { throw new NotImplementedException(); } + } + + public ISerializer Serializer + { + get { throw new NotImplementedException(); } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/IFormatter.cs b/src/Umbraco.Core/Serialization/IFormatter.cs new file mode 100644 index 0000000000..f0719481a4 --- /dev/null +++ b/src/Umbraco.Core/Serialization/IFormatter.cs @@ -0,0 +1,9 @@ +namespace Umbraco.Core.Serialization +{ + public interface IFormatter + { + string Intent { get; } + + ISerializer Serializer { get; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/ISerializer.cs b/src/Umbraco.Core/Serialization/ISerializer.cs new file mode 100644 index 0000000000..714aec540a --- /dev/null +++ b/src/Umbraco.Core/Serialization/ISerializer.cs @@ -0,0 +1,12 @@ +using System; +using System.IO; + +namespace Umbraco.Core.Serialization +{ + public interface ISerializer + { + object FromStream(Stream input, Type outputType); + + IStreamedResult ToStream(object input); + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/IStreamedResult.cs b/src/Umbraco.Core/Serialization/IStreamedResult.cs new file mode 100644 index 0000000000..a1001c5696 --- /dev/null +++ b/src/Umbraco.Core/Serialization/IStreamedResult.cs @@ -0,0 +1,10 @@ +using System.IO; + +namespace Umbraco.Core.Serialization +{ + public interface IStreamedResult + { + Stream ResultStream { get; } + bool Success { get; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/SerializationExtensions.cs b/src/Umbraco.Core/Serialization/SerializationExtensions.cs new file mode 100644 index 0000000000..be14b4c1c3 --- /dev/null +++ b/src/Umbraco.Core/Serialization/SerializationExtensions.cs @@ -0,0 +1,40 @@ +using System; +using System.IO; +using System.Text; + +namespace Umbraco.Core.Serialization +{ + public static class SerializationExtensions + { + public static T FromJson(this AbstractSerializationService service, string json, string intent = null) + { + if (string.IsNullOrWhiteSpace(json)) return default(T); + return (T)service.FromJson(json, typeof(T), intent); + } + + public static T FromJson(this ISerializer serializer, string json, string intent = null) + { + if (string.IsNullOrWhiteSpace(json)) return default(T); + return (T)serializer.FromJson(json, typeof(T)); + } + + public static object FromJson(this ISerializer serializer, string json, Type outputType) + { + if (string.IsNullOrWhiteSpace(json)) return outputType.GetDefaultValue(); + var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)); + return serializer.FromStream(stream, outputType); + } + + public static object FromJson(this AbstractSerializationService service, string json, Type outputType, string intent = null) + { + if (string.IsNullOrWhiteSpace(json)) return outputType.GetDefaultValue(); + var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)); + return service.FromStream(stream, outputType, intent); + } + + public static string ToJson(this AbstractSerializationService service, object input, string intent = null) + { + return StreamResultExtensions.ToJsonString(service.ToStream(input, intent).ResultStream); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/SerializationService.cs b/src/Umbraco.Core/Serialization/SerializationService.cs new file mode 100644 index 0000000000..886b6ba473 --- /dev/null +++ b/src/Umbraco.Core/Serialization/SerializationService.cs @@ -0,0 +1,45 @@ +using System; +using System.IO; + +namespace Umbraco.Core.Serialization +{ + public class SerializationService : AbstractSerializationService + { + private readonly ISerializer _serializer; + + public SerializationService(ISerializer serializer) + { + _serializer = serializer; + } + + #region Overrides of AbstractSerializationService + + /// + /// Finds an with a matching , and deserializes the to an object graph. + /// + /// + /// + /// + /// + public override object FromStream(Stream input, Type outputType, string intent = null) + { + if (input.CanSeek && input.Position > 0) input.Seek(0, SeekOrigin.Begin); + return _serializer.FromStream(input, outputType); + } + + /// + /// Finds an with a matching , and serializes the object graph to an . + /// + /// + /// + /// + public override IStreamedResult ToStream(object input, string intent = null) + { + return _serializer.ToStream(input); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/ServiceStackJsonSerializer.cs b/src/Umbraco.Core/Serialization/ServiceStackJsonSerializer.cs new file mode 100644 index 0000000000..11928d9af0 --- /dev/null +++ b/src/Umbraco.Core/Serialization/ServiceStackJsonSerializer.cs @@ -0,0 +1,29 @@ +using System; +using System.IO; +using ServiceStack.Text; + +namespace Umbraco.Core.Serialization +{ + public class ServiceStackJsonSerializer : ISerializer + { + public ServiceStackJsonSerializer() + { + JsConfig.DateHandler = JsonDateHandler.ISO8601; + JsConfig.ExcludeTypeInfo = false; + JsConfig.IncludeNullValues = true; + JsConfig.ThrowOnDeserializationError = true; + } + + public object FromStream(Stream input, Type outputType) + { + return JsonSerializer.DeserializeFromStream(outputType, input); + } + + public IStreamedResult ToStream(object input) + { + var ms = new MemoryStream(); + JsonSerializer.SerializeToStream(input, ms); + return new StreamedResult(ms, true); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/ServiceStackXmlSerializer.cs b/src/Umbraco.Core/Serialization/ServiceStackXmlSerializer.cs new file mode 100644 index 0000000000..b7abf29328 --- /dev/null +++ b/src/Umbraco.Core/Serialization/ServiceStackXmlSerializer.cs @@ -0,0 +1,26 @@ +using System; +using System.IO; +using System.Text; +using ServiceStack.Text; + +namespace Umbraco.Core.Serialization +{ + public class ServiceStackXmlSerializer : ISerializer + { + public ServiceStackXmlSerializer() + { + } + + public object FromStream(Stream input, Type outputType) + { + return XmlSerializer.DeserializeFromStream(outputType, input); + } + + public IStreamedResult ToStream(object input) + { + string output = XmlSerializer.SerializeToString(input); + var stream = new MemoryStream(Encoding.UTF8.GetBytes(output)); + return new StreamedResult(stream, true); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Serialization/StreamedResult.cs b/src/Umbraco.Core/Serialization/StreamedResult.cs new file mode 100644 index 0000000000..9b73fd06bf --- /dev/null +++ b/src/Umbraco.Core/Serialization/StreamedResult.cs @@ -0,0 +1,39 @@ +using System.IO; +using System.Text; +using System.Xml.Linq; + +namespace Umbraco.Core.Serialization +{ + public class StreamedResult : IStreamedResult + { + internal StreamedResult(Stream stream, bool success) + { + ResultStream = stream; + Success = success; + } + + #region Implementation of IStreamedResult + + public Stream ResultStream { get; protected set; } + + public bool Success { get; protected set; } + + #endregion + } + + public static class StreamResultExtensions + { + public static string ToJsonString(this Stream stream) + { + byte[] bytes = new byte[stream.Length]; + stream.Position = 0; + stream.Read(bytes, 0, (int)stream.Length); + return Encoding.UTF8.GetString(bytes); + } + + public static XDocument ToXDoc(this Stream stream) + { + return XDocument.Load(stream); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 8a3d46eb74..9529a5b973 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -12,6 +12,8 @@ Umbraco.Core v4.0 512 + ..\ + true true @@ -34,6 +36,9 @@ ..\packages\log4net.2.0.0\lib\net40-full\log4net.dll + + ..\packages\ServiceStack.Text.3.9.21\lib\net35\ServiceStack.Text.dll + @@ -103,8 +108,10 @@ + + @@ -271,6 +278,16 @@ + + + + + + + + + + @@ -316,6 +333,7 @@ + + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/developer/Macros/editMacro.aspx b/src/Umbraco.Web.UI/umbraco/developer/Macros/editMacro.aspx index b696c6d594..2510cb45b2 100644 --- a/src/Umbraco.Web.UI/umbraco/developer/Macros/editMacro.aspx +++ b/src/Umbraco.Web.UI/umbraco/developer/Macros/editMacro.aspx @@ -173,10 +173,10 @@ - + - + <%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> - - - +