예제 #1
0
        private static object GetDependantProperty(IObjectCreator accessor, string propertyName, string parameterName, object parameterValue)
        {
            if (accessor == null || String.IsNullOrWhiteSpace(propertyName))
            {
                return(null);
            }

            using (DbManagerProxy dbmanager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
            {
                //create instance
                var obj = accessor.CreateNew(dbmanager, null, null);

                //set value of main property
                var settingProperty = obj.GetType().GetProperty(parameterName);

                if (settingProperty != null)
                {
                    settingProperty.SetValue(obj, parameterValue, null);
                }

                var property = obj.GetType().GetProperty(propertyName);

                if (property == null)
                {
                    return(null);
                }

                return(property.GetValue(obj, null));
            }
        }
예제 #2
0
        public R Create(DbManagerProxy manager, IObject Parent, int?HACode, params object[] pars)
        {
            T acc = DataAccessor.CreateInstance <T>();
            IObjectCreator creator = acc as IObjectCreator;

            return(creator.CreateNew(manager, Parent, HACode) as R);
        }
예제 #3
0
        private static object GetPropertyValue(IObjectCreator accessor, string propertyName)
        {
            if (accessor == null || String.IsNullOrWhiteSpace(propertyName))
            {
                return(null);
            }

            using (DbManagerProxy dbmanager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
            {
                var obj      = accessor.CreateNew(dbmanager, null, null);
                var property = obj.GetType().GetProperty(propertyName);

                if (property == null)
                {
                    return(null);
                }

                return(property.GetValue(obj, null));
            }
        }