namespace System.Web.Configuration {
- [ConfigurationCollection (typeof (AuthorizationRule), AddItemName="add,deny", CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)]
+ [ConfigurationCollection (typeof (AuthorizationRule), AddItemName="allow,deny", CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)]
public sealed class AuthorizationRuleCollection : ConfigurationElementCollection
{
static ConfigurationPropertyCollection properties;
public void Add (AuthorizationRule rule)
{
- BaseAdd (rule);
+ BaseAdd (rule, false);
}
public void Clear ()
BaseClear ();
}
- [MonoTODO]
protected override ConfigurationElement CreateNewElement (string elementName)
{
- return new AuthorizationRule (AuthorizationRuleAction.Allow);
+ return new AuthorizationRule (elementName == "allow" ? AuthorizationRuleAction.Allow : AuthorizationRuleAction.Deny);
}
- [MonoTODO]
protected override ConfigurationElement CreateNewElement ()
{
return new AuthorizationRule (AuthorizationRuleAction.Allow);
return (AuthorizationRule) BaseGet (index);
}
- [MonoTODO]
protected override object GetElementKey (ConfigurationElement element)
{
- throw new NotImplementedException ();
+ AuthorizationRule rule = (AuthorizationRule)element;
+
+ return rule.Action.ToString();
}
- [MonoTODO]
public int IndexOf (AuthorizationRule rule)
{
- throw new NotImplementedException ();
+ return BaseIndexOf (rule);
}
- [MonoTODO]
protected override bool IsElementName (string elementname)
{
- throw new NotImplementedException ();
+ return (elementname == "allow" || elementname == "deny");
}
public void Remove (AuthorizationRule rule)
{
- BaseRemove (rule);
+ BaseRemove (rule.Action.ToString());
}
public void RemoveAt (int index)
BaseRemoveAt (index);
}
- [MonoTODO]
public void Set (int index, AuthorizationRule rule)
{
- throw new NotImplementedException ();
+ if (BaseGet(index) != null)
+ BaseRemoveAt(index);
+ BaseAdd(index, rule);
}
- protected override ConfigurationElementCollectionType CollectionType {
+ public override ConfigurationElementCollectionType CollectionType {
get { return ConfigurationElementCollectionType.BasicMapAlternate; }
}
- [MonoTODO]
+ [MonoTODO ("is it okay to return a comma delimited string here?")]
protected override string ElementName {
- get { throw new NotImplementedException (); }
+ get { return "allow,deny"; }
}
- [MonoTODO]
public AuthorizationRule this [int index] {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return Get (index); }
+ set { Set (index, value); }
}
protected override ConfigurationPropertyCollection Properties {
get { return properties; }
}
-
}
}