using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IcgSoftware.Threema.CoreMsgApi.Results { /// /// Result of a capability lookup /// public class CapabilityResult { private readonly string key; private readonly string[] capabilities; public CapabilityResult(string key, string[] capabilities) { this.key = key; this.capabilities = capabilities; } public string Key { get { return key; } } /// /// Get all capabilities as a string array. /// public string[] Capabilities { get { return capabilities; } } /// /// Check whether the Threema ID can receive text /// public bool CanText { get { return this.Can("text"); } } /// /// Check whether the Threema ID can receive images /// public bool CanImage { get { return this.Can("image"); } } /// /// Check whether the Threema ID can receive videos /// public bool CanVideo { get { return this.Can("video"); } } /// /// Check whether the Threema ID can receive audio /// public bool CanAudio { get { return this.Can("audio"); } } /// /// Check whether the Threema ID can receive files /// public bool CanFile { get { return this.Can("file"); } } public override string ToString() { StringBuilder b = new StringBuilder(); b.Append(this.key).Append(": "); for (int n = 0; n < this.capabilities.Length; n++) { if (n > 0) { b.Append(","); } b.Append(this.capabilities[n]); } return b.ToString(); } private bool Can(string key) { return this.capabilities.Any(k => k.Equals(key)); } } }