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 AttributeMetadata DeSerialiseAttributeMetadata(AttributeMetadata item, XmlNode attribute) { // Get the attributemetadata foreach (XmlNode node in attribute.ChildNodes) { Dictionary <string, object> itemValues = (Dictionary <string, object>)(object) item; string localName = XmlHelper.GetLocalName(node); string fieldName = localName.Substr(0, 1).ToLowerCase() + localName.Substr(1); // Check nil and don't set the value to save time/space if (node.Attributes.Count == 1 && node.Attributes[0].Name == "i:nil") { continue; } // Non Type Specific properties switch (localName) { // String values case "AttributeOf": case "DeprecatedVersion": case "EntityLogicalName": case "LogicalName": case "SchemaName": case "CalculationOf": itemValues[fieldName] = XmlHelper.GetNodeTextValue(node); break; // Bool values case "CanBeSecuredForCreate": case "CanBeSecuredForRead": case "CanBeSecuredForUpdate": case "CanModifyAdditionalSettings": case "IsAuditEnabled": case "IsCustomAttribute": case "IsCustomizable": case "IsManaged": case "IsPrimaryId": case "IsPrimaryName": case "IsRenameable": case "IsSecured": case "IsValidForAdvancedFind": case "IsValidForCreate": case "IsValidForRead": case "IsValidForUpdate": case "DefaultValue": itemValues[fieldName] = Attribute.DeSerialise(node, AttributeTypes.Boolean_); break; // Int Values case "ColumnNumber": case "Precision": case "DefaultFormValue": case "MaxLength": case "PrecisionSource": itemValues[fieldName] = Attribute.DeSerialise(node, AttributeTypes.Int_); break; // Label case "Description": case "DisplayName": Label label = new Label(); itemValues[fieldName] = MetadataSerialiser.DeSerialiseLabel(label, node); break; //OptionSet case "OptionSet": OptionSetMetadata options = new OptionSetMetadata(); itemValues[fieldName] = MetadataSerialiser.DeSerialiseOptionSetMetadata(options, node); break; case "AttributeType": item.AttributeType = (AttributeTypeCode)(object)XmlHelper.GetNodeTextValue(node); break; //Guid // LinkedAttributeId //AttributeRequiredLevel //RequiredLevel //DateTime //MaxSupportedValue (DateTimeAttributeMetadata) //MinSupportedValue (DateTimeAttributeMetadata) //decimal //MaxValue (DecimalAttributeMetadata) //IntegerFormat //Format //string[] //Targets } // Type sepcific attributes //Boolean //DefaultValue (OptionSetMetadata) //int // MaxValue (IntegerAttributeMetadata) // MinValue (IntegerAttributeMetadata) // StringFormat //Format (MemoAttributeMetadata,StringAttributeMetadata) //double //MaxValue (DoubleAttributeMetadata, MoneyAttributeMetadata) //MinValue (DoubleAttributeMetadata, MoneyAttributeMetadata) //DateTimeFormat //Format (DateTimeAttributeMetadata) //long //MaxValue (BigIntAttributeMetadata) //MinValue (BigIntAttributeMetadata) } return(item); }