second commit of everything that we want to add to core for Deploy, have moved stuff to where they should go, probably need to review if the GridValue should be in models though or if we already have this.

This commit is contained in:
Shannon
2017-01-16 20:45:08 +11:00
parent d2837b9649
commit d24541fce4
25 changed files with 624 additions and 93 deletions

View File

@@ -0,0 +1,22 @@
using System.IO;
using System.Text;
using System.Xml.Linq;
namespace Umbraco.Core.Serialization
{
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);
}
}
}

View File

@@ -1,6 +1,4 @@
using System.IO;
using System.Text;
using System.Xml.Linq;
namespace Umbraco.Core.Serialization
{
@@ -20,20 +18,4 @@ namespace Umbraco.Core.Serialization
#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);
}
}
}

View File

@@ -4,26 +4,6 @@ using Newtonsoft.Json.Linq;
namespace Umbraco.Core.Serialization
{
public class UdiRangeJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return typeof(UdiRange).IsAssignableFrom(objectType);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue(value.ToString());
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var jo = JToken.ReadFrom(reader);
var val = jo.ToObject<string>();
return val == null ? null : UdiRange.Parse(val);
}
}
public class UdiJsonConverter : JsonConverter
{

View File

@@ -0,0 +1,26 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Umbraco.Core.Serialization
{
public class UdiRangeJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return typeof(UdiRange).IsAssignableFrom(objectType);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue(value.ToString());
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var jo = JToken.ReadFrom(reader);
var val = jo.ToObject<string>();
return val == null ? null : UdiRange.Parse(val);
}
}
}