internal static void ValidateRegistration(RegistrationDescription registration)
        {
            string str;
            WindowsTemplateRegistrationDescription windowsTemplateRegistrationDescription = registration as WindowsTemplateRegistrationDescription;

            if (windowsTemplateRegistrationDescription == null)
            {
                MpnsTemplateRegistrationDescription mpnsTemplateRegistrationDescription = registration as MpnsTemplateRegistrationDescription;
                if (mpnsTemplateRegistrationDescription != null)
                {
                    mpnsTemplateRegistrationDescription.SetMpnsType();
                }
            }
            else
            {
                windowsTemplateRegistrationDescription.SetWnsType();
            }
            RegistrationDescription registrationDescription = registration;

            if (registration.Tags == null || registration.Tags.Count == 0)
            {
                str = null;
            }
            else
            {
                str = string.Join(",", registration.Tags);
            }
            registrationDescription.TagsString = str;
            registration.Validate(true, ApiVersion.Four, true);
        }
        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);
                    }
                }
            }
        }
 public WindowsTemplateRegistrationDescription(WindowsTemplateRegistrationDescription sourceRegistration) : base(sourceRegistration)
 {
     this.WnsHeaders = new WnsHeaderCollection();
     if (sourceRegistration.WnsHeaders != null)
     {
         foreach (KeyValuePair <string, string> wnsHeader in sourceRegistration.WnsHeaders)
         {
             this.WnsHeaders.Add(wnsHeader.Key, wnsHeader.Value);
         }
     }
     this.BodyTemplate = sourceRegistration.BodyTemplate;
     this.TemplateName = sourceRegistration.TemplateName;
 }