/// <summary> /// /// </summary> /// <param name="attribute"></param> public Attribute( con.AttributeElementReadWrite attribute ) { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); LoadingData = true; _attribute = attribute; foreach( FieldInfo field in typeof(Consts.Schema1.InternalDataTypes).GetFields() ) { cmbDataType.Items.Add( field.GetValue( null ) ); } this.lstAttributeValue.DisplayMember = "Value"; foreach( con.AttributeValueElementReadWrite attr in _attribute.AttributeValues ) { lstAttributeValue.Items.Add( attr ); } if( _attribute.AttributeValues.Count != 0 ) { lstAttributeValue.SelectedIndex = 0; } txtId.Text = _attribute.AttributeId; txtId.DataBindings.Add( "Text", _attribute, "AttributeId" ); txtIssuer.Text = _attribute.Issuer; //txtIssuer.DataBindings.Add( "Text", _attribute, "Issuer" ); cmbDataType.SelectedIndex = cmbDataType.FindStringExact( _attribute.DataType); cmbDataType.DataBindings.Add( "SelectedItem", _attribute, "DataType" ); LoadingData = false; }
/// <summary> /// /// </summary> /// <param name="request"></param> public Request( con.RequestElementReadWrite request ) { _request = request; this.Text = "Request"; this.SelectedImageIndex = 1; this.ImageIndex = 1; if( _request.Action != null ) { this.Nodes.Add( new Action( _request.Action ) ); } if( _request.Environment != null ) { this.Nodes.Add( new Environment( _request.Environment ) ) ; } if( _request.Resources != null ) { foreach( con.ResourceElementReadWrite resource in _request.Resources ) { this.Nodes.Add( new Resource( resource ) ); } } if( _request.Subjects != null ) { foreach( con.SubjectElementReadWrite subject in _request.Subjects ) { this.Nodes.Add( new Subject( subject ) ); } } this.ExpandAll(); }
/// <summary> /// /// </summary> /// <param name="attribute"></param> public Attribute( con.AttributeElementReadWrite attribute ) { _attribute = attribute; this.Text = "Attribute"; this.SelectedImageIndex = 3; this.ImageIndex = 3; }
/// <summary> /// /// </summary> /// <param name="resource"></param> public Resource( con.ResourceElementReadWrite resource ) { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); _resource = resource; if( _resource.ResourceContent != null ) { txtContent.Text = _resource.ResourceContent.XmlDocument.InnerXml; } }
/// <summary> /// /// </summary> /// <param name="subject"></param> public Subject( con.SubjectElementReadWrite subject ) { _subject = subject; this.Text = "Subject"; this.SelectedImageIndex = 2; this.ImageIndex = 2; foreach( con.AttributeElementReadWrite attr in _subject.Attributes ) { this.Nodes.Add( new Attribute( attr ) ); } }
/// <summary> /// /// </summary> /// <param name="action"></param> public Action( con.ActionElementReadWrite action ) { _action = action; this.Text = "Action"; this.SelectedImageIndex = 2; this.ImageIndex = 2; foreach( con.AttributeElementReadWrite attr in _action.Attributes ) { this.Nodes.Add( new Attribute( attr ) ); } }
/// <summary> /// /// </summary> /// <param name="resource"></param> public Resource( con.ResourceElementReadWrite resource ) { _resource = resource; this.Text = "Resource"; this.SelectedImageIndex = 2; this.ImageIndex = 2; foreach( con.AttributeElementReadWrite attr in _resource.Attributes ) { this.Nodes.Add( new Attribute( attr ) ); } }
/// <summary> /// /// </summary> /// <param name="environment"></param> public Environment( con.EnvironmentElementReadWrite environment ) { _environment = environment; this.Text = "Environment"; this.SelectedImageIndex = 2; this.ImageIndex = 2; foreach( con.AttributeElementReadWrite attr in _environment.Attributes ) { this.Nodes.Add( new Attribute( attr ) ); } }
/// <summary> /// /// </summary> /// <param name="context"></param> public Context( con.ContextDocumentReadWrite context ) { _context = context; this.Text = "Context Document"; this.SelectedImageIndex = 0; this.ImageIndex = 0; if( _context.Request != null ) { this.Nodes.Add( new Request( _context.Request ) ); } this.ExpandAll(); }
/// <summary> /// Evaluates the target items and return wether the target applies to the context or not. /// </summary> /// <param name="context">The evaluation context instance.</param> /// <param name="targetItem">The target item in the context document.</param> /// <returns></returns> public virtual TargetEvaluationValue Evaluate(EvaluationContext context, ctx.TargetItemBase targetItem) { if (context == null) throw new ArgumentNullException("context"); if (_targetItems.IsAny) { context.Trace("IsAny"); return TargetEvaluationValue.Match; } _evaluationValue = TargetEvaluationValue.NoMatch; //Match TargetItem foreach (TargetItemBase polItem in _targetItems.ItemsList) { foreach (TargetMatchBase match in polItem.Match) { _evaluationValue = TargetEvaluationValue.NoMatch; context.Trace("Using function: {0}", match.MatchId); IFunction matchFunction = EvaluationEngine.GetFunction(match.MatchId); if (matchFunction == null) { context.Trace("ERR: function not found {0}", match.MatchId); context.ProcessingError = true; return TargetEvaluationValue.Indeterminate; } else if (matchFunction.Returns == null) { // Validates the function return value context.Trace("ERR: The function '{0}' does not defines it's return value", match.MatchId); context.ProcessingError = true; return TargetEvaluationValue.Indeterminate; } else if (matchFunction.Returns != DataTypeDescriptor.Boolean) { context.Trace("ERR: Function does not return Boolean a value"); context.ProcessingError = true; return TargetEvaluationValue.Indeterminate; } else { Context.AttributeElement attribute = EvaluationEngine.Resolve(context, match, targetItem); if (attribute != null) { context.Trace("Attribute found, evaluating match function"); try { EvaluationValue returnValue = EvaluationEngine.EvaluateFunction(context, matchFunction, match.AttributeValue, attribute); _evaluationValue = returnValue.BoolValue ? TargetEvaluationValue.Match : TargetEvaluationValue.NoMatch; } catch (EvaluationException e) { context.Trace("ERR: {0}", e.Message); _evaluationValue = TargetEvaluationValue.Indeterminate; } } // Validate MustBePresent if (match.AttributeReference.MustBePresent) { if (context.IsMissingAttribute) { context.Trace("Attribute not found and must be present"); _evaluationValue = TargetEvaluationValue.Indeterminate; } } if (context.ProcessingError) { _evaluationValue = TargetEvaluationValue.Indeterminate; } // Do not iterate if the value was found if (_evaluationValue != TargetEvaluationValue.Match) { break; } } } // Do not iterate if the value was found if (_evaluationValue == TargetEvaluationValue.Match) { return _evaluationValue; } } return _evaluationValue; }