Ejemplo n.º 1
0
        private static void InitInputValues(object dbSessionProvider)
        {
            var inputAttributes = InputAttribute.Resolve(dbSessionProvider.GetType());

            if (inputAttributes == null || inputAttributes.Length == 0)
            {
                return;
            }

            for (int i = 0; i < inputAttributes.Length; i++)
            {
                InitInputValue(dbSessionProvider, inputAttributes[i]);
            }
        }
Ejemplo n.º 2
0
        public void InputAttributes()
        {
            var obj        = new TestObject();
            var attributes = InputAttribute.Resolve(obj.GetType());

            Assert.AreEqual(2, attributes.Length);
            Assert.AreEqual("User Name", attributes[0].Title);
            Assert.AreEqual("DbInit_UserName", attributes[0].EnvironmentVariableName);
            Assert.AreEqual(false, attributes[0].IsPassword);
            Assert.AreEqual(nameof(TestObject.Password), attributes[1].Title);
            Assert.AreEqual(nameof(TestObject.Password), attributes[1].EnvironmentVariableName);
            Assert.AreEqual(true, attributes[1].IsPassword);

            attributes[0].SetValue(obj, "TestUserName");
            attributes[1].SetValue(obj, "TestPassword");
            Assert.AreEqual("TestUserName", obj.UserName);
            Assert.AreEqual("TestPassword", obj.Password);
        }