private void HandleSetter(MethodInfo method, IInvocation invocation) { // Find the get method var getter = invocation.TargetType.GetMethod("g" + method.Name.Remove(0, 1)); PropertyValue propValue; if (Properties.TryGetValue(getter, out propValue)) { // Resets the value... propValue.Value = invocation.GetArgumentValue(0); return; } // Sets the value and caches it. propValue = Properties[getter] = new PropertyValue { Value = invocation.GetArgumentValue(0), // If this is a collection field interceptor then the value // returned should allways be considered as loaded. IsLoaded = InterceptCollections }; }
private void HandleGetter(MethodInfo method, IInvocation invocation) { PropertyValue propValue; // Try to fetch from cache and check if this is fully loaded. if (Properties.TryGetValue(method, out propValue) && propValue.IsLoaded) { invocation.ReturnValue = propValue.Value; return; } // var value = GetFieldValue(method, invocation); if (propValue == null) { // Cache the returned value from the HandleFieldGetValue; propValue = Properties[method] = new PropertyValue { // If this is a collection field interceptor then the value // returned should allways be considered as loaded. IsLoaded = InterceptCollections }; } // Cache and return the value. propValue.Value = invocation.ReturnValue = value; }