コード例 #1
0
 public SampleClassWithCycleInConstructorWithClassDependencyMethod(SampleClassWithCycleInConstructorWithClassDependencyMethod sampleClass)
 {
 }
コード例 #2
0
        public void ResolveClassWithCycleInConstructorWithClassDependencyMethodAfterBuildUpObjectOfThisClass_Failed()
        {
            var c = new Container();
            c.RegisterType<EmptyClass>();
            c.RegisterType<SampleClassWithCycleInConstructorWithClassDependencyMethod>();
            var sampleClass1 = new SampleClassWithCycleInConstructorWithClassDependencyMethod(null);

            c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction);
            var sampleClass2 = c.Resolve<SampleClassWithCycleInConstructorWithClassDependencyMethod>(ResolveKind.PartialEmitFunction);

            Assert.IsNotNull(sampleClass1);
            Assert.IsNotNull(sampleClass1.EmptyClass);
            Assert.IsNull(sampleClass2);
        }
コード例 #3
0
        public void ResolveClassWithCycleInConstructorWithClassDependencyMethodAfterBuildUpObjectOfThisClass_Failed()
        {
            var c = new Container();
            c.RegisterType<EmptyClass>().AsPerThread();
            c.RegisterType<SampleClassWithCycleInConstructorWithClassDependencyMethod>();
            var sampleClass1 = new SampleClassWithCycleInConstructorWithClassDependencyMethod(null);
            SampleClassWithCycleInConstructorWithClassDependencyMethod sampleClass2 = null;
            Exception exception = null;

            var thread = new Thread(() =>
            {
                try
                {
                    c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction);
                    sampleClass2 = c.Resolve<SampleClassWithCycleInConstructorWithClassDependencyMethod>(ResolveKind.PartialEmitFunction);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            });
            thread.Start();
            thread.Join();

            if (exception != null)
            {
                throw exception;
            }

            Assert.IsNotNull(sampleClass1);
            Assert.IsNotNull(sampleClass1.EmptyClass);
            Assert.IsNull(sampleClass2);
        }