Exemplo n.º 1
0
 /// <summary>
 /// Creates a response using the XmlReader instance provided.
 /// </summary>
 /// <remarks>This method is only provided for testing purposes, because it's easy to run the ConformanceTests
 /// comparing the expected response with the response created.</remarks>
 /// <param name="reader">The XmlReader positioned at the Response node.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public ResponseElement(XmlReader reader, XacmlVersion schemaVersion)
     : base(XacmlSchema.Context, schemaVersion)
 {
     if (reader == null) throw new ArgumentNullException("reader");
     _results = new ResultCollection();
     if (reader.LocalName == Consts.ContextSchema.ResponseElement.Response)
     {
         while (reader.Read())
         {
             switch (reader.LocalName)
             {
                 case Consts.ContextSchema.ResultElement.Result:
                     _results.Add(new ResultElement(reader, schemaVersion));
                     break;
             }
             if (reader.LocalName == Consts.ContextSchema.ResponseElement.Response &&
                 reader.NodeType == XmlNodeType.EndElement)
             {
                 break;
             }
         }
     }
     else
     {
         throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new Response using the Result list provided.
 /// </summary>
 /// <param name="results">The list of Results that will be contained in this Response.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public ResponseElement(IEnumerable<ResultElement> results, XacmlVersion schemaVersion)
     : base(XacmlSchema.Context, schemaVersion)
 {
     _results = new ResultCollection();
     if (results != null)
     {
         foreach (var result in results)
         {
             _results.Add(result);
         }
     }
 }