/// <summary> /// Sets value to cached property /// </summary> /// <param name="aObject"> /// Object where property resides <see cref="System.Object"/> /// </param> /// <param name="aProperty"> /// Property name <see cref="System.String"/> /// </param> /// <param name="aValue"> /// New value <see cref="System.Object"/> /// </param> /// <param name="aDefaultValue"> /// Default value which should be returned if method was unsuccessful <see cref="System.Object"/> /// </param> /// <returns> /// true if successful, false if not <see cref="System.Boolean"/> /// </returns> public bool GetValue(object aObject, string aProperty, out object aValue, object aDefaultValue) { bool startMethod = false; aValue = aDefaultValue; if (IsCached == true) { if (aProperty == PropertyName) { startMethod = true; } } else { if (IsCompatible(aObject) == true) { if (aProperty == PropertyName) { startMethod = IsCached; } } } // Start copying data if (startMethod == true) { if (IsProperty == true) { aValue = ConnectionProvider.GetPropertyValue(aObject, propInfo); return(true); } if (IsVirtualProperty == true) { aValue = propVirtual.Value; return(true); } if (IsDataRowField == true) { return(DatabaseProvider.GetValue(aObject, propColumn, out aValue, aDefaultValue)); } throw new ExceptionCachedPropertyGetValueFailed(this); } else { // If method arrived here then this is not a valid cache for that property // fallback creates temporary cache and gets value trough it return(CachedProperty.UncachedGetValue(aObject, aProperty, out aValue, aDefaultValue)); } return(false); }
/// <summary> /// Creates temporary cache and gets value from the property /// </summary> /// <param name="aObject"> /// Object which needs value to be set <see cref="System.Object"/> /// </param> /// <param name="aProperty"> /// Property name <see cref="System.String"/> /// </param> /// <param name="aValue"> /// Property value <see cref="System.Object"/> /// </param> /// <returns> /// true if successful, false if not <see cref="System.Boolean"/> /// </returns> /// <remarks> /// calls CachedProperty.UncachedGetValue with null as default value /// </remarks> public static bool UncachedGetValue(object aObject, string aProperty, out object aValue) { return(CachedProperty.UncachedGetValue(aObject, aProperty, out aValue, null)); }