private void WriteDataDetectorTypes(JsonWriter writer) { if (DataDetectorTypes != DataDetectorTypes.PKDataDetectorAll) { writer.WritePropertyName("dataDetectorTypes"); writer.WriteStartArray(); foreach (Enum value in Enum.GetValues(typeof(DataDetectorTypes))) { if (value.CompareTo(DataDetectorTypes.PKDataDetectorNone) != 0 && value.CompareTo(DataDetectorTypes.PKDataDetectorAll) != 0 && DataDetectorTypes.HasFlag(value)) { writer.WriteValue(value.ToString()); } } writer.WriteEndArray(); } }
// Dotfucated friendly enum name conversion // http://stackoverflow.com/questions/483794/convert-enum-to-string public static string ToSafeString(this DataDetectorTypes dataDetectorType) { switch (dataDetectorType) { case DataDetectorTypes.PKDataDetectorTypeAddress: return("PKDataDetectorTypeAddress"); case DataDetectorTypes.PKDataDetectorTypeCalendarEvent: return("PKDataDetectorTypeCalendarEvent"); case DataDetectorTypes.PKDataDetectorTypeLink: return("PKDataDetectorTypeLink"); case DataDetectorTypes.PKDataDetectorTypePhoneNumber: return("PKDataDetectorTypePhoneNumber"); default: return(""); } }
public StandardField(string key, string label, string value, string attributedValue, DataDetectorTypes dataDetectorTypes) : this(key, label, value) { this.AttributedValue = attributedValue; this.DataDetectorTypes = DataDetectorTypes.PKDataDetectorAll; }