protected override void OnValidateAndPopulateHeaders() { if (!base.Headers.ContainsKey("X-NotificationClass")) { this.AddNotificationTypeHeader(RegistrationSDKHelper.DetectMpnsTemplateRegistationType(base.Body, SRClient.NotSupportedXMLFormatAsPayloadForMpns)); base.Body = RegistrationSDKHelper.AddDeclarationToXml(base.Body); } }
private static void SetWnsType(this WindowsTemplateRegistrationDescription registration) { if (registration == null || registration.IsJsonObjectPayLoad()) { return; } if (registration.IsXmlPayLoad()) { if (registration.WnsHeaders == null) { registration.WnsHeaders = new WnsHeaderCollection(); } if (!registration.WnsHeaders.ContainsKey("X-WNS-Type") || !registration.WnsHeaders["X-WNS-Type"].Equals("wns/raw", StringComparison.OrdinalIgnoreCase)) { switch (RegistrationSDKHelper.DetectWindowsTemplateRegistationType(registration.BodyTemplate, SRClient.NotSupportedXMLFormatAsBodyTemplate)) { case WindowsTemplateBodyType.Toast: { RegistrationSDKHelper.AddOrUpdateHeader(registration.WnsHeaders, "X-WNS-Type", "wns/toast"); return; } case WindowsTemplateBodyType.Tile: { RegistrationSDKHelper.AddOrUpdateHeader(registration.WnsHeaders, "X-WNS-Type", "wns/tile"); return; } case WindowsTemplateBodyType.Badge: { RegistrationSDKHelper.AddOrUpdateHeader(registration.WnsHeaders, "X-WNS-Type", "wns/badge"); break; } default: { return; } } } else { try { XmlDocument xmlDocument = new XmlDocument(); using (XmlReader xmlReader = XmlReader.Create(new StringReader(registration.BodyTemplate))) { xmlDocument.Load(xmlReader); } } catch (XmlException xmlException) { throw new ArgumentException(SRClient.NotSupportedXMLFormatAsBodyTemplate); } } } }
protected override void OnValidateAndPopulateHeaders() { if (base.Headers.ContainsKey("X-WNS-Type") && base.Headers["X-WNS-Type"].Equals("wns/raw", StringComparison.OrdinalIgnoreCase)) { this.AddNotificationTypeHeader(WindowsTemplateBodyType.Raw); base.ContentType = "application/octet-stream"; return; } this.AddNotificationTypeHeader(RegistrationSDKHelper.DetectWindowsTemplateRegistationType(base.Body, SRClient.NotSupportedXMLFormatAsPayload)); base.Body = RegistrationSDKHelper.AddDeclarationToXml(base.Body); }
private static void SetMpnsType(this MpnsTemplateRegistrationDescription registration) { if (registration == null || registration.IsJsonObjectPayLoad()) { return; } if (registration.MpnsHeaders != null && registration.MpnsHeaders.ContainsKey("X-NotificationClass")) { int num = int.Parse(registration.MpnsHeaders["X-NotificationClass"], CultureInfo.InvariantCulture); if (num >= 3 && num <= 10 || num >= 13 && num <= 20 || num >= 23 && num <= 31) { return; } } if (registration.IsXmlPayLoad()) { if (registration.MpnsHeaders == null) { registration.MpnsHeaders = new MpnsHeaderCollection(); } switch (RegistrationSDKHelper.DetectMpnsTemplateRegistationType(registration.BodyTemplate, SRClient.NotSupportedXMLFormatAsBodyTemplateForMpns)) { case MpnsTemplateBodyType.Toast: { RegistrationSDKHelper.AddOrUpdateHeader(registration.MpnsHeaders, "X-WindowsPhone-Target", "toast"); RegistrationSDKHelper.AddOrUpdateHeader(registration.MpnsHeaders, "X-NotificationClass", "2"); break; } case MpnsTemplateBodyType.Tile: { RegistrationSDKHelper.AddOrUpdateHeader(registration.MpnsHeaders, "X-WindowsPhone-Target", "token"); RegistrationSDKHelper.AddOrUpdateHeader(registration.MpnsHeaders, "X-NotificationClass", "1"); return; } default: { return; } } } }