コード例 #1
0
 public DependentClass(
     ConcreteOnlyDependency concreteOnlyDependency,
     IInterfaceOnlyDependency interfaceOnlyDependency,
     IMixedDependency mixedDependencyInferface,
     MixedDependency mixedDependencyClass,
     ValueTypeDependency valueTypeDependency)
 {
     ConcreteOnlyDependency = concreteOnlyDependency ??
                              throw new ArgumentNullException(nameof(concreteOnlyDependency));
     InterfaceOnlyDependency = interfaceOnlyDependency ??
                               throw new ArgumentNullException(nameof(interfaceOnlyDependency));
     MixedDependencyInferface = mixedDependencyInferface ??
                                throw new ArgumentNullException(nameof(mixedDependencyInferface));
     MixedDependencyClass = mixedDependencyClass ??
                            throw new ArgumentNullException(nameof(mixedDependencyClass));
     ValueTypeDependency = valueTypeDependency;
 }
コード例 #2
0
        public WhenSingletonDependenciesWithoutAContext(ITestOutputHelper output)
        {
            ExpectedConcreteOnlyDependency  = new ConcreteOnlyDependency();
            ExpectedInterfaceOnlyDependency = new InterfaceOnlyDependency();
            ExpectedMixedDependency         = new MixedDependency();
            ExpectedValueTypeDependency     = new ValueTypeDependency(Guid.NewGuid());

            _container =
                new RegistrationSetup()
                .RegisterFixed(ExpectedConcreteOnlyDependency)
                .RegisterFixed <IInterfaceOnlyDependency>(ExpectedInterfaceOnlyDependency)
                .RegisterFixed <IMixedDependency, MixedDependency>(ExpectedMixedDependency)
                .RegisterFixed(ExpectedValueTypeDependency)
                .Register <DependentClass>()
                .Construct(GetType().GetTypeInfo().Assembly, out string code);

            output.WriteLine(code);
        }