@@ -10,10 +10,19 @@ namespace mysql_managed_interface
10
10
{
11
11
class MySQLHostManager : AppDomainManager , IManagedHost
12
12
{
13
+ private System . Collections . Generic . Dictionary < string , ICustomAssembly > functions = null ;
14
+ private string m_Assembly ;
15
+ private string m_Class ;
13
16
14
17
static void ADIDelegate ( string [ ] args )
15
18
{
19
+ //var asm = AppDomain.CurrentDomain.Load(args[0]);
20
+ }
16
21
22
+ void CurrentDomain_AssemblyLoad ( object sender , AssemblyLoadEventArgs args )
23
+ {
24
+
25
+ throw new NotImplementedException ( ) ;
17
26
}
18
27
19
28
public static StrongName CreateStrongName ( Assembly assembly )
@@ -42,27 +51,44 @@ public static StrongName CreateStrongName(Assembly assembly)
42
51
/// </summary>
43
52
public override void InitializeNewDomain ( AppDomainSetup appDomainInfo )
44
53
{
54
+ if ( appDomainInfo != null )
55
+ {
56
+ if ( appDomainInfo . AppDomainInitializerArguments . Length > 0 )
57
+ {
58
+ m_Assembly = appDomainInfo . AppDomainInitializerArguments [ 0 ] ;
59
+ }
60
+ if ( appDomainInfo . AppDomainInitializerArguments . Length > 1 )
61
+ {
62
+ m_Class = appDomainInfo . AppDomainInitializerArguments [ 1 ] ;
63
+ }
64
+ }
45
65
// let the unmanaged host know about us
46
66
InitializationFlags = AppDomainManagerInitializationOptions . RegisterWithHost ;
47
-
48
- return ;
67
+
68
+
49
69
}
50
70
51
71
public string CreateAppDomain ( string name )
72
+ {
73
+ return CreateAppDomain ( name , "" ) ;
74
+ }
75
+
76
+ public string CreateAppDomain ( string assemblyName , string className )
52
77
{
53
78
PermissionSet permissions = new PermissionSet ( PermissionState . None ) ;
54
- permissions . AddPermission ( new SecurityPermission ( PermissionState . Unrestricted ) ) ;
55
- permissions . AddPermission ( new UIPermission ( PermissionState . Unrestricted ) ) ;
79
+ permissions . AddPermission ( new SecurityPermission ( SecurityPermissionFlag . Execution ) ) ;
56
80
57
81
AppDomainSetup ads = new AppDomainSetup ( ) ;
58
82
ads . AppDomainInitializer = ADIDelegate ;
83
+ ads . AppDomainInitializerArguments = new string [ ] { assemblyName , className } ;
59
84
ads . ConfigurationFile = "mysqldotnet.config" ;
60
85
ads . PrivateBinPath = @"lib\plugin" ;
61
86
ads . PrivateBinPathProbe = "" ;
62
-
87
+
88
+ string AppDomainName = DateTime . Now . ToFileTime ( ) . ToString ( ) ;
63
89
64
90
return string . Format ( "{0}||{1}" , GetCLR ( ) , AppDomain . CreateDomain (
65
- name ,
91
+ AppDomainName ,
66
92
AppDomain . CurrentDomain . Evidence ,
67
93
ads ,
68
94
permissions ,
@@ -93,22 +119,40 @@ public void Write(string message)
93
119
public Int64 Run ( Int64 path )
94
120
{
95
121
return ( path * 3 ) ;
96
- //new FileIOPermission(PermissionState.Unrestricted).Assert();
97
- //string fullPath = Path.Combine(
98
- // Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
99
- // path);
100
- //CodeAccessPermission.RevertAssert();
101
-
102
- //new FileIOPermission(
103
- // FileIOPermissionAccess.Read | FileIOPermissionAccess.PathDiscovery,
104
- // fullPath).Assert();
105
- //AppDomain.CurrentDomain.ExecuteAssembly(fullPath);
106
- //CodeAccessPermission.RevertAssert();
107
122
}
108
123
109
124
public string GetCLR ( )
110
125
{
111
126
return string . Format ( "v{0}" , Environment . Version . ToString ( 3 ) ) ;
112
127
}
128
+
129
+ public long RunInteger ( string functionName , long value )
130
+ {
131
+ return functions [ functionName ] . RunInteger ( value ) ;
132
+ }
133
+
134
+ public long RunIntegers ( string functionName , long [ ] values )
135
+ {
136
+ return functions [ functionName ] . RunIntegers ( values ) ;
137
+ }
138
+ public double RunReal ( string functionName , double value )
139
+ {
140
+ return functions [ functionName ] . RunReal ( value ) ;
141
+ }
142
+
143
+ public double RunReals ( string functionName , double [ ] values )
144
+ {
145
+ return functions [ functionName ] . RunReals ( values ) ;
146
+ }
147
+
148
+ public string RunString ( string functionName , string value )
149
+ {
150
+ return functions [ functionName ] . RunString ( value ) ;
151
+ }
152
+
153
+ public string RunStrings ( string functionName , string [ ] values )
154
+ {
155
+ return functions [ functionName ] . RunStrings ( values ) ;
156
+ }
113
157
}
114
158
}
0 commit comments