5
我已經寫了幾個自定義模型粘合劑,現在,已經意識到我已經陷入了依靠神奇的字符串,如陷阱:如何從定製模型活頁夾中移除魔術字符串?
if (bindingContext.ValueProvider.ContainsPrefix("PaymentKey"))
{
paymentKey = bindingContext.ValueProvider.GetValue("PaymentKey").AttemptedValue;
}
我希望能夠使用表達式強類型的前綴名稱,但無法弄清楚如何,並會感謝一些幫助。
謝謝。
您可以創建一個靜態類來保存這些字符串值作爲屬性和引用屬性,而不是。例如:bindingContext.ValueProvider.ContainsPrefix(SomeClass.PaymentKey) – 2010-10-05 19:07:23