// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003, Ximian Inc.
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
+#if !MOONLIGHT
+
using System.Collections;
using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Security.Policy {
[Serializable]
- public sealed class ZoneMembershipCondition
- : IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable, IConstantMembershipCondition
- {
- SecurityZone zone;
+ [ComVisible (true)]
+ public sealed class ZoneMembershipCondition : IMembershipCondition, IConstantMembershipCondition {
+
+ private readonly int version = 1;
+
+ private SecurityZone zone;
// so System.Activator.CreateInstance can create an instance...
internal ZoneMembershipCondition ()
return new ZoneMembershipCondition (zone);
}
- public override bool Equals (Object o)
- {
- if (o is ZoneMembershipCondition == false)
- return false;
- else
- return ((ZoneMembershipCondition) o).SecurityZone == zone;
- }
+ public override bool Equals (object o)
+ {
+ ZoneMembershipCondition zmc = (o as ZoneMembershipCondition);
+ if (zmc == null)
+ return false;
+ return (zmc.SecurityZone == zone);
+ }
- public void FromXml (SecurityElement element)
+ public void FromXml (SecurityElement e)
{
- FromXml (element, null);
+ FromXml (e, null);
}
- public void FromXml (SecurityElement element, PolicyLevel level)
- {
- if (element == null)
- throw new ArgumentException ("element");
-
- if (element.Attribute ("version") != "1")
- throw new ArgumentException (
- Locale.GetText ("The argument is invalid."));
+ public void FromXml (SecurityElement e, PolicyLevel level)
+ {
+ MembershipConditionHelper.CheckSecurityElement (e, "e", version, version);
- zone = (SecurityZone) Enum.Parse (
- typeof (SecurityZone), element.Attribute ("Zone"));
- }
+ string z = e.Attribute ("Zone");
+ if (z != null) {
+ zone = (SecurityZone) Enum.Parse (typeof (SecurityZone), z);
+ }
+ }
public override int GetHashCode ()
{
public SecurityElement ToXml (PolicyLevel level)
{
- SecurityElement element = new SecurityElement ("IMembershipCondition");
- element.AddAttribute ("version", "1");
-
- element.AddAttribute ("Zone", zone.ToString ());
-
- return element;
+ // PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
+ SecurityElement se = MembershipConditionHelper.Element (typeof (ZoneMembershipCondition), version);
+ se.AddAttribute ("Zone", zone.ToString ());
+ return se;
}
}
}
+
+#endif
+