本文整理汇总了C#中TinyIoC.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# TinyIoC.Resolve方法的具体用法?C# TinyIoC.Resolve怎么用?C# TinyIoC.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TinyIoC
的用法示例。
在下文中一共展示了TinyIoC.Resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestStartup
protected override void RequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
{
base.RequestStartup(container, pipelines, context);
pipelines.BeforeRequest.AddItemToStartOfPipeline(
ctx =>
{
var facebookClient = container.Resolve<Facebook.FacebookClient>();
var fbUser = context.CurrentUser as IFacebookUser;
if (fbUser != null)
facebookClient.AccessToken = fbUser.FacebookAccessToken;
#region SignedRequest
if (context.Request != null)
{
dynamic signedRequest;
var fbApp = container.Resolve<Facebook.IFacebookApplication>();
if (context.Request.TryParseFacebookSignedRequest(fbApp.AppId, fbApp.AppSecret, out signedRequest))
{
if (signedRequest.ContainsKey("oauth_token"))
facebookClient.AccessToken = signedRequest.oauth_token;
}
}
#endregion
return null;
});
}
示例2: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
var configuration = new StitchConfiguration()
{
/*Compilers = new[]
{
new StitchConfigurationCompiler {Type = typeof (JavaScriptCompiler).AssemblyQualifiedName, Extension = ".js"},
new StitchConfigurationCompiler {Type = typeof (CoffeeScriptCompiler).AssemblyQualifiedName, Extension = ".coffee"},
new StitchConfigurationCompiler {Type = typeof (jQueryTemplateCompiler).AssemblyQualifiedName, Extension = ".tmpl"}
},*/
Files = new[]
{
new StitchConfiguration()
{
Name = "/Scripts/app.stitch",
Paths = new[]
{
"Scripts/App"
}
}
}
};
container.Register<IStitchConfiguration>(configuration);
Stitch.Enable(this, container.Resolve<IRootPathProvider>(), container.Resolve<IStitchConfiguration>());
}
示例3: FacebookRequestStartup
private Response FacebookRequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines, NancyContext context)
{
if (context.Request != null)
{
string[] perms = null;
dynamic signedRequest;
var fbApp = container.Resolve<IFacebookApplication>();
if (context.TryParseFacebookSignedRequest(fbApp.AppId, fbApp.AppSecret, out signedRequest))
{
if (((System.Collections.Generic.IDictionary<string, object>)signedRequest).ContainsKey("oauth_token"))
{
var fb = container.Resolve<FacebookClient>();
fb.AccessToken = signedRequest.oauth_token;
try
{
var result = (IDictionary<string, object>)fb.Get("me/permissions");
perms = ((IDictionary<string, object>)((IList<object>)result["data"])[0]).Keys.ToArray();
}
catch (FacebookOAuthException)
{
// access token is invalid so perms=none
// but don't throw exception.
fb.AccessToken = null;
}
}
}
context.Items[CustomFacebookExtensions.FacebookPermsKey] = perms ?? new string[0];
}
return null;
}
示例4: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
var formsAuthConfiguration =
new FormsAuthenticationConfiguration()
{
Passphrase = "SuperSecretPass",
Salt = "AndVinegarCrisps",
HmacPassphrase = "UberSuperSecure",
RedirectUrl = "/authentication/login",
UsernameMapper = container.Resolve<IUsernameMapper>(),
};
FormsAuthentication.Enable(this, formsAuthConfiguration);
BeforeRequest += ctx =>
{
var rootPathProvider =
container.Resolve<IRootPathProvider>();
var staticFileExtensions =
new Dictionary<string, string>
{
{ "jpg", "image/jpg" },
{ "png", "image/png" },
{ "gif", "image/gif" },
{ "css", "text/css" },
{ "js", "text/javascript" }
};
var requestedExtension =
Path.GetExtension(ctx.Request.Uri);
if (!string.IsNullOrEmpty(requestedExtension))
{
var extensionWithoutDot =
requestedExtension.Substring(1);
if (staticFileExtensions.Keys.Any(x => x.Equals(extensionWithoutDot, StringComparison.InvariantCultureIgnoreCase)))
{
var fileName =
Path.GetFileName(ctx.Request.Uri);
if (fileName == null)
{
return null;
}
var filePath =
Path.Combine(rootPathProvider.GetRootPath(), "content", fileName);
return !File.Exists(filePath) ? null : new StaticFileResponse(filePath, staticFileExtensions[extensionWithoutDot]);
}
}
return null;
};
}
示例5: ApplicationStartup
protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
container.Resolve<IUserValidator>(),
"NancyFx"));
}
示例6: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container)
{
base.ConfigureApplicationContainer(container);
container.Register<Repositories.IAppUserMapper, Repositories.InMemoryAppUserMapper>().AsSingleton();
container.Register<IUserMapper>(container.Resolve<Repositories.IAppUserMapper>());
}
示例7: ApplicationStartup
protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
StaticConfiguration.DisableErrorTraces = false;
SassAndCoffee.Hooks.Enable(pipelines, new InMemoryCache(), container.Resolve<IRootPathProvider>());
}
示例8: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
this.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
container.Resolve<IUserValidator>(),
"MyRealm"));
}
示例9: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container)
{
container.Register<IPersistentStore, PersistentStore>().AsSingleton();
var bus = StickABusInIt(container.Resolve<IPersistentStore>());
container.Register<ICommandSender, FakeBus>(bus);
container.Register<IEventPublisher, FakeBus>(bus);
}
示例10: ConfigureRequestContainer
protected override void ConfigureRequestContainer(TinyIoC.TinyIoCContainer container, NancyContext context)
{
base.ConfigureRequestContainer(container, context);
container.Register< BlogService>();
var ravenSession = container.Resolve< IRavenSessionProvider >().GetSession();
container.Register( ravenSession );
container.Register< IBlogService, BlogService >();
}
示例11: ApplicationStartup
protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
var formsAuthConfig = new FormsAuthenticationConfiguration
{
RedirectUrl = "~/facebook/login",
UserMapper = container.Resolve<IUserMapper>()
};
FormsAuthentication.Enable(pipelines, formsAuthConfig);
}
示例12: RequestStartup
protected override void RequestStartup(TinyIoC.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
{
var formsAuthConfiguration =
new FormsAuthenticationConfiguration
{
RedirectUrl = "~/login",
UserMapper = container.Resolve<IUserMapper>(),
};
FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
base.RequestStartup(container, pipelines);
}
示例13: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
var formsAuthConfiguration =
new FormsAuthenticationConfiguration()
{
RedirectUrl = "~/login",
UserMapper = container.Resolve<IUserMapper>(),
};
FormsAuthentication.Enable(this, formsAuthConfiguration);
}
示例14: ApplicationStartup
protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
container.Resolve<IUserValidator>(),
"RateAllTheThings"));
pipelines.OnError += (context, exception) =>
{
exception.SendToAirbrake();
return null;
};
}
示例15: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
var formsAuthConfiguration =
new FormsAuthenticationConfiguration()
{
RedirectUrl = "~/login",
UsernameMapper = container.Resolve<IUsernameMapper>(),
};
FormsAuthentication.Enable(this, formsAuthConfiguration);
//Adding a check on the pipeline to validate if the user is still authorised by facebook.
this.BeforeRequest.AddItemToEndOfPipeline(FacebookAuthenticatedCheckPipeline.CheckUserIsNothAuthorisedByFacebookAnymore);
}