Esempio n. 1
0
        private IFieldAccessor BuildFieldAccessor(object ob, string fieldName)
        {
            var klass = ob.GetType();

            var accessType = _configurationManager.GetAccessType();

            if (_provider.HasAccessType(klass))
            {
                accessType = _provider.GetAccessType(klass);
            }
            if (_provider.HasPropertyAccessType(klass, fieldName))
            {
                accessType = _provider.GetPropertyAccessType(klass, fieldName);
            }

            var customGetter = _provider.GetPropertyCustomGetterName(klass, fieldName);

            var fieldAccessor = new FieldAccessor(ob, fieldName, accessType);

            fieldAccessor.SetCustomGetterName(customGetter);

            if (_logger != null)
            {
                fieldAccessor.SetLogger(_logger);
            }

            if (_provider.IsVirtualProperty(klass, fieldName))
            {
                fieldAccessor.SetEnsureFieldExists(false);
            }

            return(fieldAccessor);
        }