コード例 #1
0
 /// <summary>
 /// Creates a TargetMatchCollection, with the items contained in a ReadWriteTargetMatchCollection
 /// </summary>
 /// <param name="items"></param>
 public TargetMatchCollection(TargetMatchReadWriteCollection items)
 {
     if (items == null)
     {
         throw new ArgumentNullException("items");
     }
     foreach (TargetMatchBaseReadWrite item in items)
     {
         SubjectMatchElementReadWrite     sItem = item as SubjectMatchElementReadWrite;
         ActionMatchElementReadWrite      aItem = item as ActionMatchElementReadWrite;
         ResourceMatchElementReadWrite    rItem = item as ResourceMatchElementReadWrite;
         EnvironmentMatchElementReadWrite eItem = item as EnvironmentMatchElementReadWrite;
         if (sItem != null)
         {
             this.List.Add(new SubjectMatchElement(sItem.MatchId, sItem.AttributeValue, sItem.AttributeReference, sItem.SchemaVersion));
         }
         else if (aItem != null)
         {
             this.List.Add(new ActionMatchElement(aItem.MatchId, aItem.AttributeValue, aItem.AttributeReference, aItem.SchemaVersion));
         }
         else if (rItem != null)
         {
             this.List.Add(new ResourceMatchElement(rItem.MatchId, rItem.AttributeValue, rItem.AttributeReference, rItem.SchemaVersion));
         }
         else if (eItem != null)
         {
             this.List.Add(new EnvironmentMatchElement(eItem.MatchId, eItem.AttributeValue, eItem.AttributeReference, eItem.SchemaVersion));
         }
     }
 }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            pol.TargetMatchBaseReadWrite targetMatch = null;

            if (_targetItem is pol.ActionElementReadWrite)
            {
                targetMatch = new pol.ActionMatchElementReadWrite(
                    InternalFunctions.StringEqual,
                    new pol.AttributeValueElementReadWrite(InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11),                        //TODO: check version
                    new pol.ActionAttributeDesignatorElement(InternalDataTypes.XsdString, false, "", "", XacmlVersion.Version11),                   //TODO: check version
                    XacmlVersion.Version11);
            }
            else if (_targetItem is pol.EnvironmentElementReadWrite)
            {
                targetMatch = new pol.EnvironmentMatchElementReadWrite(
                    InternalFunctions.StringEqual,
                    new pol.AttributeValueElementReadWrite(InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11),                        //TODO: check version
                    new pol.EnvironmentAttributeDesignatorElement(InternalDataTypes.XsdString, false, "", "", XacmlVersion.Version11),              //TODO: check version
                    XacmlVersion.Version11);
            }
            else if (_targetItem is pol.ResourceElementReadWrite)
            {
                targetMatch = new pol.ResourceMatchElementReadWrite(
                    InternalFunctions.StringEqual,
                    new pol.AttributeValueElementReadWrite(InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11),                        //TODO: check version
                    new pol.ResourceAttributeDesignatorElement(InternalDataTypes.XsdString, false, "", "", XacmlVersion.Version11),                 //TODO: check version
                    XacmlVersion.Version11);
            }
            else if (_targetItem is pol.SubjectElementReadWrite)
            {
                targetMatch = new pol.SubjectMatchElementReadWrite(
                    InternalFunctions.StringEqual,
                    new pol.AttributeValueElementReadWrite(InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11),                        //TODO: check version
                    new pol.SubjectAttributeDesignatorElement(InternalDataTypes.XsdString, false, "", "", "", XacmlVersion.Version11),              //TODO: check version
                    XacmlVersion.Version11);
            }

            _targetItem.Match.Add(targetMatch);               //TODO: check version

            try
            {
                LoadingData = true;
                Match matchControl = new Match(_targetItem, targetMatch, lstMatch.Items.Count);
                _list[lstMatch.Items.Count] = matchControl;
            }
            finally
            {
                LoadingData = false;
            }

            index = -1;
            lstMatch.Items.Clear();
            foreach (pol.TargetMatchBaseReadWrite match in _targetItem.Match)
            {
                lstMatch.Items.Add(match);
            }
        }
コード例 #3
0
ファイル: TargetItem.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnAdd_Click(object sender, EventArgs e)
		{
			pol.TargetMatchBaseReadWrite targetMatch = null;

			if( _targetItem is pol.ActionElementReadWrite )
				targetMatch = new pol.ActionMatchElementReadWrite( 
					InternalFunctions.StringEqual, 
					new pol.AttributeValueElementReadWrite( InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11 ),  //TODO: check version
					new pol.ActionAttributeDesignatorElement( InternalDataTypes.XsdString, false, "", "", XacmlVersion.Version11 ),  //TODO: check version
					XacmlVersion.Version11 ) ;
			else if( _targetItem is pol.EnvironmentElementReadWrite )
				targetMatch = new pol.EnvironmentMatchElementReadWrite( 
					InternalFunctions.StringEqual, 
					new pol.AttributeValueElementReadWrite( InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11 ),  //TODO: check version
					new pol.EnvironmentAttributeDesignatorElement( InternalDataTypes.XsdString, false, "", "", XacmlVersion.Version11 ),  //TODO: check version
					XacmlVersion.Version11 ) ;
			else if( _targetItem is pol.ResourceElementReadWrite )
				targetMatch = new pol.ResourceMatchElementReadWrite( 
					InternalFunctions.StringEqual, 
					new pol.AttributeValueElementReadWrite( InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11 ),  //TODO: check version
					new pol.ResourceAttributeDesignatorElement( InternalDataTypes.XsdString, false, "", "", XacmlVersion.Version11 ),  //TODO: check version
					XacmlVersion.Version11 ) ;
			else if( _targetItem is pol.SubjectElementReadWrite )
				targetMatch = new pol.SubjectMatchElementReadWrite( 
					InternalFunctions.StringEqual, 
					new pol.AttributeValueElementReadWrite( InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11 ),  //TODO: check version
					new pol.SubjectAttributeDesignatorElement( InternalDataTypes.XsdString, false, "", "", "", XacmlVersion.Version11 ),  //TODO: check version
					XacmlVersion.Version11 ) ;

			_targetItem.Match.Add( targetMatch ); //TODO: check version

			try
			{
				LoadingData = true;
				Match matchControl = new Match( _targetItem, targetMatch,lstMatch.Items.Count );
				_list[ lstMatch.Items.Count ] = matchControl;
			}
			finally
			{
				LoadingData = false;
			}

			index = -1;
			lstMatch.Items.Clear();
			foreach( pol.TargetMatchBaseReadWrite match in _targetItem.Match )
			{
				lstMatch.Items.Add( match );
			}
		}