Skip to content

Commit

Permalink
[asp.net] Part of fix for bug #579837. AuthorizationRule.SerializeEle…
Browse files Browse the repository at this point in the history
…ment will not process unmodified elements.

* AuthorizationRule.cs: if the configuration save is not Full, SerializeElement checks whether the rule being
  serialized is modified. If it isn't, validation and serialization are not performed.
* AuthorizationRuleCollection.cs: there is no element name for the collection.
  • Loading branch information
grendello committed Oct 4, 2010
1 parent f941c9b commit 88e76d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -49,7 +49,8 @@ public sealed class AuthorizationRule : ConfigurationElement
static ConfigurationPropertyCollection properties;

AuthorizationRuleAction action;

ConfigurationSaveMode saveMode = ConfigurationSaveMode.Full;

static AuthorizationRule ()
{
rolesProp = new ConfigurationProperty ("roles", typeof (StringCollection), null,
Expand Down Expand Up @@ -130,7 +131,10 @@ public override int GetHashCode ()
[MonoTODO ("Not implemented")]
protected override bool IsModified ()
{
throw new NotImplementedException ();
if (((CommaDelimitedStringCollection)Roles).IsModified || ((CommaDelimitedStringCollection)Users).IsModified || ((CommaDelimitedStringCollection)Verbs).IsModified)
return true;

return false;
}

void VerifyData ()
Expand Down Expand Up @@ -168,6 +172,9 @@ protected override void ResetModified ()

protected override bool SerializeElement (XmlWriter writer, bool serializeCollectionKey)
{
if (saveMode != ConfigurationSaveMode.Full && !IsModified ())
return true;

PreSerialize (writer);

writer.WriteStartElement (action == AuthorizationRuleAction.Allow ? "allow" : "deny");
Expand All @@ -191,6 +198,7 @@ protected override void SetReadOnly ()
protected override void Unmerge (ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
{
base.Unmerge (sourceElement, parentElement, saveMode);
this.saveMode = saveMode;
}

public AuthorizationRuleAction Action {
Expand Down
Expand Up @@ -108,9 +108,8 @@ public void Set (int index, AuthorizationRule rule)
get { return ConfigurationElementCollectionType.BasicMapAlternate; }
}

[MonoTODO ("is it okay to return a comma delimited string here?")]
protected override string ElementName {
get { return "allow,deny"; }
get { return String.Empty; }
}

public AuthorizationRule this [int index] {
Expand Down

0 comments on commit 88e76d8

Please sign in to comment.