本文整理汇总了C#中ObjectContainer类的典型用法代码示例。如果您正苦于以下问题:C# ObjectContainer类的具体用法?C# ObjectContainer怎么用?C# ObjectContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectContainer类属于命名空间,在下文中一共展示了ObjectContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObjectContainerSaveState
public void ObjectContainerSaveState(ObjectContainer o)
{
using (var stream = File.Create("x.ssa"))
{
stream.Write(_buffer, 0, 0);
}
}
示例2: RegisterDefaults
public virtual void RegisterDefaults(ObjectContainer container)
{
container.RegisterTypeAs<DefaultRuntimeConfigurationProvider, IRuntimeConfigurationProvider>();
container.RegisterTypeAs<TestRunnerManager, ITestRunnerManager>();
container.RegisterTypeAs<StepFormatter, IStepFormatter>();
container.RegisterTypeAs<TestTracer, ITestTracer>();
container.RegisterTypeAs<DefaultListener, ITraceListener>();
container.RegisterTypeAs<TraceListenerQueue, ITraceListenerQueue>();
container.RegisterTypeAs<ErrorProvider, IErrorProvider>();
container.RegisterTypeAs<RuntimeBindingSourceProcessor, IRuntimeBindingSourceProcessor>();
container.RegisterTypeAs<RuntimeBindingRegistryBuilder, IRuntimeBindingRegistryBuilder>();
container.RegisterTypeAs<BindingRegistry, IBindingRegistry>();
container.RegisterTypeAs<BindingFactory, IBindingFactory>();
container.RegisterTypeAs<StepDefinitionRegexCalculator, IStepDefinitionRegexCalculator>();
container.RegisterTypeAs<BindingInvoker, IBindingInvoker>();
container.RegisterTypeAs<StepDefinitionSkeletonProvider, IStepDefinitionSkeletonProvider>();
container.RegisterTypeAs<DefaultSkeletonTemplateProvider, ISkeletonTemplateProvider>();
container.RegisterTypeAs<StepTextAnalyzer, IStepTextAnalyzer>();
container.RegisterTypeAs<RuntimePluginLoader, IRuntimePluginLoader>();
container.RegisterTypeAs<BindingAssemblyLoader, IBindingAssemblyLoader>();
RegisterUnitTestProviders(container);
}
示例3: ContainerShouldThrowExceptionWhenDisposed
public void ContainerShouldThrowExceptionWhenDisposed()
{
var container = new ObjectContainer();
container.Dispose();
container.Resolve<IObjectContainer>();
}
示例4: TestObjectReferenceUpdate
public void TestObjectReferenceUpdate()
{
var nodeContainer = new NodeContainer();
var instance = new TestObject { Name = "Test" };
var container = new ObjectContainer { Instance = instance };
var containerNode = nodeContainer.GetOrCreateNode(container);
var memberNode = containerNode.Children.First();
var instanceNode = memberNode.Content.Reference.AsObject.TargetNode;
// Update to a new instance
var newInstance = new TestObject { Name = "Test2" };
memberNode.Content.Update(newInstance);
Helper.TestMemberContentNode(containerNode, memberNode, container, newInstance, nameof(ObjectContainer.Instance), true);
Helper.TestNonNullObjectReference(memberNode.Content.Reference, newInstance, false);
var newInstanceNode = nodeContainer.GetNode(newInstance);
Helper.TestNonNullObjectReference(memberNode.Content.Reference, newInstanceNode, newInstance);
Assert.AreNotEqual(instanceNode.Guid, newInstanceNode.Guid);
// Update to null
memberNode.Content.Update(null);
Helper.TestMemberContentNode(containerNode, memberNode, container, null, nameof(ObjectContainer.Instance), true);
Helper.TestNullObjectReference(memberNode.Content.Reference);
// Update back to the initial instance
memberNode.Content.Update(instance);
Helper.TestMemberContentNode(containerNode, memberNode, container, instance, nameof(ObjectContainer.Instance), true);
Helper.TestNonNullObjectReference(memberNode.Content.Reference, instanceNode, instance);
}
示例5: RegisterDefaults
public virtual void RegisterDefaults(ObjectContainer container)
{
container.RegisterTypeAs<DefaultRuntimeConfigurationProvider, IRuntimeConfigurationProvider>();
container.RegisterTypeAs<TestRunnerFactory, ITestRunnerFactory>();
container.RegisterTypeAs<TestRunner, ITestRunner>();
container.RegisterTypeAs<TestExecutionEngine, ITestExecutionEngine>();
container.RegisterTypeAs<StepDefinitionMatchService, IStepDefinitionMatchService>();
container.RegisterTypeAs<StepFormatter, IStepFormatter>();
container.RegisterTypeAs<TestTracer, ITestTracer>();
container.RegisterTypeAs<DefaultListener, ITraceListener>();
container.RegisterTypeAs<ErrorProvider, IErrorProvider>();
container.RegisterTypeAs<StepArgumentTypeConverter, IStepArgumentTypeConverter>();
container.RegisterTypeAs<BindingRegistry, IRuntimeBindingRegistryBuilder>();
container.RegisterTypeAs<BindingRegistry, IBindingRegistry>();
container.RegisterTypeAs<BindingFactory, IBindingFactory>();
container.RegisterTypeAs<StepDefinitionRegexCalculator, IStepDefinitionRegexCalculator>();
container.RegisterTypeAs<BindingInvoker, IBindingInvoker>();
container.RegisterTypeAs<ContextManager, IContextManager>();
container.RegisterTypeAs<StepDefinitionSkeletonProviderCS, IStepDefinitionSkeletonProvider>(ProgrammingLanguage.CSharp.ToString());
container.RegisterTypeAs<StepDefinitionSkeletonProviderVB, IStepDefinitionSkeletonProvider>(ProgrammingLanguage.VB.ToString());
container.RegisterTypeAs<RuntimePluginLoader, IRuntimePluginLoader>();
container.RegisterTypeAs<BindingAssemblyLoader, IBindingAssemblyLoader>();
RegisterUnitTestProviders(container);
}
示例6: CreateContainer
public static IObjectContainer CreateContainer(SpecFlowConfigurationHolder configurationHolder, ProjectSettings projectSettings)
{
var container = new ObjectContainer();
RegisterDefaults(container);
var specFlowConfiguration = container.Resolve<ISpecFlowProjectConfigurationLoader>()
.LoadConfiguration(configurationHolder);
if (specFlowConfiguration.GeneratorConfiguration.CustomDependencies != null)
container.RegisterFromConfiguration(specFlowConfiguration.GeneratorConfiguration.CustomDependencies);
container.RegisterInstanceAs(specFlowConfiguration);
container.RegisterInstanceAs(specFlowConfiguration.GeneratorConfiguration);
container.RegisterInstanceAs(specFlowConfiguration.RuntimeConfiguration);
var generatorInfo = container.Resolve<IGeneratorInfoProvider>().GetGeneratorInfo();
container.RegisterInstanceAs(generatorInfo);
container.RegisterInstanceAs(projectSettings);
container.RegisterInstanceAs(container.Resolve<CodeDomHelper>(projectSettings.ProjectPlatformSettings.Language));
if (specFlowConfiguration.GeneratorConfiguration.GeneratorUnitTestProvider != null)
container.RegisterInstanceAs(container.Resolve<IUnitTestGeneratorProvider>(specFlowConfiguration.GeneratorConfiguration.GeneratorUnitTestProvider));
return container;
}
示例7: ObjectInfo
/* CONSTRUCTOR */
public ObjectInfo (ObjectContainer container)
{
Container = container;
Depends = container.Depends.ToArray ();
SystemType = container.SystemType;
RefId = container.RefId;
}
示例8: Init
public override void Init()
{
base.Init();
_box = (BeerBox) Container["beer.box"];
_objContainer = (ObjectContainer)Container[typeof(ObjectContainer)];
}
示例9: Serialize
public void Serialize(ObjectContainer o)
{
var formatter = new BinaryFormatter();
using (var stream = File.Create("x.dat"))
{
formatter.Serialize(stream, o);
}
}
示例10: ShouldNotRegisterInvalidTypeMapping
public void ShouldNotRegisterInvalidTypeMapping()
{
// given
var container = new ObjectContainer();
// then
Assert.Catch<InvalidOperationException>(() => container.RegisterTypeAs(typeof(SimpleClassExtendingGenericInterface), typeof(IGenericInterface<>)));
}
示例11: RegisterDefaults
private static void RegisterDefaults(ObjectContainer container)
{
container.RegisterTypeAs<SpecFlowProjectConfigurationLoader, ISpecFlowProjectConfigurationLoader>();
container.RegisterTypeAs<InProcGeneratorInfoProvider, IGeneratorInfoProvider>();
container.RegisterTypeAs<TestGenerator, ITestGenerator>();
container.RegisterTypeAs<TestHeaderWriter, ITestHeaderWriter>();
container.RegisterTypeAs<TestUpToDateChecker, ITestUpToDateChecker>();
}
示例12: CreateTestRunnerContainer
public IObjectContainer CreateTestRunnerContainer(IObjectContainer globalContainer)
{
var testRunnerContainer = new ObjectContainer(globalContainer);
defaultDependencyProvider.RegisterTestRunnerDefaults(testRunnerContainer);
return testRunnerContainer;
}
示例13: SetUp
public void SetUp()
{
mockTestRunner = MockRepository.GenerateMock<ITestRunner>();
var container = new ObjectContainer();
container.RegisterInstanceAs(mockTestRunner);
steps = new StepsTestableHelper();
((IContainerDependentObject)steps).SetObjectContainer(container);
}
示例14: DisplayValue
private static string DisplayValue(Tk5FieldInfoEx field, ObjectContainer container, bool showHint)
{
TkDebug.AssertArgumentNull(field, "field", null);
//if (field.Upload != null)
// return DisplayUpload(field, row);
object receiver = container.MainObject;
string displayValue = string.Empty;
string value = string.Empty;
try
{
value = receiver.MemberValue(field.NickName).ConvertToString();
if (field.Decoder == null || field.Decoder.Type == DecoderType.None)
displayValue = FormatNumber(field, field.NickName, receiver);
else
displayValue = container.Decoder.GetNameString(field.NickName);
}
catch
{
displayValue = value;
}
if (showHint)
{
if (!string.IsNullOrEmpty(field.Hint))
displayValue += " " + field.Hint;
}
if (field.ListDetail != null && field.ListDetail.Link != null)
{
var link = field.ListDetail.Link;
string linkUrl = string.Empty;
string target = string.Empty;
switch (link.RefType)
{
case LinkRefType.Href:
linkUrl = HtmlUtil.ParseLinkUrl(receiver, link.Content);
linkUrl = WebUtil.ResolveUrl(linkUrl);
if (!string.IsNullOrEmpty(link.Base))
linkUrl = UriUtil.CombineUri(link.Base, linkUrl).ToString();
if (!string.IsNullOrEmpty(link.Target))
target = string.Format(ObjectUtil.SysCulture, " target=\"{0}\"", link.Target);
break;
case LinkRefType.Http:
if (!value.StartsWith("http", StringComparison.OrdinalIgnoreCase))
linkUrl = "http://";
linkUrl += value;
target = " target=\"_blank\"";
break;
case LinkRefType.Email:
linkUrl = "mailto:" + value;
target = " target=\"_blank\"";
break;
}
return string.Format(ObjectUtil.SysCulture, "<a href=\"{0}\"{1}>{2}</a>",
StringUtil.EscapeHtmlAttribute(linkUrl), target, StringUtil.EscapeHtml(displayValue));
}
return displayValue;
}
示例15: LoadPlugins
private static IGeneratorPlugin[] LoadPlugins(ObjectContainer container, IGeneratorConfigurationProvider configurationProvider, SpecFlowConfigurationHolder configurationHolder)
{
var plugins = container.Resolve<IDictionary<string, IGeneratorPlugin>>().Values.AsEnumerable();
var pluginLoader = container.Resolve<IGeneratorPluginLoader>();
plugins = plugins.Concat(configurationProvider.GetPlugins(configurationHolder).Where(pd => (pd.Type & PluginType.Generator) != 0).Select(pd => LoadPlugin(pluginLoader, pd)));
return plugins.ToArray();
}