/// <summary> /// Writes the Xml of a scope transform. /// </summary> /// <param name="writer">An XmlWriter for the scope transform.</param> public override void WriteXml(XmlWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStartElement(AuthorizationConstants.Elements.Transform, AuthorizationConstants.Namespaces.Xmlns); if (TransformID != null) { writer.WriteAttributeString(AuthorizationConstants.Attributes.TransformId, TransformID.ToString()); } writer.WriteAttributeString(AuthorizationConstants.Attributes.Type, Type.ToString()); if (MatchExpression != null) { MatchExpression.WriteXml(writer); } if (TargetClaim != null) { writer.WriteStartElement(AuthorizationConstants.Elements.TargetClaim, AuthorizationConstants.Namespaces.Xmlns); writer.WriteAttributeString(AuthorizationConstants.Attributes.ClaimType, TargetClaim.ClaimType); if (!string.IsNullOrEmpty(TargetClaim.ClaimValue)) { writer.WriteString(TargetClaim.ClaimValue); } writer.WriteEndElement(); } if (Expression != null) { Expression.WriteXml(writer); } writer.WriteEndElement(); }
/// <summary> /// Writes the Xml of a evaluation rule. /// </summary> /// <param name="writer">An XmlWriter for the evaluation rule.</param> public override void WriteXml(XmlWriter writer) { _ = writer ?? throw new ArgumentNullException(nameof(writer)); writer.WriteStartElement(AuthorizationConstants.Elements.Rule, AuthorizationConstants.Namespaces.Xmlns); if (Issuer != null) { writer.WriteAttributeString(AuthorizationConstants.Attributes.Issuer, Issuer); } if (TermId != null) { writer.WriteAttributeString(AuthorizationConstants.Attributes.TermId, TermId.ToString()); } writer.WriteAttributeString(AuthorizationConstants.Attributes.Evaluates, XmlConvert.ToString(Evaluates)); Operation.WriteXml(writer); MatchExpression.WriteXml(writer); writer.WriteEndElement(); }