本文整理汇总了C#中System.Resolver类的典型用法代码示例。如果您正苦于以下问题:C# Resolver类的具体用法?C# Resolver怎么用?C# Resolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resolver类属于System命名空间,在下文中一共展示了Resolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configuration
public void Configuration(IAppBuilder app) {
var serializer = CreateJsonSerializer();
GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);
var resolver = new Resolver(serializer);
GlobalHost.DependencyResolver.Register(typeof(IParameterResolver), () => resolver);
app.UseCors(new MyCorsOptions());
app.Map("/api/get-upload-folders", builder => builder.Run(InvokeGames));
app.Map("/signalr", map => {
var debug =
#if DEBUG
true;
#else
false;
#endif
var hubConfiguration = new HubConfiguration {
EnableDetailedErrors = debug
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch is already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
}
示例2: TestCache
public void TestCache() {
Resolver<ContentType> resolver = new Resolver<ContentType>();
resolver.Add(new ContentType("*.html", "text/html"));
resolver.Add(new ContentType("*.jpg", "image/jpeg"));
resolver.Add(new ContentType("/images/*", "image/jpeg"));
resolver.Add(new ContentType("/log/**", "text/plain"));
resolver.Add(new ContentType("*.exe", "application/octetstream"));
resolver.Add(new ContentType("**.txt", "text/plain"));
resolver.Add(new ContentType("/html/*", "text/html"));
AssertEquals(7, resolver.Count);
AssertEquals("image/jpeg", resolver.Resolve("image.jpg").Value);
AssertEquals("text/plain", resolver.Resolve("README.txt").Value);
int index = 0;
for(int i = resolver.Count; i > 0; i--) {
ContentType type = resolver[i - 1];
if(type.Value.Equals("text/plain")) {
index = i;
}
}
resolver.RemoveAt(index);
resolver.Add(new ContentType("*", "application/octetstream"));
AssertEquals("application/octetstream", resolver.Resolve("README.txt").Value);
AssertEquals("application/octetstream", resolver.Resolve("README.txt").Value);
resolver.Add(new ContentType("README.*", "text/html"));
resolver.Add(new ContentType("README.txt", "text/plain"));
AssertEquals("text/plain", resolver.Resolve("README.txt").Value);
AssertEquals("text/html", resolver.Resolve("README.jsp").Value);
}
示例3: Resolver
async Task IBoot.Run(CancellationToken token)
{
IResolver resolver = new Resolver(new[] {"CH.IoC."});
_log = resolver.Resolve<ILog>();
_log.Log(1, "Boot 1");
var tasks =
new[]
{
"isolated\\0",
"isolated\\1",
"isolated\\2"
}
.Select(path => Run(path, token))
.ToArray(); // force start
foreach (var task in tasks)
{
try
{
await task;
}
catch (Exception ex)
{
_log.Log(2, "Boot 2: " + ex);
}
}
while (!token.IsCancellationRequested)
{
await Task.Delay(10, token);
}
}
示例4: Resolver
Task IIsolated.Run(System.Threading.CancellationToken token)
{
IResolver resolver = new Resolver(new[] {"CH.IoC."});
var log = resolver.Resolve<ILog>();
log.Log("Isolated 4.0.0.0");
return Task.Delay(1, token);
}
示例5: UCPrintMonitor
public UCPrintMonitor(User user, string moduleType)
{
InitializeComponent();
this.resolver = new Resolver();
this.resolver.UserCode = user.Code;
this.resolver.ModuleType = moduleType;
this.TheClientMgr = new ClientMgrWSSoapClient();
this.dataGridView1.AutoGenerateColumns = false;
this.resolver.Transformers = null;
this.resolver.Result = string.Empty;
this.resolver.BinCode = string.Empty;
this.resolver.Code = string.Empty;
this.resolver.CodePrefix = string.Empty;
this.cacheReceiptNotes = new List<ReceiptNote>();
//timer1_Tick(this, null);
#region Printer
foreach (string fPrinterName in LocalPrinter.GetLocalPrinters())
{
this.comboBoxPrint1.Items.Add(fPrinterName);
this.comboBoxPrint2.Items.Add(fPrinterName);
this.comboBoxPrint3.Items.Add(fPrinterName);
this.comboBoxPrint4.Items.Add(fPrinterName);
this.comboBoxPrint5.Items.Add(fPrinterName);
}
//this.comboBoxPrint1.SelectedItem = Settings.Default.DefaultPrintName1;
#endregion
}
示例6: sceNetResolverCreate
public int sceNetResolverCreate(int *PointerToResolverId, void *Buffer, int BufferLength)
{
var Resolver = new Resolver();
var ResolverId = Resolvers.Create(Resolver);
*PointerToResolverId = ResolverId;
//throw(new NotImplementedException());
return 0;
}
示例7: Create
public static string Create(MethodReference mRef, Resolver resolver, ICode ast) {
if (mRef.ContainsGenericParameters()) {
throw new ArgumentException("Cannot create JS for method with open generic parameters");
}
var mDef = mRef.Resolve();
if (mDef.IsAbstract) {
throw new ArgumentException("Should never need to transcode an abstract method");
}
var tRef = mRef.DeclaringType;
var tDef = tRef.Resolve();
var v = new JsMethod(resolver);
v.Visit(ast);
var js = v.js.ToString();
var sb = new StringBuilder();
// Method declaration
var methodName = resolver.MethodNames[mRef];
//var parameterNames = mRef.Parameters.Select(x => v.parameters.ValueOrDefault(x).NullThru(y => resolver.LocalVarNames[y])).ToArray();
// Match parameters, but have to do by position, as method built may be a custom method replacing a BCL method,
// so parameters are not the same.
var parameterNames = mRef.Parameters.Select(x => v.parameters.FirstOrDefault(y => y.Key.Sequence == x.Sequence).Value.NullThru(y => resolver.LocalVarNames[y])).ToArray();
if (!mDef.IsStatic) {
var thisName = v.vars.FirstOrDefault(x => x.ExprType == Expr.NodeType.VarThis).NullThru(x => resolver.LocalVarNames[x]);
parameterNames = parameterNames.Prepend(thisName).ToArray();
}
var unusedParameterNameGen = new NameGenerator();
parameterNames = parameterNames.Select(x => x ?? ("_" + unusedParameterNameGen.GetNewName())).ToArray();
sb.AppendFormat("// {0}", mRef.FullName);
sb.AppendLine();
sb.AppendFormat("var {0} = function({1}) {{", methodName, string.Join(", ", parameterNames));
// Variable declarations
var declVars = v.vars
.Select(x => new { name = resolver.LocalVarNames[x], type = x.Type })
.Where(x => !parameterNames.Contains(x.name))
.Select(x => {
var name = x.name;
if (x.type.IsValueType) {
name += " = " + DefaultValuer.Get(x.type, resolver.FieldNames);
}
return name;
})
.Distinct() // Bit of a hack, but works for now
.ToArray();
if (declVars.Any()) {
sb.AppendLine();
sb.Append(' ', tabSize);
sb.AppendFormat("var {0};", string.Join(", ", declVars));
}
// Method body
sb.AppendLine(js);
// Method ending
sb.AppendLine("};");
var sbStr = sb.ToString();
return sbStr;
}
示例8: SDKEngine
/// <summary>
/// Constructor.
/// </summary>
/// <param name="createdOnForeground"></param>
public SDKEngine(bool createdOnForeground)
{
_appIsOnForeground = createdOnForeground;
LayoutManager = LayoutManager.Instance;
Resolver = new Resolver();
_eventHistory = new EventHistory();
_nextTimeToProcessDelayedActions = DateTimeOffset.MaxValue;
UnresolvedActionCount = 0;
}
示例9: Main
static void Main(string[] args)
{
var resolver = new Resolver();
resolver.Register<Shopper, Shopper>();
//resolver.Register<ICreditCard, MasterCard>();
resolver.Register<ICreditCard, Visa>();
var shopper = resolver.Resolve<Shopper>();
shopper.Charge();
Console.Read();
}
示例10: TinyIocBasic
public void TinyIocBasic()
{
var resolver = new Resolver();
resolver.Container.Register<IJsonSerializer>(new JsonSerializer());
//resolver.AddDynamic<IJsonSerializer>(() => new JsonSerializer());
var serializer = resolver.GetService<IJsonSerializer>();
Assert.IsNotNull(serializer);
}
示例11: TestMultipleConstructorsOfMaxSize
public void TestMultipleConstructorsOfMaxSize()
{
Resolver r = new Resolver();
Mock<IIocContainer> context = new Mock<IIocContainer>();
try
{
r.ResolveDependency(typeof(MatchingConstructorCounts), context.Object);
Assert.Fail();
}
catch (IocException) { }
}
示例12: TestMultipleIocConstructorAttributes
public void TestMultipleIocConstructorAttributes()
{
Resolver r = new Resolver();
Mock<IIocContainer> context = new Mock<IIocContainer>();
try
{
r.ResolveDependency(typeof(BadConstructorAttributes), context.Object);
Assert.Fail();
}
catch (IocException) { }
}
示例13: TestPropertyAndMethodSetup
public void TestPropertyAndMethodSetup()
{
Resolver r = new Resolver();
Mock<IIocContainer> context = new Mock<IIocContainer>();
object returnedObject = new object();
string returnedString = "returnedString";
context.Setup((c) => c.Resolve(typeof(object), String.Empty)).Returns(returnedObject);
context.Setup((c) => c.Resolve(typeof(string), String.Empty)).Returns(returnedString);
PropertyAndMethodInitialization result = (r.ResolveDependency(typeof(PropertyAndMethodInitialization), context.Object) as PropertyAndMethodInitialization);
Assert.AreEqual(returnedObject, result.O);
Assert.AreEqual(returnedString, result.S);
}
示例14: TestIoc
public void TestIoc()
{
Assert.DoesNotThrow(
() =>
{
var r = new Resolver(new[] {"CH."});
var mf = r.Resolve<IMemcachedFactory>();
var mc = mf.Create(MemcachedSettings.Settings.Server("localhost", 17325));
mc.Stats();
});
}
示例15: TestNoResolution
public void TestNoResolution() {
Resolver<ContentType> resolver = new Resolver<ContentType>();
resolver.Add(new ContentType("*.html", "text/html"));
resolver.Add(new ContentType("*.jpg", "image/jpeg"));
resolver.Add(new ContentType("/images/*", "image/jpeg"));
resolver.Add(new ContentType("/log/**", "text/plain"));
resolver.Add(new ContentType("*.exe", "application/octetstream"));
resolver.Add(new ContentType("**.txt", "text/plain"));
resolver.Add(new ContentType("/html/*", "text/html"));
AssertEquals(7, resolver.Count);
AssertEquals("text/plain", resolver.Resolve("README.txt").Value);
AssertEquals(null, resolver.Resolve("README"));
}