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:
22
src/Umbraco.Core/Serialization/StreamResultExtensions.cs
Normal file
22
src/Umbraco.Core/Serialization/StreamResultExtensions.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
26
src/Umbraco.Core/Serialization/UdiRangeJsonConverter.cs
Normal file
26
src/Umbraco.Core/Serialization/UdiRangeJsonConverter.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user