Example #1
0
        public void TestGetWithMember_Equals_HashCode()
        {
            BindingKey b1  = BindingKey.Get(typeof(object));
            BindingKey b1i = BindingKey.GetMember(typeof(object));
            BindingKey b2i = BindingKey.GetMember <object>();

            Assert.AreEqual(true, b1i.IsMember);
            Assert.AreEqual(true, b2i.IsMember);
            Assert.AreEqual(null, b1i.Qualifier);
            Assert.AreEqual(null, b2i.Qualifier);

            Assert.AreEqual(b1i, b2i);
            Assert.AreEqual(b1i.GetHashCode(), b2i.GetHashCode());
            Assert.AreNotEqual(b1, b1i);
            Assert.AreNotEqual(b1.GetHashCode(), b1i.GetHashCode());

            BindingKey b1Ex  = BindingKey.Get(typeof(Exception));
            BindingKey b1Exi = BindingKey.GetMember(typeof(Exception));
            BindingKey b2Exi = BindingKey.GetMember <Exception>();

            Assert.AreEqual(b1Exi, b2Exi);
            Assert.AreEqual(b1Exi.GetHashCode(), b2Exi.GetHashCode());
            Assert.AreNotEqual(b1Ex.GetHashCode(), b1Exi.GetHashCode());

            Assert.AreNotEqual(b1i, b1Exi);
            Assert.AreNotEqual(b2i, b2Exi);
        }
Example #2
0
        /// <inheritdoc/>
        public T InjectMembers <T> (T instance)
            where T : class
        {
            var iResolver = ResolveResolver(BindingKey.GetMember(instance.GetType()));

            iResolver.DoInject(instance);
            return(instance);
        }
Example #3
0
 internal BoundMembersBinding()
 {
     BindingConfig = new BindingConfig(typeof(CType));
     BindingKey    = BindingKey.GetMember <CType>();
 }