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)); } }
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); }
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)); } }