/// <summary> /// Creates a new <see cref="Notification"/> from a list of headers /// </summary> /// <param name="headers">The <see cref="HeaderCollection"/> used to populate the object</param> /// <returns><see cref="Notification"/></returns> public static Notification FromHeaders(HeaderCollection headers) { string appName = headers.GetHeaderStringValue(Header.APPLICATION_NAME, true); string name = headers.GetHeaderStringValue(Header.NOTIFICATION_NAME, true); string id = headers.GetHeaderStringValue(Header.NOTIFICATION_ID, false); string title = headers.GetHeaderStringValue(Header.NOTIFICATION_TITLE, true); string text = headers.GetHeaderStringValue(Header.NOTIFICATION_TEXT, false); if (text == null) { text = String.Empty; } string coalescingID = headers.GetHeaderStringValue(Header.NOTIFICATION_COALESCING_ID, false); Resource icon = headers.GetHeaderResourceValue(Header.NOTIFICATION_ICON, false); bool sticky = headers.GetHeaderBooleanValue(Header.NOTIFICATION_STICKY, false); string p = headers.GetHeaderStringValue(Header.NOTIFICATION_PRIORITY, false); Priority priority = Growl.Connector.Priority.Normal; if (p != null) { int pval = 0; bool pok = int.TryParse(p, out pval); if (pok && Enum.IsDefined(typeof(Priority), pval)) { priority = (Priority)pval; } } Notification notification = new Notification(appName, name, id, title, text, icon, sticky, priority, coalescingID); SetInhertiedAttributesFromHeaders(notification, headers); return(notification); }
/// <summary> /// Creates a new <see cref="NotificationType"/> from a list of headers /// </summary> /// <param name="headers">The <see cref="HeaderCollection"/> used to populate the response</param> /// <returns><see cref="NotificationType"/></returns> public static NotificationType FromHeaders(HeaderCollection headers) { string name = headers.GetHeaderStringValue(Header.NOTIFICATION_NAME, true); string displayName = headers.GetHeaderStringValue(Header.NOTIFICATION_DISPLAY_NAME, false); Resource icon = headers.GetHeaderResourceValue(Header.NOTIFICATION_ICON, false); bool enabled = headers.GetHeaderBooleanValue(Header.NOTIFICATION_ENABLED, false); NotificationType nt = new NotificationType(name, displayName, icon, enabled); SetCustomAttributesFromHeaders(nt, headers); // NOTE: dont call SetInheritedAttributesFromHeaders because we want to ignore the common attributes return(nt); }