unitycontainer / configuration

Unity.Configuration package
Apache License 2.0
13 stars 13 forks source link

Method not called on instance creation when registration configured via XML #35

Closed DeKon0650 closed 3 years ago

DeKon0650 commented 4 years ago

In XML file method call is configured on type registration. But the method is not called on resolving an instance. Here are samples of configuration and code. Tested on 5.11.6

  <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <reginster type="TestClass">
      <method name="TestMethod" />
    </reginster>
  </unity>
    class Program
    {
        static void Main(string[] args)
        {
            var unity = new UnityContainer();

            var t = unity.Resolve<TestClass>();

            Console.ReadLine();
        }
    }

    public class TestClass
    {
        public TestClass()
        {
            Console.WriteLine("constructor");
        }

        public void TestMethod()
        {
            Console.WriteLine("method");
        }
    }
ENikS commented 4 years ago

All of these supposedly work. Did you configure the section?

DeKon0650 commented 4 years ago

Made mistakes in configuration. My bad. Thanks.