当前位置: 首页>>代码示例>>C#>>正文


C# EvaluationEngine.Evaluate方法代码示例

本文整理汇总了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 ) );
				}
			}
开发者ID:Condeti,项目名称:XACML.NET,代码行数:25,代码来源:NUnit.2.cs

示例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 ) );
				}
			}
		}
开发者ID:Condeti,项目名称:XACML.NET,代码行数:32,代码来源:MainForm.cs


注:本文中的Xacml.Core.Runtime.EvaluationEngine.Evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。