private bool PortfolioAjaxAction(HttpListenerContext context) { UiFieldAttribute.SetFieldsFromPropNameValue( context.Request.QueryString.AllKeys.ToDictionary(q => q, q => context.Request.QueryString[q]), RobotFarm.Instance.portfolioTradeSettings, true); RobotFarm.Instance.SaveSettings(); const string answer = "{\"status\": \"OK\"}"; WriteJsonResponse(context, answer); return(true); }
public void TestPropertyDic() { var sets = new AutoTradeSettings { MaxLeverage = 6, TradeAuto = true }; var nameVal = UiFieldAttribute.GetAttributeNameValue(sets); Assert.Greater(nameVal.Count, 0); var cat = new AutoTradeSettings(); UiFieldAttribute.SetFieldsFromPropNameValue( nameVal.ToDictionary(p => p.PropName, p => Converter.GetStringFromObject(p.Value)), cat, false); Assert.AreEqual(sets.MaxLeverage, cat.MaxLeverage); Assert.AreEqual(sets.TradeAuto, cat.TradeAuto); }