public static PicklistAttributeMetadata DeSerialisePicklistAttributeMetadata(PicklistAttributeMetadata item, XmlNode metaData) { XmlNode options = XmlHelper.SelectSingleNode(metaData, "OptionSet"); if (options != null) item.OptionSet = MetadataSerialiser.DeSerialiseOptionSetMetadata(new OptionSetMetadata(), options); return item; }
public static List <OptionSetItem> GetOptionSetValues(string entityLogicalName, string attributeLogicalName, bool?allowEmpty) { if (allowEmpty == null) { allowEmpty = false; } string cacheKey = entityLogicalName + "." + attributeLogicalName + "." + allowEmpty.ToString(); if (_optionsCache.ContainsKey(cacheKey)) { return(_optionsCache[cacheKey]); } else { AttributeMetadata attribute = LoadAttributeMetadata(entityLogicalName, attributeLogicalName); PicklistAttributeMetadata pickList = (PicklistAttributeMetadata)attribute; List <OptionSetItem> opts = new List <OptionSetItem>(); if (allowEmpty.Value) { opts.Add(new OptionSetItem()); } foreach (OptionMetadata o in pickList.OptionSet.Options) { OptionSetItem a = new OptionSetItem(); a.Name = o.Label.UserLocalizedLabel.Label; a.Value = o.Value.Value; opts.Add(a); } _optionsCache[cacheKey] = opts; return(opts); } }
public static PicklistAttributeMetadata DeSerialisePicklistAttributeMetadata(PicklistAttributeMetadata item, XmlNode metaData) { XmlNode options = XmlHelper.SelectSingleNode(metaData, "OptionSet"); if (options != null) { item.OptionSet = MetadataSerialiser.DeSerialiseOptionSetMetadata(new OptionSetMetadata(), options); } return(item); }