/// <summary> /// Assigns a value to a field on this object. /// </summary> /// <param name="field">The field to set</param> /// <param name="newValue">The new value to assign to the field</param> /// <param name="fixLength">Determines if the length should be truncated if too long. When false, an error will be raised if data is too large to be assigned to the field.</param> public virtual void SetValue(Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants field, object newValue, bool fixLength) { if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.AddedDate) { this.AddedDate = GlobalValues.SetValueHelperDateTimeNotNullableInternal(newValue, "Field 'AddedDate' does not allow null values!"); } else if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Count) { this.Count = GlobalValues.SetValueHelperIntNotNullableInternal(newValue, "Field 'Count' does not allow null values!"); } else if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Reason) { this.Reason = GlobalValues.SetValueHelperInternal((string)newValue, fixLength, GetMaxLength(field)); } else if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.RepositoryId) { this.RepositoryId = GlobalValues.SetValueHelperIntNotNullableInternal(newValue, "Field 'RepositoryId' does not allow null values!"); } else if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.RowId) { throw new Exception("Field '" + field.ToString() + "' is a primary key and cannot be set!"); } else if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Subkey) { this.Subkey = GlobalValues.SetValueHelperInternal((string)newValue, fixLength, GetMaxLength(field)); } else { throw new Exception("Field '" + field.ToString() + "' not found!"); } }
/// <summary> /// Gets the value of one of this object's properties. /// </summary> public virtual object GetValue(Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants field, object defaultValue) { if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.AddedDate) { return(this.AddedDate); } if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Count) { return(this.Count); } if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Reason) { return((this.Reason == null) ? defaultValue : this.Reason); } if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.RepositoryId) { return(this.RepositoryId); } if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.RowId) { return(this.RowId); } if (field == Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Subkey) { return((this.Subkey == null) ? defaultValue : this.Subkey); } throw new Exception("Field '" + field.ToString() + "' not found!"); }
/// <summary> /// Gets the system type of a field on this object /// </summary> public static System.Type GetFieldType(Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants field) { if (field.GetType() != typeof(Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants)) { throw new Exception("The field parameter must be of type 'Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants'."); } switch ((Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants)field) { case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.AddedDate: return(typeof(DateTime)); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Count: return(typeof(int)); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Reason: return(typeof(string)); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.RepositoryId: return(typeof(int)); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.RowId: return(typeof(long)); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Subkey: return(typeof(string)); } return(null); }
/// <summary> /// Gets the maximum size of the field value. /// </summary> public static int GetMaxLength(Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants field) { switch (field) { case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.AddedDate: return(0); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Count: return(0); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Reason: return(20); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.RepositoryId: return(0); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.RowId: return(0); case Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants.Subkey: return(50); } return(0); }
/// <summary> /// Returns the actual database name of the specified field. /// </summary> internal static string GetDatabaseFieldName(Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants field) { return(GetDatabaseFieldName(field.ToString())); }
/// <summary> /// Assigns a value to a field on this object. /// </summary> /// <param name="field">The field to set</param> /// <param name="newValue">The new value to assign to the field</param> public virtual void SetValue(Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants field, object newValue) { SetValue(field, newValue, false); }
/// <summary> /// Gets the value of one of this object's properties. /// </summary> public virtual object GetValue(Gravitybox.Datastore.EFDAL.Entity.CacheInvalidate.FieldNameConstants field) { return(GetValue(field, null)); }