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
|
|
|
|
|
{
|
2015-10-02 12:58:44 +03:00
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Not called in all contexts.")]
|
|
|
|
|
public static string ReadAsString(string name)
|
|
|
|
|
{
|
2017-12-23 04:03:53 +03:00
|
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
var content = assembly.GetManifestResourceStream(name);
|
|
|
|
|
using (var reader = new StreamReader(content))
|
2015-10-02 12:58:44 +03:00
|
|
|
|
{
|
2017-12-23 04:03:53 +03:00
|
|
|
|
var data = reader.ReadToEnd();
|
2015-10-02 12:58:44 +03:00
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2017-12-23 04:03:53 +03:00
|
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
var content = assembly.GetManifestResourceStream(name);
|
|
|
|
|
using (var reader = new StreamReader(content))
|
2015-10-01 04:13:20 +03:00
|
|
|
|
{
|
2017-12-23 04:03:53 +03:00
|
|
|
|
var data = reader.ReadToEnd();
|
2015-10-01 04:13:20 +03:00
|
|
|
|
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)
|
|
|
|
|
{
|
2017-12-23 04:03:53 +03:00
|
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
var content = assembly.GetManifestResourceStream(name);
|
|
|
|
|
using (var reader = new StreamReader(content))
|
2016-03-25 21:48:57 +03:00
|
|
|
|
{
|
2017-12-23 04:03:53 +03:00
|
|
|
|
var data = reader.ReadToEnd();
|
2016-03-25 21:48:57 +03:00
|
|
|
|
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)
|
|
|
|
|
{
|
2017-12-23 04:03:53 +03:00
|
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
var content = assembly.GetManifestResourceStream(name);
|
|
|
|
|
using (var reader = new StreamReader(content))
|
2016-01-27 03:12:04 +03:00
|
|
|
|
{
|
2017-12-23 04:03:53 +03:00
|
|
|
|
var data = reader.ReadToEnd();
|
2016-01-27 03:12:04 +03:00
|
|
|
|
return XElement.Parse(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-10-01 04:13:20 +03:00
|
|
|
|
}
|
|
|
|
|
}
|