BililiveRecorder/BililiveRecorder.Core/Scripting/Runtime/JintDotnet.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2022-05-12 17:29:34 +08:00
using System;
using System.Collections.Specialized;
using System.Net;
using System.Net.Http;
using System.Web;
2022-05-11 00:20:57 +08:00
using Jint;
using Jint.Native.Object;
2023-01-14 22:43:29 +08:00
using Jint.Runtime.Descriptors;
2022-05-12 17:29:34 +08:00
using Jint.Runtime.Interop;
2022-05-11 00:20:57 +08:00
namespace BililiveRecorder.Core.Scripting.Runtime
{
internal class JintDotnet : ObjectInstance
2022-05-11 00:20:57 +08:00
{
public JintDotnet(Engine engine) : base(engine)
{
}
2022-05-12 17:29:34 +08:00
protected override void Initialize()
{
2023-01-14 22:43:29 +08:00
this.FastSetProperty("Dns", new PropertyDescriptor(TypeReference.CreateTypeReference(this._engine, typeof(Dns)), false, false, false));
2022-05-12 17:29:34 +08:00
AddTypeAsProperty<Uri>();
AddTypeAsProperty<UriBuilder>();
AddTypeAsProperty<HttpUtility>();
AddTypeAsProperty<NameValueCollection>();
AddTypeAsProperty<HttpClient>();
AddTypeAsProperty<HttpClientHandler>();
AddTypeAsProperty<HttpCompletionOption>();
AddTypeAsProperty<HttpRequestMessage>();
AddTypeAsProperty<HttpMethod>();
AddTypeAsProperty<ByteArrayContent>();
AddTypeAsProperty<StringContent>();
AddTypeAsProperty<FormUrlEncodedContent>();
2023-01-14 22:43:29 +08:00
void AddTypeAsProperty<T>() => this.FastSetProperty(typeof(T).Name, new PropertyDescriptor(TypeReference.CreateTypeReference<T>(this._engine), false, false, false));
2022-05-12 17:29:34 +08:00
}
2022-05-11 00:20:57 +08:00
}
}