示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XacmlContextStatus"/> class.
        /// </summary>
        /// <param name="statusCode">The status code.</param>
        public XacmlContextStatus(XacmlContextStatusCode statusCode)
        {
            if (statusCode == null)
            {
                throw new ArgumentNullException(nameof(statusCode));
            }

            this.statusCode = statusCode;
        }
        protected virtual void WriteContextStatusCode(XmlWriter writer, XacmlContextStatusCode xacmlContextStatusCode) {
            Contract.Requires<ArgumentNullException>(writer != null);
            Contract.Requires<ArgumentNullException>(xacmlContextStatusCode != null);

            writer.WriteStartElement(XacmlConstants.Prefixes.Context, XacmlConstants.ElementNames.StatusCode, this.version.NamespaceContext);

            writer.WriteAttributeString(XacmlConstants.AttributeNames.Value, xacmlContextStatusCode.Value.ToString());

            if (xacmlContextStatusCode.StatusCode != null) {
                this.WriteContextStatusCode(writer, xacmlContextStatusCode.StatusCode);
            }

            writer.WriteEndElement();
        }
        protected virtual XacmlContextStatusCode ReadContextStatusCode(XmlReader reader) {
            Contract.Requires<ArgumentNullException>(reader != null, "reader");
            Contract.Requires<XmlException>(reader.IsStartElement(XacmlConstants.ElementNames.StatusCode, this.version.NamespaceContext));

            // Read attributes
            Uri statusCode = this.ReadAttribute<Uri>(reader, XacmlConstants.AttributeNames.Value, isRequered: true);

            XacmlContextStatusCode result = new XacmlContextStatusCode(statusCode);
            if (reader.IsEmptyElement) {
                reader.Read();
                return result;
            }

            reader.ReadStartElement(XacmlConstants.ElementNames.StatusCode, this.version.NamespaceContext);
            // Read elements
            result.StatusCode = this.ReadOptional(XacmlConstants.ElementNames.StatusCode, this.version.NamespaceContext, ReadContextStatusCode, reader);

            reader.ReadEndElement();

            return result;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="XacmlContextStatus"/> class.
 /// </summary>
 /// <param name="statusCode">The status code.</param>
 public XacmlContextStatus(XacmlContextStatusCode statusCode) {
     Contract.Requires<ArgumentNullException>(statusCode != null);
     this.statusCode = statusCode;
 }