public string SerializeBinding(string globalLang, string globalBaseUri, TileBranding globalBranding, bool globalAddImageQuery) { StringBuilder bindingNode = new StringBuilder(String.Empty); bindingNode.AppendFormat("<binding template='{0}'", TemplateName); if (!String.IsNullOrWhiteSpace(Lang) && !Lang.Equals(globalLang)) { bindingNode.AppendFormat(" lang='{0}'", Util.HttpEncode(Lang)); globalLang = Lang; } if (Branding != TileBranding.Logo && Branding != globalBranding) { bindingNode.AppendFormat(" branding='{0}'", Branding.ToString().ToLowerInvariant()); } if (!String.IsNullOrWhiteSpace(BaseUri) && !BaseUri.Equals(globalBaseUri)) { bindingNode.AppendFormat(" baseUri='{0}'", Util.HttpEncode(BaseUri)); globalBaseUri = BaseUri; } if (AddImageQueryNullable != null && AddImageQueryNullable != globalAddImageQuery) { bindingNode.AppendFormat(" addImageQuery='{0}'", AddImageQuery.ToString().ToLowerInvariant()); globalAddImageQuery = AddImageQuery; } bindingNode.AppendFormat(">{0}</binding>", SerializeProperties(globalLang, globalBaseUri, globalAddImageQuery)); return(bindingNode.ToString()); }
public override string GetContent() { StringBuilder builder = new StringBuilder(String.Empty); builder.AppendFormat("<tile><visual version='{0}'", Util.NotificationContentVersion); if (!String.IsNullOrWhiteSpace(Lang)) { builder.AppendFormat(" lang='{0}'", Util.HttpEncode(Lang)); } if (Branding != TileBranding.Logo) { builder.AppendFormat(" branding='{0}'", Branding.ToString().ToLowerInvariant()); } if (!String.IsNullOrWhiteSpace(BaseUri)) { builder.AppendFormat(" baseUri='{0}'", Util.HttpEncode(BaseUri)); } if (AddImageQuery) { builder.AppendFormat(" addImageQuery='true'"); } builder.Append(">"); builder.Append(SerializeBinding(Lang, BaseUri, Branding, AddImageQuery)); builder.Append("</visual></tile>"); return(builder.ToString()); }
public override string GetContent() { if (RequireSquareContent && SquareContent == null) { throw new NotificationContentValidationException( "Square tile content should be included with each wide tile. " + "If this behavior is undesired, use the RequireSquareContent property."); } StringBuilder visualNode = new StringBuilder(String.Empty); visualNode.AppendFormat("<visual version='{0}'", Util.NotificationContentVersion); if (!String.IsNullOrWhiteSpace(Lang)) { visualNode.AppendFormat(" lang='{0}'", Util.HttpEncode(Lang)); } if (Branding != TileBranding.Logo) { visualNode.AppendFormat(" branding='{0}'", Branding.ToString().ToLowerInvariant()); } if (!String.IsNullOrWhiteSpace(BaseUri)) { visualNode.AppendFormat(" baseUri='{0}'", Util.HttpEncode(BaseUri)); } if (AddImageQuery) { visualNode.AppendFormat(" addImageQuery='true'"); } visualNode.Append(">"); StringBuilder builder = new StringBuilder(String.Empty); builder.AppendFormat("<tile>{0}<binding template='{1}'>{2}</binding>", visualNode, TemplateName, SerializeProperties(Lang, BaseUri, AddImageQuery)); if (SquareContent != null) { ISquareTileInternal squareBase = SquareContent as ISquareTileInternal; if (squareBase == null) { throw new NotificationContentValidationException("The provided square tile content class is unsupported."); } builder.Append((string)squareBase.SerializeBinding(Lang, BaseUri, Branding, AddImageQuery)); } builder.Append("</visual></tile>"); return(builder.ToString()); }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (State == ButtonState.Primary && Weight != ButtonWeight.Clear) { // TODO throw necessary? throw new System.Exception("Cannot have a Type set when State is set to Primary."); } if (Branding != ButtonBranding.None && (Weight != ButtonWeight.Clear || State != ButtonState.Secondary)) { // TODO throw necessary? throw new System.Exception("Cannot have Weight or State set when Branding is set."); } output.TagMode = TagMode.StartTagAndEndTag; output.AddClass("s-btn"); if (Weight != ButtonWeight.Clear) { output.AddClass("s-btn__" + Weight.ToString().ToLower()); } if (State != ButtonState.Secondary) { output.AddClass("s-btn__" + State.ToString().ToLower()); } if (Branding != ButtonBranding.None) { output.AddClass("s-btn__" + Branding.ToString().ToLower()); } var sizeClass = ""; switch (Size) { case ButtonSize.XSmall: sizeClass = "s-btn__xs"; break; case ButtonSize.Small: sizeClass = "s-btn__sm"; break; case ButtonSize.Medium: sizeClass = "s-btn__md"; break; case ButtonSize.Large: sizeClass = "s-btn__lg"; break; case ButtonSize.XLarge: sizeClass = "s-btn__xl"; break; case ButtonSize.Default: default: break; } output.AddClass(sizeClass); if (Loading) { output.AddClass("is-loading"); } if (Selected) { output.AddClass("is-selected"); } if (Dropdown) { output.AddClass("s-btn__dropdown"); } if (Unset) { output.AddClass("s-btn__unset"); } if (Link) { output.AddClass("s-btn__link"); } }