2015-10-01 04:13:20 +03:00
|
|
|
|
// Copyright (c) .NET Foundation. All rights reserved.
|
|
|
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
|
|
2016-01-27 03:12:04 +03:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2015-10-01 04:13:20 +03:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
2016-01-27 03:12:04 +03:00
|
|
|
|
using System.Xml.Linq;
|
2015-10-01 04:13:20 +03:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.AspNet.WebHooks
|
|
|
|
|
{
|
|
|
|
|
internal static class EmbeddedResource
|
|
|
|
|
{
|
2016-01-27 03:12:04 +03:00
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Not called in all contexts.")]
|
2015-10-01 04:13:20 +03:00
|
|
|
|
public static JObject ReadAsJObject(string name)
|
|
|
|
|
{
|
|
|
|
|
Assembly asm = Assembly.GetExecutingAssembly();
|
|
|
|
|
Stream content = asm.GetManifestResourceStream(name);
|
|
|
|
|
using (StreamReader reader = new StreamReader(content))
|
|
|
|
|
{
|
|
|
|
|
string data = reader.ReadToEnd();
|
|
|
|
|
return JObject.Parse(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-27 03:12:04 +03:00
|
|
|
|
|
2016-03-25 21:48:57 +03:00
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Not called in all contexts.")]
|
|
|
|
|
public static JArray ReadAsJArray(string name)
|
|
|
|
|
{
|
|
|
|
|
Assembly asm = Assembly.GetExecutingAssembly();
|
|
|
|
|
Stream content = asm.GetManifestResourceStream(name);
|
|
|
|
|
using (StreamReader reader = new StreamReader(content))
|
|
|
|
|
{
|
|
|
|
|
string data = reader.ReadToEnd();
|
|
|
|
|
return JArray.Parse(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-27 03:12:04 +03:00
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Not called in all contexts.")]
|
|
|
|
|
public static XElement ReadAsJXElement(string name)
|
|
|
|
|
{
|
|
|
|
|
Assembly asm = Assembly.GetExecutingAssembly();
|
|
|
|
|
Stream content = asm.GetManifestResourceStream(name);
|
|
|
|
|
using (StreamReader reader = new StreamReader(content))
|
|
|
|
|
{
|
|
|
|
|
string data = reader.ReadToEnd();
|
|
|
|
|
return XElement.Parse(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-10-01 04:13:20 +03:00
|
|
|
|
}
|
|
|
|
|
}
|