更改文件架构

This commit is contained in:
CortexCore
2023-06-07 18:38:07 +08:00
parent 93292b1a59
commit ed84166723
720 changed files with 297 additions and 65 deletions

View File

@@ -12,6 +12,10 @@ using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace BITKit
{
public class AppIsNotPlayingException : Exception
{
public override string Message => "Application Is Not Playing";
}
public class BITApp
{
[System.Serializable]

View File

@@ -0,0 +1,32 @@
#if UNITY
#else
using System.ComponentModel.DataAnnotations;
#endif
using System;
namespace BITKit
{
public interface ILog
{
int Id { get; }
string EntityName { get; }
public string Message { get; }
public string StackTrace { get; }
DateTime CreateTime { get; }
string CreateUser { get; }
}
[System.Serializable]
public record LogModel:ILog
{
#if UNITY
#else
[Key]
#endif
public int Id { get; set; }
public string EntityName { get; set; }
public string Message { get; set; }
public string StackTrace { get; set; }
public DateTime CreateTime { get; set; }=DateTime.Now;
public string CreateUser { get; set; } = nameof(BITKit);
};
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dbdc13ee7c5f4e6ea13f8a6786f74097
timeCreated: 1686107848

View File

@@ -0,0 +1,34 @@
namespace BITKit
{
[System.Serializable]
public record WeChatMessage
{
/// <summary>
/// WXPusher接口Token
/// </summary>
public string appToken = "AT_93EEY2WYtU9AQzMULFVXCUIKieixCbBc";
/// <summary>
/// 推送内容
/// </summary>
public string content;
/// <summary>
/// 消息摘要",//消息摘要显示在微信聊天页面或者模版消息卡片上限制长度100可以不传不传默认截取content前面的内容。
/// </summary>
public string summary;
/// <summary>
/// 内容类型 1表示文字 2表示html(只发送body标签内部的数据即可不包括body标签) 3表示markdown
/// </summary>
public int contentType = 1;
/// <summary>
/// 是否验证订阅时间true表示只推送给付费订阅用户false表示推送的时候不验证付费不验证用户订阅到期时间用户订阅过期了也能收到。
/// </summary>
public bool verifyPay = false;
/// <summary>
/// 推送用户的uid
/// </summary>
public string[] uids = new string[]
{
"UID_mjMsThbCofwk5YSDJvBegUv0X0jK",
};
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5cb892c46078490e904ad43dd6c7794c
timeCreated: 1686121360

View File

@@ -1,10 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using System.Net;
using Cysharp.Threading.Tasks;
using System.Threading;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
namespace BITKit.HttpNet
{
[System.Serializable]
@@ -13,26 +16,24 @@ namespace BITKit.HttpNet
System.Net.Http.HttpClient client = new();
public override async UniTask<string> GetAsync(string url, CancellationToken cancellationToken = default)
{
using (var response = await client.GetAsync(url))
{
return await response.Content.ReadAsStringAsync();
}
using var response = await client.GetAsync(url, cancellationToken);
return await response.Content.ReadAsStringAsync();
}
public override async UniTask<string> PostAsync<T>(string url, T value, CancellationToken cancellationToken = default)
{
HttpContent content = null;
switch (value)
HttpContent content = value switch
{
case string _string:
content = new StringContent(_string);
break;
default:
//content = new ByteArrayContent(.WriteAsBytes(value));
break;
}
string _string => new StringContent(_string,Encoding.Unicode,"application/json"),
_ => new StringContent(JsonConvert.SerializeObject(value),Encoding.Unicode,"application/json")
};
using var response = await client.PostAsync(url, content, cancellationToken);
return await response.Content.ReadAsStringAsync();
if (response.StatusCode is HttpStatusCode.OK)
{
return await response.Content.ReadAsStringAsync();
}
BIT4Log.Log<HttpClient>(response.StatusCode);
return response.StatusCode.ToString();
}
}
}

View File

@@ -36,5 +36,10 @@ namespace BITKit
Allow = false;
value = default;
}
public static implicit operator T(Optional<T> self)
{
return self.value;
}
}
}