File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+ using System . Threading . Tasks ;
6+ using System . Net ;
7+
8+ #pragma warning disable SYSLIB0014 // 类型或成员已过时
9+
10+ namespace Algorithm . Interop
11+ {
12+ public class Environment
13+ {
14+
15+ /// <summary>
16+ /// 核心文件路径
17+ /// </summary>
18+ public const string dll_path = "./Core/" ;
19+
20+ /// <summary>
21+ /// 云端 DLL 存储路径
22+ /// </summary>
23+ public const string cloudUrl = "https://source.catrol.cn/lib/Algorithm/Core/" ;
24+
25+ /// <summary>
26+ /// 库版本
27+ /// </summary>
28+ public const string version = "v1.0" ;
29+
30+ /// <summary>
31+ /// 核心文件文件名
32+ /// </summary>
33+ private readonly static List < string > CoreFiles = new ( )
34+ {
35+ "Math.dll" ,
36+ "Hash.dll"
37+ } ;
38+
39+ /// <summary>
40+ /// 检查环境是否就绪, 核心文件是否存在
41+ /// </summary>
42+ /// <returns>环境是否就绪</returns>
43+ public static bool CheckEnvironment ( )
44+ {
45+ foreach ( string fn in CoreFiles )
46+ {
47+ if ( ! File . Exists ( $ "{ dll_path } { fn } ") )
48+ return false ;
49+ }
50+ return true ;
51+ }
52+
53+ /// <summary>
54+ /// 安装环境
55+ /// </summary>
56+ public static void InstallEnvironment ( )
57+ {
58+ WebClient wc = new ( ) ;
59+ foreach ( string fn in CoreFiles )
60+ {
61+ if ( ! File . Exists ( $ "{ dll_path } { fn } ") )
62+ {
63+ wc . DownloadFile (
64+ new Uri ( $ "{ cloudUrl } { version } /{ fn } ", UriKind . Absolute ) ,
65+ Path . GetFullPath ( $ "{ dll_path } { fn } ") ) ;
66+ }
67+ }
68+ wc . Dispose ( ) ;
69+ }
70+ }
71+ }
72+
73+ #pragma warning restore SYSLIB0014 // 类型或成员已过时
You can’t perform that action at this time.
0 commit comments