static private bool DenormalizeMessenger <E>(ICard2 card, ITypedProperty <E> prop, int index) where E : ExtendibleEnum { string typeVal = prop.RawProperty.TextValue.Split(':').FirstOrDefault() ?? "Messenger"; if (typeVal.Length > 1) { typeVal = typeVal.First().ToString().ToUpper() + typeVal.Substring(1); // Make first letter capital. } // Add "itemX.PROP" property. string applePropName = string.Format("item10{0}.IMPP", index); prop.RawProperty.Parameters.Add(new Parameter("X-SERVICE-TYPE", typeVal)); card.AddProperty(applePropName, prop.RawProperty); // Add itemN.X-ABLabel property. string appleLabelPropName = string.Format("item10{0}.X-ABLabel", index); ITextProperty appleLabelProp = card.CreateTextProp(typeVal); appleLabelProp.RawProperty.SortIndex = prop.RawProperty.SortIndex; card.AddProperty(appleLabelPropName, appleLabelProp.RawProperty); return(true); }
static private bool DenormalizeTypedProperty <E>(ICard2 card, ITypedProperty <E> prop, string propName, int index, IEnumerable <string> supportedStandardTypes, IEnumerable <string> customLabelMetaTypes) where E : ExtendibleEnum { // Find first non-standard type param and move it to item2.X-ABLabel property. foreach (E type in prop.Types) { string typeVal = type.Name; if (supportedStandardTypes.Contains(typeVal.ToUpper())) { continue; // No need to change, continue searching. } if (customLabelMetaTypes.Contains(typeVal.ToUpper())) { // Must be converted to itemN.X-ABLabel:_$!<Other>!$_ typeVal = string.Format("_$!<{0}>!$_", typeVal); } // Remove this param value from TYPE. prop.Types = prop.Types.Where(x => x != type).ToArray(); // Add "itemX.PROP" property. string applePropName = string.Format("item10{0}.{1}", index, propName); card.AddProperty(applePropName, prop.RawProperty); // Add itemN.X-ABLabel property. string appleLabelPropName = string.Format("item10{0}.X-ABLabel", index); ITextProperty appleLabelProp = card.CreateTextProp(typeVal); appleLabelProp.RawProperty.SortIndex = prop.RawProperty.SortIndex; card.AddProperty(appleLabelPropName, appleLabelProp.RawProperty); return(true); } return(false); }