本文整理汇总了C#中IObjectContainer类的典型用法代码示例。如果您正苦于以下问题:C# IObjectContainer类的具体用法?C# IObjectContainer怎么用?C# IObjectContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IObjectContainer类属于命名空间,在下文中一共展示了IObjectContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XypericoDependencyResolver
public XypericoDependencyResolver(IObjectContainer container)
{
Container = container;
//
// Register all controller types so the container will be able to resolve them
//
Logger.Debug("Dependency resolver scanning for controllers");
//foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
foreach (Assembly a in BuildManager.GetReferencedAssemblies())
{
try
{
Logger.DebugFormat("Scanning assembly {0}", a.FullName);
foreach (Type controllerType in (from t in a.GetTypes() where typeof(IController).IsAssignableFrom(t) select t))
{
Logger.DebugFormat("Adding {0} as a controller", controllerType);
Container.AddTransientComponent(controllerType, controllerType);
// OLD: AddComponentLifeStyle(controllerType.ToString(), controllerType, Castle.Core.LifestyleType.Transient);
}
}
catch (ReflectionTypeLoadException ex)
{
Logger.Warn(string.Format("Could not load assembly {0}.", a.FullName), ex);
foreach (Exception ex2 in ex.LoaderExceptions)
Logger.Warn("Loader exception", ex2);
}
catch (Exception ex)
{
Logger.Warn(string.Format("Could not load assembly {0}.", a.FullName), ex);
}
}
}
示例2: SetFirstCar
public static void SetFirstCar(IObjectContainer db)
{
Pilot pilot = new Pilot("Rubens Barrichello", 99);
Car car = new Car("BMW");
car.Pilot = pilot;
db.Store(car);
}
示例3: StoreData
private static void StoreData(IObjectContainer container, Random rnd)
{
for (int i = 0; i < rnd.Next(4096); i++)
{
container.Store(new DataObject(rnd));
}
}
示例4: StoreOtherPeople
private static void StoreOtherPeople(IObjectContainer container)
{
for (int i = 0; i < PopulationSize; i++)
{
container.Store(new Person("Citizen No " + i));
}
}
示例5: RetrieveAllPilots
public static void RetrieveAllPilots(IObjectContainer db)
{
IQuery query = db.Query();
query.Constrain(typeof(Pilot));
IObjectSet result = query.Execute();
ListResult(result);
}
示例6: StoreData
private void StoreData(IObjectContainer container)
{
container.Store(new Person("Roman","Stoffel")
{
Address = new Address()
{
City = "Zurich",
Street = "FunStreet"
}
});
container.Store(new Person("Joe","Cool")
{
Address = new Address()
{
City = "FunTown",
Street = "Fun Plaza"
}
});
container.Store(new Person("Joanna", "Awesome")
{
Address = new Address()
{
City = "More Fun Town",
Street = "Plaza"
}
});
}
示例7: ShowReport
private void ShowReport(IObjectContainer container)
{
// #example: Run a report with db4o
var dataToShow = from Person p in container
where p.FirstName.Contains("o")
select p;
var reportViewer = new ReportViewer
{
ProcessingMode = ProcessingMode.Local
};
// Put the data into the datasource which you are using
// in your report. Here it's named 'MainData'
reportViewer.LocalReport.DataSources.Add(
new ReportDataSource("MainData", dataToShow));
reportViewer.Dock = DockStyle.Fill;
// The report can be an embedded resource
reportViewer.LocalReport.ReportEmbeddedResource = "Db4oDoc.Code.Reporting.ExampleReport.rdlc";
// or can be a file
// reportViewer.LocalReport.ReportPath = "path/to/your/report";
// After that you can use the report viewer in your app
this.Controls.Add(reportViewer);
reportViewer.RefreshReport();
// #end example
}
示例8: ActivateList
static void ActivateList(IObjectContainer db, IList list)
{
foreach (var obj in list)
{
db.Activate(obj, int.MaxValue);
}
}
示例9: RegisterDefaults
public virtual void RegisterDefaults(IObjectContainer container)
{
var serviceProvider = container.Resolve<IServiceProvider>();
RegisterVsDependencies(container, serviceProvider);
container.RegisterTypeAs<InstallServices, InstallServices>();
container.RegisterTypeAs<VsBrowserGuidanceNotificationService, IGuidanceNotificationService>();
container.RegisterTypeAs<WindowsFileAssociationDetector, IFileAssociationDetector>();
container.RegisterTypeAs<RegistryStatusAccessor, IStatusAccessor>();
container.RegisterTypeAs<IntegrationOptionsProvider, IIntegrationOptionsProvider>();
container.RegisterInstanceAs<IIdeTracer>(VsxHelper.ResolveMefDependency<IVisualStudioTracer>(serviceProvider));
container.RegisterInstanceAs(VsxHelper.ResolveMefDependency<IProjectScopeFactory>(serviceProvider));
container.RegisterTypeAs<TestRunnerEngine, ITestRunnerEngine>();
container.RegisterTypeAs<TestRunnerGatewayProvider, ITestRunnerGatewayProvider>();
container.RegisterTypeAs<MsTestRunnerGateway, ITestRunnerGateway>(TestRunnerTool.VisualStudio2010MsTest.ToString());
container.RegisterTypeAs<ReSharper5TestRunnerGateway, ITestRunnerGateway>(TestRunnerTool.ReSharper5.ToString());
container.RegisterTypeAs<ReSharper6TestRunnerGateway, ITestRunnerGateway>(TestRunnerTool.ReSharper.ToString());
container.RegisterTypeAs<SpecRunTestRunnerGateway, ITestRunnerGateway>(TestRunnerTool.SpecRun.ToString());
container.RegisterTypeAs<VS2012RunnerGateway, ITestRunnerGateway>(TestRunnerTool.VisualStudio2012.ToString());
container.RegisterTypeAs<AutoTestRunnerGateway, ITestRunnerGateway>(TestRunnerTool.Auto.ToString());
container.RegisterTypeAs<StepDefinitionSkeletonProvider, IStepDefinitionSkeletonProvider>();
container.RegisterTypeAs<DefaultSkeletonTemplateProvider, ISkeletonTemplateProvider>();
container.RegisterTypeAs<StepTextAnalyzer, IStepTextAnalyzer>();
RegisterCommands(container);
}
示例10: StoreExampleObjects
// #end example
private static void StoreExampleObjects(IObjectContainer container)
{
for (int i = 0; i < 100; i++)
{
container.Store(new Item(i));
}
}
示例11: Setup
public static void Setup(IObjectContainer container)
{
Chimera.Authentication.Views.MongoDB.Utility.Initialize(container);
container.AddComponent<INameValueContextCollection, CallContextNamedValueCollection>();
container.AddComponent<IUserAccountViewBuilder, UserAccountViewBuilder>();
}
示例12: FreespaceListener
public FreespaceListener(IObjectContainer container)
{
_totalFreespaceCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.TotalFreespace, container, false);
_averageSlotSizeCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceAverageSlotSize, container, false);
_freespaceSlotsCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceSlotCount, container, false);
_reusedSlotsCounter = Db4oPerformanceCounters.CounterFor(PerformanceCounterSpec.FreespaceReusedSlotsPerSec, container, false);
}
示例13: Query
public virtual IObjectSet Query(IObjectContainer db)
{
var query = db.Query();
query.Constrain(this);
query.Descend("_flag").Constrain(true).Not();
return query.Execute();
}
示例14: cadastrarStatus
public Boolean cadastrarStatus(clsStatus objStatus)
{
try
{
if (!temDuplicidade(objStatus, "Cadastrar"))
{
objStatus.Codigo = obtemNovoId(); //Executa a solicitação de um novo id
db = ServidorSingleton.obterServidor().OpenClient();
db.Store(objStatus);
db.Commit();
return true;
}
else {
return false;
}
}
catch (Exception ex)
{
db.Rollback();
throw new Exception("Erro cadastrando o status :" + ex.ToString());
}
finally {
db.Close();
db.Dispose();
}
}
示例15: SetUp
public void SetUp()
{
_filePath = Path.GetTempFileName();
//Db4objects.Db4o.Config.IConfiguration db4oConfiguration = Db4oFactory.Configure();
//Db4objects.Db4o.Config.IObjectClass objectClass = db4oConfiguration.ObjectClass(typeof(LanguageForm));
// objectClass.ObjectField("_writingSystemId").Indexed(true);
// objectClass.ObjectField("_form").Indexed(true);
_db = Db4oFactory.OpenFile(_filePath);
((YapStream) _db).GetNativeQueryHandler().QueryOptimizationFailure +=
OnQueryOptimizationFailure;
for (int i = 0;i < 10000;i++)
{
Entry e = new Entry();
e.name = new MultiText();
e.name._forms[0] = new LanguageForm("en", "en-" + i);
//e.name._forms[1] = new LanguageForm("fr", "fr-"+i);
e.name._singleForm = new LanguageForm("en", i.ToString());
_db.Set(e);
}
_db.Commit();
_db.Dispose();
_db = Db4oFactory.OpenFile(_filePath);
}