示例#1
0
        /// <summary>
        /// Sets the choice list.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="list">The list.</param>
        public static void SetChoiceList(IEditableRoot item, MobileObservableCollection<ChoiceInfo> list)
        {
            foreach (var property in item.GetAllPropertiesForType())
            {
                var editor = property.GetCustomAttributes(typeof(FieldEditorAttribute), false).FirstOrDefault();
                if (editor != null && ((FieldEditorAttribute)editor).DataType == Constants.ChoiceFieldType)
                {
                    var choiceString = property.GetValue(item, null) as string;
                    XElement choiceXml = null;
                    if (!string.IsNullOrEmpty(choiceString))
                        choiceXml = XElement.Parse(choiceString);

                    property.SetValue(item, SetChoiceList(list, choiceXml), null);

                    break;
                }
            }
        }