/// <summary>
		/// Loads the supported card types from the applications configuration file. Allowing
		/// users to add new regular expressions. This populates the <code>_cardTypes</code> member.
		/// </summary>
		private void LoadCardTypes()
		{
			CardTypeCollection ct = (CardTypeCollection) ConfigurationManager.GetSection("Etier.CreditCard");

			if (ct != null)
				_cardTypes = new CardTypeCollection(ct);
		}
Exemple #2
0
 /// <summary>
 /// Adds the elements of another CardTypeCollection to the end of this CardTypeCollection.
 /// </summary>
 /// <param name="items">
 /// The CardTypeCollection whose elements are to be added to the end of this CardTypeCollection.
 /// </param>
 public virtual void AddRange(CardTypeCollection items)
 {
     foreach (CardType item in items)
     {
         List.Add(item);
     }
 }
Exemple #3
0
        protected override void OnInit(EventArgs e)
        {
            if (Site != null)
            {
                if (Site.DesignMode)
                {
                    // In design mode so just add a quick dummy item.
                    Items.Add(new ListItem("CardTypes Here"));
                }
            }
            else
            {
                CardTypeCollection ct = (CardTypeCollection)ConfigurationManager.GetSection("Etier.CreditCard");

                if (ct != null)
                {
                    _cardTypes = new CardTypeCollection(ct);
                }
                else
                {
                    throw new NullReferenceException(
                              "CardTypeListBox requires card types in the web.config in the Etier.CreditCard section.");
                }
            }

            base.OnInit(e);
        }
		private void LimitAcceptedCardTypes()
		{
			CardTypeCollection acceptedTypes = new CardTypeCollection();

			foreach (CardType ct in _cardTypes)
			{
				if (Regex.IsMatch(_acceptedTypes, ".*" + ct.Name + ".*"))
					acceptedTypes.Add(ct);
			}

			_cardTypes = acceptedTypes;
		}
        public object Create(object parent, object configContext, XmlNode section)
        {
            XmlNodeList        cardTypes;
            CardTypeCollection al = new CardTypeCollection();

            cardTypes = section.SelectNodes("cardTypes//cardType");

            foreach (XmlNode cardType in cardTypes)
            {
                String name   = cardType.Attributes.GetNamedItem("name").Value;
                String regExp = cardType.Attributes.GetNamedItem("regExp").Value;

                //Add them to the card types collection
                CardType ct = new CardType(name, regExp);

                al.Add(ct);
            }

            return(al);
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the CardTypeCollection class, containing elements
 /// copied from another instance of CardTypeCollection
 /// </summary>
 /// <param name="items">
 /// The CardTypeCollection whose elements are to be added to the new CardTypeCollection.
 /// </param>
 public CardTypeCollection(CardTypeCollection items)
 {
     AddRange(items);
 }
Exemple #7
0
 public Enumerator(CardTypeCollection collection)
 {
     wrapped = ((CollectionBase)collection).GetEnumerator();
 }