本文整理匯總了C#中Xacml.Core.Runtime.EvaluationEngine.Evaluate方法的典型用法代碼示例。如果您正苦於以下問題:C# EvaluationEngine.Evaluate方法的具體用法?C# EvaluationEngine.Evaluate怎麽用?C# EvaluationEngine.Evaluate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Xacml.Core.Runtime.EvaluationEngine
的用法示例。
在下文中一共展示了EvaluationEngine.Evaluate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: IIA001
public void IIA001 ()
{
string[] files = new string[] { "2.IIA001Policy.xml", "2.IIA001Request.xml", "2.IIA001Response.xml" };
Assert.AreEqual( files.Length, 3, "Test incomplete" );FileInfo policyFile = new FileInfo( files[0] );
FileInfo requestFile = new FileInfo( files[1] );
FileInfo ResponseElementFile = new FileInfo( files[2] );
using( FileStream fs = new FileStream( policyFile.FullName, FileMode.Open, FileAccess.Read ) )
using( FileStream fs1 = new FileStream( requestFile.FullName, FileMode.Open, FileAccess.Read ) )
using( FileStream fs2 = new FileStream( ResponseElementFile.FullName, FileMode.Open, FileAccess.Read ) )
{
// Load Policy
PolicyDocument policyDocument = (PolicyDocument)PolicyLoader.LoadPolicyDocument( fs, XacmlVersion.Version20, DocumentAccess.ReadOnly );
// Load Request
ContextDocumentReadWrite requestDocument = ContextLoader.LoadContextDocument( fs1, XacmlVersion.Version20 );
// Load ResponseElement
ContextDocumentReadWrite ResponseElementDocument = ContextLoader.LoadContextDocument( fs2, XacmlVersion.Version20 );
EvaluationEngine engine = new EvaluationEngine();
ResponseElement res = engine.Evaluate( policyDocument, (ContextDocument)requestDocument );
NUnit.Framework.Assert.AreEqual( ((ResultElement)res.Results[0]).Obligations.Count, ((ResultElement)ResponseElementDocument.Response.Results[0]).Obligations.Count );
NUnit.Framework.Assert.AreEqual( ResponseElementDocument.Response.Results.Count, res.Results.Count );
NUnit.Framework.Assert.IsTrue( ((ResultElement)res.Results[0]).Decision.ToString() == ((ResultElement)ResponseElementDocument.Response.Results[0]).Decision.ToString(), string.Format( "Decission incorrect Expected:{0} Returned:{1}", ((ResultElement)ResponseElementDocument.Response.Results[0]).Decision.ToString(), ((ResultElement)res.Results[0]).Decision.ToString() ) );
NUnit.Framework.Assert.IsTrue( ((ResultElement)res.Results[0]).Status.StatusCode.Value == ((ResultElement)ResponseElementDocument.Response.Results[0]).Status.StatusCode.Value, String.Format( "Status incorrect Expected:{0} Returned:{1}", ((ResultElement)ResponseElementDocument.Response.Results[0]).Status.StatusCode.Value, ((ResultElement)res.Results[0]).Status.StatusCode.Value ) );
}
}
示例2: menuItem8_Click
private void menuItem8_Click(object sender, EventArgs e)
{
if( MessageBox.Show( this,"The policy will be saved. Do you want to proceed?", "Warning", MessageBoxButtons.YesNo ) == DialogResult.Yes )
{
//Loads the request
openFileDialog.Filter = "Request Files|*.xml|All Files|*.*";
if( openFileDialog.ShowDialog() == DialogResult.OK )
{
menuItem9_Click( sender, e );
con.ContextDocumentReadWrite oCon = ContextLoader.LoadContextDocument( openFileDialog.OpenFile(), XacmlVersion.Version11 );
//Gets the policy from the TreeView
Stream stream = new FileStream( _path, FileMode.Open );
pol.PolicyDocumentReadWrite oPol = PolicyLoader.LoadPolicyDocument( stream , XacmlVersion.Version20 );
stream.Close();
//Evaluates the request
EvaluationEngine engine = new EvaluationEngine();
con.ResponseElement res = engine.Evaluate( (pol.PolicyDocument)oPol, (con.ContextDocument)oCon );
//Creates the xml
string path = Path.GetTempFileName();
XmlWriter writer = new XmlTextWriter( path, Encoding.UTF8 );
res.WriteDocument( writer );
writer.Close();
mainPanel.Controls.Clear();
mainPanel.Controls.Add( new XmlViewer( path, ResponseElement.Response ) );
}
}
}