private void SetValue(MethodInfo mi, object value) { string name = mi.Name.Substring(4); PropertyOptions po = _propertyOptions[name]; _ioHandler.Write(po, value); }
public void Intercept(IInvocation invocation) { if (PropertyResultBox.IsProperty(invocation.Method, out bool isGetProperty, out string propertyName)) { ResultBox rbox = _boxes[propertyName]; if (rbox is ProxyResultBox proxy) { if (!proxy.IsInitialised) { proxy.Initialise(_ioHandler, OptionPath.Combine(_prefix, proxy.StoreByName)); } if (!isGetProperty) { throw new NotSupportedException("cannot assign values to interface properties"); } //return a proxy interface invocation.ReturnValue = proxy.ProxyInstance; } else { PropertyResultBox pbox = (PropertyResultBox)rbox; string path = OptionPath.Combine(_prefix, pbox.StoreByName); if (isGetProperty) { invocation.ReturnValue = _ioHandler.Read(pbox.ResultBaseType, path, pbox.DefaultResult); } else { _ioHandler.Write(pbox.ResultBaseType, path, invocation.Arguments[0]); } } }
private void WriteProperty(PropertyResultBox pbox, object[] arguments) { string path = OptionPath.Combine(_basePath, pbox.StoreByName); _ioHandler.Write(pbox.ResultBaseType, path, arguments[0]); }