/// <summary> /// Check if a property is tagged with a certain tag /// </summary> /// <param name="methodCallInfo">IMethodCallMessage</param> private void IsTaggedWith(MethodCallInfo methodCallInfo) { methodCallInfo.ReturnValue = false; if (_taggedProperties.TryGetValue(methodCallInfo.PropertyNameOf(0), out var tags)) { methodCallInfo.ReturnValue = tags.ContainsKey(methodCallInfo.Arguments[1]); } }
/// <summary> /// Return the default value for a property /// </summary> private static void GetDefaultValue(MethodCallInfo methodCallInfo) { var propertyInfo = typeof(T).GetProperty(methodCallInfo.PropertyNameOf(0)); // Prevent ArgumentNullExceptions if (propertyInfo != null) { methodCallInfo.ReturnValue = GetConvertedDefaultValue(propertyInfo); } }
/// <summary> /// Return the default value for a property /// </summary> private void RestoreToDefault(MethodCallInfo methodCallInfo) { var propertyInfo = typeof(T).GetProperty(methodCallInfo.PropertyNameOf(0)); // Prevent ArgumentNullExceptions if (propertyInfo == null) { return; } RestoreToDefault(methodCallInfo.Interceptor, propertyInfo, out var _); }
/// <summary> /// Check if a property is tagged with a certain tag /// </summary> /// <param name="methodCallInfo">IMethodCallMessage</param> private void GetTagValue(MethodCallInfo methodCallInfo) { methodCallInfo.ReturnValue = false; if (!_taggedProperties.TryGetValue(methodCallInfo.PropertyNameOf(0), out var tags)) { return; } var hasTag = tags.ContainsKey(methodCallInfo.Arguments[1]); object returnValue = null; if (hasTag) { returnValue = tags[methodCallInfo.Arguments[1]]; } methodCallInfo.ReturnValue = returnValue; }
/// <summary> /// Test if the supplied property was changed /// </summary> /// <param name="methodCallInfo">MethodCallInfo</param> private void IsChanged(MethodCallInfo methodCallInfo) { methodCallInfo.ReturnValue = _changedValues.Contains(methodCallInfo.PropertyNameOf(0).ToLowerInvariant()); }
/// <summary> /// Return the description for a property /// </summary> private static void GetDescription(MethodCallInfo methodCallInfo) { var propertyInfo = typeof(T).GetProperty(methodCallInfo.PropertyNameOf(0)); methodCallInfo.ReturnValue = propertyInfo.GetDescription(); }
/// <summary> /// IsWriteProtected logic checks if the supplied property Lambda expression is write protected. /// </summary> /// <param name="methodCallInfo">IMethodCallMessage</param> private void IsWriteProtected(MethodCallInfo methodCallInfo) { methodCallInfo.ReturnValue = _writeProtectedProperties.Contains(methodCallInfo.PropertyNameOf(0)); }
/// <summary> /// DisableWriteProtect removes the write protection of the supplied property in the LambdaExpression /// </summary> /// <param name="methodCallInfo">IMethodCallMessage</param> private void DisableWriteProtect(MethodCallInfo methodCallInfo) { _writeProtectedProperties.Remove(methodCallInfo.PropertyNameOf(0)); }
/// <summary> /// WriteProtect sets the write protection of the supplied property in the LambdaExpression /// </summary> /// <param name="methodCallInfo">IMethodCallMessage</param> private void WriteProtect(MethodCallInfo methodCallInfo) { _writeProtectedProperties.Add(methodCallInfo.PropertyNameOf(0)); }