ToXml() public method

public ToXml ( ) : SecurityElement
return SecurityElement
		public void PermissionStateNone ()
		{
			GacIdentityPermission gip = new GacIdentityPermission (PermissionState.None);

			SecurityElement se = gip.ToXml ();
			// only class and version are present
			Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes");
			Assert.IsNull (se.Children, "Xml-Children");

			GacIdentityPermission copy = (GacIdentityPermission)gip.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (gip, copy), "ReferenceEquals");
		}
		public void PermissionStateUnrestricted ()
		{
			GacIdentityPermission gip = new GacIdentityPermission (PermissionState.Unrestricted);

			// FX 2.0 now supports Unrestricted for Identity Permissions
			// However the XML doesn't show the Unrestricted status...

			SecurityElement se = gip.ToXml ();
			// only class and version are present
			Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes");
			Assert.IsNull (se.Children, "Xml-Children");

			GacIdentityPermission copy = (GacIdentityPermission)gip.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (gip, copy), "ReferenceEquals");

			// ... and because it doesn't implement IUnrestrictedPermission
			// there is not way to know if it's unrestricted so...
			Assert.IsTrue (gip.Equals (new GacIdentityPermission (PermissionState.None)), "Unrestricted==None");
			// there is not much difference after all ;-)
		}
		public void FromXml_NoVersion ()
		{
			GacIdentityPermission gip = new GacIdentityPermission ();
			SecurityElement se = gip.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", se.Attribute ("class"));
			gip.FromXml (w);
		}
		public void FromXml_WrongVersion ()
		{
			GacIdentityPermission gip = new GacIdentityPermission ();
			SecurityElement se = gip.ToXml ();
			se.Attributes.Remove ("version");
			se.Attributes.Add ("version", "2");
			gip.FromXml (se);
		}
		public void FromXml_NoClass ()
		{
			GacIdentityPermission gip = new GacIdentityPermission ();
			SecurityElement se = gip.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("version", se.Attribute ("version"));
			gip.FromXml (w);
			// doesn't even care of the class attribute presence
		}
		public void FromXml_WrongClass ()
		{
			GacIdentityPermission gip = new GacIdentityPermission ();
			SecurityElement se = gip.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", "Wrong" + se.Attribute ("class"));
			w.AddAttribute ("version", se.Attribute ("version"));
			gip.FromXml (w);
			// doesn't care of the class name at that stage
			// anyway the class has already be created so...
		}
		public void FromXml_WrongTagCase ()
		{
			GacIdentityPermission gip = new GacIdentityPermission ();
			SecurityElement se = gip.ToXml ();
			se.Tag = "IPERMISSION"; // instead of IPermission
			gip.FromXml (se);
		}
		public void FromXml_WrongTag ()
		{
			GacIdentityPermission gip = new GacIdentityPermission ();
			SecurityElement se = gip.ToXml ();
			se.Tag = "IMono";
			gip.FromXml (se);
		}