-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathApiItem.cs
More file actions
121 lines (105 loc) · 3.09 KB
/
Copy pathApiItem.cs
File metadata and controls
121 lines (105 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using QuantBox.APIProvider.UI;
using System;
using System.ComponentModel;
using XAPI;
namespace QuantBox.APIProvider.Single
{
#if NET48
using System.Drawing.Design;
#endif
/// <summary>
/// 由用户选择Dll,然后加载,得到
///
/// </summary>
public class ApiItem : ICloneable
{
public const string CATEGORY_INFO = "Information";
public const string CATEGORY_TYPE = "Type";
internal BindingList<UserItem> LinkedUserList;
internal BindingList<ServerItem> LinkedServerList;
private string _dllPath;
private string _typeName;
private IXApi CheckApi(string typeName, string dllPath)
{
if (string.IsNullOrEmpty(typeName))
{
TypeName = "XAPI.Callback.XApi, XAPI_CSharp";
return null;
}
var api = XApiHelper.CreateInstance(typeName, dllPath);
try
{
Type = api.GetApiTypes;
Name = api.GetApiName;
Version = api.GetApiVersion;
// 取公共部分
UseType = UseType & Type;
}
catch (Exception ex)
{
api = null;
Type = ApiType.None;
Name = ex.Message;
Version = "请使用depends检查一下是否缺少依赖";
UseType = ApiType.None;
}
return api;
}
#if NET48
[Editor(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
#endif
public string DllPath
{
get
{
return _dllPath;
}
set
{
_dllPath = value;
Api = CheckApi(_typeName, _dllPath);
}
}
public string TypeName
{
get
{
return _typeName;
}
set
{
_typeName = value;
Api = CheckApi(_typeName, _dllPath);
}
}
[Browsable(false)]
internal IXApi Api { get; set; }
[Category(CATEGORY_INFO)]
[ReadOnly(true)]
public string Name { get; set; }
[Category(CATEGORY_INFO)]
[ReadOnly(true)]
public string Version { get; set; }
[TypeConverter(typeof(UserItemConverter))]
public int User { get; set; }
[TypeConverter(typeof(ServerItemConverter))]
public int Server { get; set; }
public string LogPrefix { get; set; }
[Category(CATEGORY_TYPE)]
[ReadOnly(true)]
public ApiType Type { get; set; }
#if NET48
[Editor(typeof(ApiTypeSelectorEditor), typeof(UITypeEditor))]
#endif
[Category(CATEGORY_TYPE)]
public ApiType UseType { get; set; }
public override string ToString()
{
return string.Format("LogPrefix={0};UseType={1};Name={2}", LogPrefix, UseType, Name);
}
public object Clone()
{
return this.MemberwiseClone();
}
}
}