コード例 #1
0
        static void Main(string[] args)
        {
            var services = new Cat()
                           .Register <Base, Foo>(Lifetime.Transient)
                           .Register <Base, Bar>(Lifetime.Transient)
                           .Register <Base, Baz>(Lifetime.Transient)
                           .GetServices <Base>();

            Debug.Assert(services.OfType <Foo>().Any());
            Debug.Assert(services.OfType <Bar>().Any());
            Debug.Assert(services.OfType <Baz>().Any());
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: wangxiaowei010204/DIDemo
        private static void GetServices()
        {
            var services = new Cat()
                           .Register <Base, Foo>(Lifetime.Transient)
                           .Register <Base, Bar>(Lifetime.Transient)
                           .Register <Base, Baz>(Lifetime.Transient)
                           .GetServices <Base>();

            Debug.Assert(services.OfType <Foo>().Any());
            Debug.Assert(services.OfType <Bar>().Any());
            Debug.Assert(services.OfType <Baz>().Any());
        }