本文整理汇总了C#中TinyIoC类的典型用法代码示例。如果您正苦于以下问题:C# TinyIoC类的具体用法?C# TinyIoC怎么用?C# TinyIoC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TinyIoC类属于命名空间,在下文中一共展示了TinyIoC类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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>());
}
开发者ID:prabirshrestha,项目名称:NancyFacebookSample,代码行数:7,代码来源:Bootstrapper.cs
示例2: ApplicationStartup
protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
container.Resolve<IUserValidator>(),
"NancyFx"));
}
开发者ID:seun104,项目名称:AgbaraVOIP,代码行数:7,代码来源:AuthenticationBootstrapper.cs
示例3: RegisterViewEngines
protected override void RegisterViewEngines(TinyIoC.TinyIoCContainer container, IEnumerable<Type> viewEngineTypes)
{
if (viewEngineTypes.Count() > 1) //No need to register it because the default Container has already done it.
{
this.container.RegisterMultiple<IViewEngine>(viewEngineTypes).AsSingleton();
}
}
开发者ID:aqueduct,项目名称:Appia,代码行数:7,代码来源:Bootstrapper.cs
示例4: RegisterIFacebookApplicationPerRequest
private void RegisterIFacebookApplicationPerRequest(TinyIoC.TinyIoCContainer container, NancyContext context)
{
Facebook.IFacebookApplication facebookApplication = null;
if (context != null && context.Request != null && context.Request.Url != null)
{
var url = context.Request.Url;
if (url.HostName == "localhost")
{
facebookApplication = new Facebook.DefaultFacebookApplication
{
AppId = ",
AppSecret = ",
SiteUrl = "http://localhost:45254/",
CanvasUrl = "http://localhost:45254/canvas/",
SecureCanvasUrl = "https://localhost:44302/canvas/",
CanvasPage = "http://apps.facebook.com/appname/
};
}
else
{
//facebookApplication = new Facebook.DefaultFacebookApplication { AppId = "", AppSecret = "" };
}
}
container.Register(facebookApplication);
}
开发者ID:prabirshrestha,项目名称:NancyFacebookSample,代码行数:25,代码来源:Bootstrapper.cs
示例5: ConfigureRequestContainer
protected override void ConfigureRequestContainer(TinyIoC.TinyIoCContainer container)
{
foreach (var mock in _mocks)
{
container.Register(mock.Key, mock.Value);
}
}
开发者ID:bobbles31,项目名称:Ideastrike,代码行数:7,代码来源:IdeaStrikeTestBootStrapper.cs
示例6: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
// In reality you would use a pre-built authentication/claims provider
this.BeforeRequest += (ctx) =>
{
// World's-worse-authentication (TM)
// Pull the username out of the querystring if it exists
// and build claims from it
var username = ctx.Request.Query.username;
if (username.HasValue)
{
ctx.Items[Nancy.Security.SecurityConventions.AuthenticatedUsernameKey] = username.ToString();
ctx.Items[Nancy.Security.SecurityConventions.AuthenticatedClaimsKey] = BuildClaims(username.ToString());
}
return null;
};
this.AfterRequest += (ctx) =>
{
// If status code comes back as Unauthorized then
// forward the user to the login page
if (ctx.Response.StatusCode == HttpStatusCode.Unauthorized)
{
ctx.Response = new RedirectResponse("/login?returnUrl=" + Uri.EscapeDataString(ctx.Request.Path));
}
};
}
开发者ID:polera,项目名称:Nancy,代码行数:31,代码来源:AuthenticationBootstrapper.cs
示例7: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container)
{
base.ConfigureApplicationContainer(container);
container.Register<IRaceData>(new RaceData(_args.AlwaysUseCache));
container.Register<IOutput, CliOutput>();
}
开发者ID:nicholascloud,项目名称:presentations,代码行数:7,代码来源:RaceServiceBootstrapper.cs
示例8: 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;
});
}
开发者ID:prabirshrestha,项目名称:NancyFacebookSample,代码行数:30,代码来源:Bootstrapper.cs
示例9: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container)
{
base.ConfigureApplicationContainer(container);
var mongoUrlStore = new MongoUrlStore("mongodb://localhost:27010/short_url");
container.Register<UrlStore>(mongoUrlStore);
}
开发者ID:Vutha,项目名称:ShortURL,代码行数:7,代码来源:Bootstrapper.cs
示例10: ProcessRegistrations
public static void ProcessRegistrations(TinyIoC.TinyIoCContainer container)
{
var applicationRegistrationImplementations =
AppDomain.CurrentDomain.GetAssemblies()
.Where(a =>
a.GetReferencedAssemblies().Contains(typeof (ApplicationRegistar).Assembly.GetName()) ||
a == typeof (ApplicationRegistar).Assembly)
.SelectMany(t => t.GetTypes())
.Where(t => t.Implements(typeof (IApplicationRegistration)))
.ToList();
container.RegisterMultiple<IApplicationRegistration>(applicationRegistrationImplementations);
var applicationRegistrations = container.ResolveAll<IApplicationRegistration>().ToList();
foreach (var typeRegistration in applicationRegistrations.SelectMany(ar => ar.TypeRegistrations))
{
container.Register(typeRegistration.RegistrationType, typeRegistration.InstanceType);
}
foreach (var instanceRegistration in applicationRegistrations.SelectMany(ar => ar.InstanceRegistrations))
{
container.Register(instanceRegistration.RegistrationType, instanceRegistration.Instance);
}
foreach (var collectionRegistration in applicationRegistrations.SelectMany(ar => ar.CollectionRegistration).GroupBy(cr => cr.RegistrationType))
{
container.RegisterMultiple(collectionRegistration.Key, collectionRegistration.SelectMany(c => c.InstanceTypes));
}
}
开发者ID:albertjan,项目名称:DynamicRestClient,代码行数:30,代码来源:ApplicationRegistar.cs
示例11: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
BeforeRequest += ctx =>
{
var staticFileExtensions =
new Dictionary<string, string>
{
{ "jpg", "image/jpg" },
{ "png", "image/png" },
{ "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 filePath = "Public" + ctx.Request.Uri.Replace('/', '\\');
return new GenericFileResponse(filePath, staticFileExtensions[extensionWithoutDot]);
}
}
return null;
};
}
开发者ID:andrewhart098,项目名称:Nancy-Starter-Kit,代码行数:34,代码来源:StaticContentBootstrapper.cs
示例12: ApplicationStartup
protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
{
FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration {
RedirectUrl = "~/login",
UserMapper = _mocks[typeof(IUserRepository)] as IUserRepository
});
}
开发者ID:bobbles31,项目名称:Ideastrike,代码行数:7,代码来源:IdeaStrikeTestBootStrapper.cs
示例13: ConfigureApplicationContainer
// Overriding this just to show how it works, not actually necessary as autoregister
// takes care of it all.
protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer existingContainer)
{
// We don't call base because we don't want autoregister
// we just register our one known dependency as an application level singleton
existingContainer.Register<IApplicationDependency, ApplicationDependencyClass>().AsSingleton();
existingContainer.Register<IRazorConfiguration, MyRazorConfiguration>().AsSingleton();
}
开发者ID:rspacjer,项目名称:Nancy,代码行数:9,代码来源:DemoBootstrapper.cs
示例14: 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>());
}
开发者ID:nathanpalmer,项目名称:Nancy.Stitch,代码行数:29,代码来源:Bootstrapper.cs
示例15: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
this.BeforeRequest += (ctx) =>
{
// World's-worse-authentication (TM)
// Pull the username out of the querystring if it exists
// and build claims from it
var username = ctx.Request.Query.username;
if (username.HasValue)
{
ctx.Items[Security.USERNAME_KEY] = username.ToString();
ctx.Items[Security.CLAIMS_KEY] = BuildClaims(username.ToString());
}
return null;
};
this.AfterRequest += (ctx) =>
{
// If status code comes back as Unauthorized then
// forward the user to the login page
if (ctx.Response.StatusCode == HttpStatusCode.Unauthorized)
{
ctx.Response = new RedirectResponse("/login?returnUrl=" + ctx.Request.Uri);
}
};
}
开发者ID:ToJans,项目名称:Nancy,代码行数:30,代码来源:AuthenticationBootstrapper.cs
示例16: ConfigureApplicationContainer
protected override void ConfigureApplicationContainer(TinyIoC.TinyIoCContainer container)
{
container.Register(documentStore);
container.Register(s3Configuration);
container.Register<IS3Storage, RavenDBStorage>().AsSingleton();
container.Register<IS3Responder, S3XmlResponder>().AsSingleton();
}
开发者ID:nrazon,项目名称:S3Emulator,代码行数:7,代码来源:Bootstrapper.cs
示例17: ApplicationStartup
protected override void ApplicationStartup(TinyIoC.TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
// In reality you would use a pre-built authentication/claims provider
pipelines.BeforeRequest += (ctx) =>
{
// World's-worse-authentication (TM)
// Pull the username out of the querystring if it exists
// and build claims from it
var username = ctx.Request.Query.username;
if (username.HasValue)
{
ctx.CurrentUser = new DemoUserIdentity
{
UserName = username.ToString(),
Claims = BuildClaims(username.ToString())
};
}
return null;
};
pipelines.AfterRequest += (ctx) =>
{
// If status code comes back as Unauthorized then
// forward the user to the login page
if (ctx.Response.StatusCode == HttpStatusCode.Unauthorized)
{
ctx.Response = new RedirectResponse("/login?returnUrl=" + Uri.EscapeDataString(ctx.Request.Path));
}
};
}
开发者ID:RobertTheGrey,项目名称:Nancy,代码行数:34,代码来源:AuthenticationBootstrapper.cs
示例18: 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;
}
开发者ID:prabirshrestha,项目名称:NancyFacebookSample,代码行数:32,代码来源:Facebook.Bootstrapper.cs
示例19: 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>());
}
开发者ID:NancyFx,项目名称:Nancy.SassAndCoffee,代码行数:8,代码来源:Bootstrapper.cs
示例20: InitialiseInternal
protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
{
base.InitialiseInternal(container);
this.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
container.Resolve<IUserValidator>(),
"MyRealm"));
}
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:8,代码来源:AuthenticationBootstrapper.cs
注:本文中的TinyIoC类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论