本文整理汇总了C#中IAppHost.GetContainer方法的典型用法代码示例。如果您正苦于以下问题:C# IAppHost.GetContainer方法的具体用法?C# IAppHost.GetContainer怎么用?C# IAppHost.GetContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppHost
的用法示例。
在下文中一共展示了IAppHost.GetContainer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public void Register(IAppHost appHost)
{
appHost.RegisterService<Users.Service>();
appHost.GetContainer().RegisterAutoWiredType(typeof(Users.Service));
//appHost.GetContainer().Register<Users.Service>((c) => new Users.Service(c.Resolve<IBus>()));
appHost.GetContainer().RegisterValidators(typeof(Plugin).Assembly);
}
示例2: AfterPluginsLoaded
public void AfterPluginsLoaded(IAppHost appHost)
{
var container = appHost.GetContainer();
if (container.Exists<IpModuleManager>())
{
var manager = container.Resolve<IpModuleManager>();
manager.DeviceStatusChanged += (sender, args) =>
{
var cb = container.Resolve<IParadoxEventCallbacks>();
cb.PutDeviceUpdate(args.Device);
};
manager.PartitionStatusChanged += (sender, args) =>
{
var cb = container.Resolve<IParadoxEventCallbacks>();
cb.PutPartitionUpdate(args.Partition);
};
}
else
{
logger.Error("Cannot find Ip Module Manager to register device and partition status changes events for MQTT");
}
}
示例3: AfterPluginsLoaded
public void AfterPluginsLoaded(IAppHost appHost)
{
var container = appHost.GetContainer();
if (container.Exists<IpModuleManager>())
{
var manager = container.Resolve<IpModuleManager>();
manager.DeviceStatusChanged += (sender, args) =>
{
logger.DebugFormat("{0}:{1}[{2}]", args.Device.Name, args.Device.Status, args.Device.ZoneId);
var settings = container.Resolve<SmartThingsSettings>();
var cb = new SmartThingsCallbacks(settings);
cb.PutDeviceUpdate(args.Device);
};
manager.PartitionStatusChanged += (sender, args) =>
{
logger.DebugFormat("{0}:{1}", args.Partition.Name, args.Partition.Status);
var settings = container.Resolve<SmartThingsSettings>();
var cb = new SmartThingsCallbacks(settings);
cb.PutPartitionUpdate(args.Partition);
};
}
else
{
logger.Error("Cannot find Ip Module Manager to register device and partition status changes events for SmartThings");
}
}
示例4: Configure
public void Configure(IAppHost appHost)
{
var settingsProvider = new SettingsProvider(new RoamingAppDataStorage("Paradox"));
var mySettings = settingsProvider.GetSettings<SmartThingsSettings>();
var container = appHost.GetContainer();
container.Register(mySettings);
container.RegisterAs<SmartThingsCallbacks, IParadoxEventCallbacks>();
}
示例5: Configure
public void Configure(IAppHost appHost)
{
var settingsProvider = new SettingsProvider(new RoamingAppDataStorage("Paradox"));
var mySettings = settingsProvider.GetSettings<ParadoxMqttSettings>();
var container = appHost.GetContainer();
container.Register(mySettings);
container.Register(new MqttClient(mySettings.BrokerUrl));
container.RegisterAs<MqttCallbacks, IParadoxEventCallbacks>().ReusedWithin(ReuseScope.Container);
}
示例6: Configure
public static void Configure(IAppHost appHost)
{
JsConfig.EmitCamelCaseNames = true;
RedisConfig.AssumeServerVersion = 2821;
var container = appHost.GetContainer();
container.Register<IRedisClientsManager>(c =>
new RedisManagerPool(appHost.AppSettings.Get("redis-server", "127.0.0.1")));
}
示例7: RegisterService
private void RegisterService(IAppHost host)
{
ServiceDiscovery = Settings.GetDiscoveryClient() ?? new ConsulDiscovery();
ServiceDiscovery.Register(host);
// register servicestack discovery services
host.Register(ServiceDiscovery);
host.GetContainer()
.Register<IServiceGatewayFactory>(x => new ConsulServiceGatewayFactory(Settings.GetGateway(), ServiceDiscovery))
.ReusedWithin(ReuseScope.None);
}
示例8: Register
public void Register(IAppHost appHost)
{
var container = appHost.GetContainer();
container.Register(c => appHost);
container.Register<IRedisClientsManager>(new PooledRedisClientManager("localhost:6379"));
container.Register(container.Resolve<IRedisClientsManager>().GetClient());
var redisVirtualPathProvider = new RedisVirtualPathProvider(appHost);
container.Register(c => redisVirtualPathProvider);
container.RegisterAutoWired<RedisVirtualPathProvider>().ReusedWithin(ReuseScope.Default);
//container.RegisterAutoWiredType(typeof(RedisVirtualPathProvider), ReuseScope.Default);
//container.AutoWire(redisVirtualPathProvider);
var clientManager = container.Resolve<IRedisClientsManager>();
var redisClient = container.Resolve<IRedisClient>();
var pathProvider = container.Resolve<RedisVirtualPathProvider>();
;
}
示例9: AfterPluginsLoaded
public void AfterPluginsLoaded(IAppHost appHost)
{
var authEvents = appHost.TryResolve<IAuthEvents>();
if (authEvents == null)
{
authEvents = AuthEvents.Count == 0
? new AuthEvents() :
AuthEvents.Count == 1
? AuthEvents.First()
: new MultiAuthEvents(AuthEvents);
appHost.GetContainer().Register<IAuthEvents>(authEvents);
}
else if (AuthEvents.Count > 0)
{
throw new Exception("Registering IAuthEvents via both AuthFeature.AuthEvents and IOC is not allowed");
}
}
示例10: Register
public void Register(IAppHost appHost)
{
var broker = new MemoryServerEventsBroker()
{
//Timeout = Timeout,
};
var container = appHost.GetContainer();
if (container.TryResolve<IServerEventsBroker>() == null)
container.Register<IServerEventsBroker>(broker);
appHost.RawHttpHandlers.Add(httpReq =>
httpReq.PathInfo.EndsWith(StreamPath)
? (IHttpHandler)new ServerEventsHandler()
//: httpReq.PathInfo.EndsWith(HeartbeatPath)
// ? new ServerEventsHeartbeatHandler()
: null);
}