internal EntityDataSourceWrapper AddWrappedEntity(object entity) { EntityDataSourceWrapper wrapper = new EntityDataSourceWrapper(this, entity); this._wrapperList.Add(wrapper); return(wrapper); }
internal void SetValue(EntityDataSourceWrapper entity, object value) { object parentObjectValue = GetParentObjectValue(entity, true /* initialize */); // set property value on parent this.propertyInfo.SetValue(parentObjectValue, value, new object[] { }); }
internal static void ValidateKeyPropertyValuesExist(EntityDataSourceWrapper entityWrapper, Dictionary <string, object> propertyValues) { foreach (var keyProperty in entityWrapper.Collection.AllPropertyDescriptors.Select(d => d.Column).OfType <EntityDataSourcePropertyColumn>().Where(c => c.IsKey)) { if (!propertyValues.ContainsKey(keyProperty.DisplayName)) { throw new EntityDataSourceValidationException(Strings.EntityDataSourceView_NoKeyProperty); } } }
private object Initialize(EntityDataSourceWrapper entity) { // get parent's value object parentObjectValue = GetParentObjectValue(entity, true /* initialize */); // construct type instance for this property object propertyValue = EntityDataSourceUtil.InitializeType(this.ClrType); // set property this.propertyInfo.SetValue(parentObjectValue, propertyValue, new object[] { }); return(propertyValue); }
private EntityDataSourceWrapper GetWrapper(object component) { // Validate that the component comes from the collection to which // this descriptor is bound. Elements of the collection are // non-null wrappers instances. EntityDataSourceUtil.CheckArgumentNull(component, "component"); EntityDataSourceWrapper wrapper = component as EntityDataSourceWrapper; if (null == wrapper || this._collection != wrapper.Collection) { throw new ArgumentException(Strings.ComponentNotFromProperCollection, "component"); } return(wrapper); }
internal object GetValue(EntityDataSourceWrapper entity) { object parentObjectValue = GetParentObjectValue(entity, false /* initialize */); if (null == parentObjectValue) { // use convention that property of null is null return(null); } else { // get this property object propertyValue = this.propertyInfo.GetValue(parentObjectValue, new object[] { }); return(propertyValue); } }
/// <summary> /// Validates that the keys in the update parameters all match property names on the entityWrapper. /// </summary> /// <param name="entityWrapper"></param> /// <param name="parameters"></param> internal static void ValidateWebControlParameterNames(EntityDataSourceWrapper entityWrapper, ParameterCollection parameters, EntityDataSource owner) { Debug.Assert(null != entityWrapper, "entityWrapper should not be null"); if (null != parameters) { PropertyDescriptorCollection entityProperties = entityWrapper.GetProperties(); System.Collections.Specialized.IOrderedDictionary parmVals = parameters.GetValues(owner.HttpContext, owner); foreach (DictionaryEntry de in parmVals) { string key = de.Key as string; if (null == key || null == entityProperties.Find(key, false)) { throw new InvalidOperationException(Strings.EntityDataSourceUtil_InsertUpdateParametersDontMatchPropertyNameOnEntity(key, entityWrapper.WrappedEntity.GetType().ToString())); } } } }
internal static void SetAllPropertiesWithVerification(EntityDataSourceWrapper entityWrapper, Dictionary <string, object> changedProperties, bool overwrite) { Dictionary <string, Exception> exceptions = null; entityWrapper.SetAllProperties(changedProperties, /*overwriteSameValue*/ true, ref exceptions); if (null != exceptions) { // The EntityDataSourceValidationException has a property "InnerExceptions" that encapsulates // all of the failed property setters. The message from one of those errors is surfaced so that it // appears on the web page as a human-readable error like: // "Error while setting property 'PropertyName': 'The value cannot be null.'." string key = exceptions.Keys.First(); throw new EntityDataSourceValidationException( Strings.EntityDataSourceView_DataConversionError( key, exceptions[key].Message), exceptions); } }
private object GetParentObjectValue(EntityDataSourceWrapper entity, bool initialize) { // get parent's value object parentObjectValue; if (null == this.parent) { // at the top level, the entity is the value parentObjectValue = entity.WrappedEntity; } else { parentObjectValue = this.parent.GetValue(entity); if (null == parentObjectValue && initialize) { parentObjectValue = this.parent.Initialize(entity); } } return(parentObjectValue); }
internal override object GetValue(EntityDataSourceWrapper entity) { EntityKey entityKey = this.Group.GetEntityKey(entity); if (null == entityKey) { return(null); } else { object value = null; // loop through to find the correct keymember, take compound key into consideration foreach (EntityKeyMember entityKeyValue in entityKey.EntityKeyValues) { if (entityKeyValue.Key == this.KeyMember.Name) { value = entityKeyValue.Value; } } return(value); } }
override internal void SetValue(EntityDataSourceWrapper entity, object value) { this.memberPath.SetValue(entity, value); }
override internal object GetValue(EntityDataSourceWrapper entity) { return this.memberPath.GetValue(entity); }
internal abstract void SetValue(EntityDataSourceWrapper entity, object value);
internal abstract object GetValue(EntityDataSourceWrapper entity);
internal EntityDataSourceWrapper AddWrappedEntity(object entity) { EntityDataSourceWrapper wrapper = new EntityDataSourceWrapper(this, entity); this._wrapperList.Add(wrapper); return wrapper; }
internal object GetValue(EntityDataSourceWrapper entity) { object parentObjectValue = GetParentObjectValue(entity, false /* initialize */); if (null == parentObjectValue) { // use convention that property of null is null return null; } else { // get this property object propertyValue = this.propertyInfo.GetValue(parentObjectValue, new object[] { }); return propertyValue; } }
internal abstract void SetKeyValues(EntityDataSourceWrapper wrapper, Dictionary <string, object> newKeyValues);
internal abstract EntityKey GetEntityKey(EntityDataSourceWrapper entity);
internal abstract void SetKeyValues(EntityDataSourceWrapper wrapper, Dictionary<string, object> newKeyValues);
internal override void SetValue(EntityDataSourceWrapper entity, object value) { throw new InvalidOperationException(Strings.SetValueNotSupported); }
internal override object GetValue(EntityDataSourceWrapper entity) { EntityKey entityKey = this.Group.GetEntityKey(entity); if (null == entityKey) { return null; } else { object value = null; // loop through to find the correct keymember, take compound key into consideration foreach (EntityKeyMember entityKeyValue in entityKey.EntityKeyValues) { if (entityKeyValue.Key == this.KeyMember.Name) { value = entityKeyValue.Value; } } return value; } }
private object Initialize(EntityDataSourceWrapper entity) { // get parent's value object parentObjectValue = GetParentObjectValue(entity, true /* initialize */); // construct type instance for this property object propertyValue = EntityDataSourceUtil.InitializeType(this.ClrType); // set property this.propertyInfo.SetValue(parentObjectValue, propertyValue, new object[] { }); return propertyValue; }
override internal object GetValue(EntityDataSourceWrapper entity) { return(this.memberPath.GetValue(entity)); }
private object GetParentObjectValue(EntityDataSourceWrapper entity, bool initialize) { // get parent's value object parentObjectValue; if (null == this.parent) { // at the top level, the entity is the value parentObjectValue = entity.WrappedEntity; } else { parentObjectValue = this.parent.GetValue(entity); if (null == parentObjectValue && initialize) { parentObjectValue = this.parent.Initialize(entity); } } return parentObjectValue; }