Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
228 lines (185 loc) · 6 KB
/
Copy pathProgram.cs
File metadata and controls
228 lines (185 loc) · 6 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
using System;
using System.Collections.Generic;
using System.Reflection;
using Tug.Ext;
using Tug.Ext.Provider;
using Tug.Ext.Util;
using static System.Console;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
WriteLine("Hello World!");
WriteLine("Found the following FooProviderXs:");
var femX = new FooExtManagerX();
foreach (var e in femX.FoundProviders)
WriteLine($" * {e}");
WriteLine();
WriteLine("Found the following FooProviders:");
var fem = new FooExtManager();
foreach (var e in fem.FoundExtensionNames)
WriteLine($" * {e}");
WriteLine();
}
}
public interface IFooExtension : IExtension
{ }
public class FooExtensionAttribute : ExtensionAttribute
{
protected override string Name
{ get; }
}
public class FooExtManager : ExtManagerBase<IFooExtension, FooExtensionAttribute>
{
public FooExtManager()
{
base.AddBuiltIns(typeof(FooExtManagerX).GetTypeInfo().Assembly);
}
}
[FooExtension]
public class FooBarExtension : IFooExtension
{
public FooBarExtension()
{
WriteLine("FooBarProvider - CONSTRUCTED");
}
public IEnumerable<ExtParameterInfo> DescribeParameters()
{
return new ExtParameterInfo[0];
}
}
public interface IThingy : IProviderProduct
{ }
public interface IThingyProvider : IProviderExtension<IThingy>
{ }
public class ThingyProviderAttribute : ExtensionAttribute
{
public ThingyProviderAttribute(string name)
{
Name = name;
}
protected override string Name
{ get; }
}
public class ThingyExtManager : ExtManagerBase<IThingyProvider, ThingyProviderAttribute>
{ }
public class MyThingy : IThingy
{
bool IProviderProduct.IsDisposed
{
get
{
throw new NotImplementedException();
}
}
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects).
}
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
// TODO: set large fields to null.
disposedValue = true;
}
}
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
// ~MyThingy() {
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
// Dispose(false);
// }
// This code added to correctly implement the disposable pattern.
void IDisposable.Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
// TODO: uncomment the following line if the finalizer is overridden above.
// GC.SuppressFinalize(this);
}
#endregion
}
[ThingyProvider("MyThingy")]
public class MyThingyProvider : IThingyProvider
{
public IEnumerable<ExtParameterInfo> DescribeParameters()
{
throw new NotImplementedException();
}
public IThingy Produce()
{
throw new NotImplementedException();
}
public void SetParameters(IDictionary<string, object> productParams)
{
throw new NotImplementedException();
}
}
public interface IFooX : IExtension
{
void DoFoo();
}
public interface IFooProviderX : IExtProviderX<IFooX>
{ }
public class FooExtManagerX : ExtManagerBaseX<IFooX, IFooProviderX>
{
public FooExtManagerX()
{
base.AddBuiltIns(typeof(FooExtManagerX).GetTypeInfo().Assembly);
}
}
public class FooBarX : IFooX
{
public bool IsDisposed
{ get; private set; }
public void DoFoo() => WriteLine("FooBar!");
void IFooX.DoFoo()
{
throw new NotImplementedException();
}
#region IDisposable Support
protected virtual void Dispose(bool disposing)
{
if (!IsDisposed)
{
if (disposing)
{
// TODO: dispose managed state (managed objects).
}
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
// TODO: set large fields to null.
IsDisposed = true;
}
}
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
// ~FooBar() {
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
// Dispose(false);
// }
// This code added to correctly implement the disposable pattern.
// void IDisposable.Dispose()
// {
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
// Dispose(true);
// // TODO: uncomment the following line if the finalizer is overridden above.
// // GC.SuppressFinalize(this);
// }
#endregion
}
public class FooBarProviderX : IFooProviderX
{
ExtInfo IExtProviderX<IFooX>.Describe()
{ return new ExtInfo(nameof(FooBarX)); }
IEnumerable<ExtParameterInfo> IExtProviderX<IFooX>.DescribeParameters()
{ return new ExtParameterInfo[0]; }
IFooX IExtProviderX<IFooX>.Provide(IDictionary<string, object> initParams)
{
return new FooBarX();
}
}
}