/// <summary>用指定的标记和文本初始化 <see cref="T:System.Security.SecurityElement" /> 类的新实例。</summary> /// <param name="tag">XML 元素的标记名称。</param> /// <param name="text">元素中的文本内容。</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="tag" /> 参数为 null。</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="tag" /> 参数或 <paramref name="text" /> 参数在 XML 中无效。</exception> public SecurityElement(string tag, string text) { if (tag == null) { throw new ArgumentNullException("tag"); } if (!SecurityElement.IsValidTag(tag)) { throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidElementTag"), (object)tag)); } if (text != null && !SecurityElement.IsValidText(text)) { throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidElementText"), (object)text)); } this.m_strTag = tag; this.m_strText = text; }
/// <summary>Initializes a new instance of the <see cref="T:System.Security.SecurityElement" /> class with the specified tag and text.</summary> /// <param name="tag">The tag name of the XML element. </param> /// <param name="text">The text content within the element. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="tag" /> parameter is null. </exception> /// <exception cref="T:System.ArgumentException">The <paramref name="tag" /> parameter or <paramref name="text" /> parameter is invalid in XML. </exception> public SecurityElement(string tag, string text) { if (tag == null) { throw new ArgumentNullException("tag"); } if (!SecurityElement.IsValidTag(tag)) { throw new ArgumentException(string.Format("Argument_InvalidElementTag", new object[] { tag })); } if (text != null && !SecurityElement.IsValidText(text)) { throw new ArgumentException(string.Format("Argument_InvalidElementText", new object[] { text })); } this.m_strTag = tag; this.m_strText = text; }