GetPathList() public method

public GetPathList ( RegistryPermissionAccess access ) : string
access RegistryPermissionAccess
return string
        /// <summary>Creates a permission that is the union of the current permission and the specified permission.</summary>
        /// <returns>A new permission that represents the union of the current permission and the specified permission.</returns>
        /// <param name="other">A permission to combine with the current permission. It must be of the same type as the current permission. </param>
        /// <exception cref="T:System.ArgumentException">The <paramref name="other" /> parameter is not null and is not of the same type as the current permission. </exception>
        public override IPermission Union(IPermission other)
        {
            RegistryPermission registryPermission = this.Cast(other);

            if (registryPermission == null)
            {
                return(this.Copy());
            }
            if (this.IsUnrestricted() || registryPermission.IsUnrestricted())
            {
                return(new RegistryPermission(PermissionState.Unrestricted));
            }
            if (this.IsEmpty() && registryPermission.IsEmpty())
            {
                return(null);
            }
            RegistryPermission registryPermission2 = (RegistryPermission)this.Copy();
            string             pathList            = registryPermission.GetPathList(RegistryPermissionAccess.Create);

            if (pathList != null)
            {
                registryPermission2.AddPathList(RegistryPermissionAccess.Create, pathList);
            }
            pathList = registryPermission.GetPathList(RegistryPermissionAccess.Read);
            if (pathList != null)
            {
                registryPermission2.AddPathList(RegistryPermissionAccess.Read, pathList);
            }
            pathList = registryPermission.GetPathList(RegistryPermissionAccess.Write);
            if (pathList != null)
            {
                registryPermission2.AddPathList(RegistryPermissionAccess.Write, pathList);
            }
            return(registryPermission2);
        }
Esempio n. 2
0
        public override IPermission Union(IPermission other)
        {
            RegistryPermission rp = Cast(other);

            if (rp == null)
            {
                return(Copy());
            }

            if (IsUnrestricted() || rp.IsUnrestricted())
            {
                return(new RegistryPermission(PermissionState.Unrestricted));
            }

            if (IsEmpty() && rp.IsEmpty())
            {
                return(null);
            }

            RegistryPermission result = (RegistryPermission)Copy();
            string             path   = rp.GetPathList(RegistryPermissionAccess.Create);

            if (path != null)
            {
                result.AddPathList(RegistryPermissionAccess.Create, path);
            }
            path = rp.GetPathList(RegistryPermissionAccess.Read);
            if (path != null)
            {
                result.AddPathList(RegistryPermissionAccess.Read, path);
            }
            path = rp.GetPathList(RegistryPermissionAccess.Write);
            if (path != null)
            {
                result.AddPathList(RegistryPermissionAccess.Write, path);
            }
            return(result);
        }
Esempio n. 3
0
		public void FromXml ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
			SecurityElement se = ep.ToXml ();
			Assert.IsNotNull (se, "ToXml()");
			ep.FromXml (se);
			se.AddAttribute ("Read", keyLocalMachine);
			ep.FromXml (se);
			Assert.AreEqual (keyLocalMachine, ep.GetPathList (RegistryPermissionAccess.Read), "FromXml-Read");
			se.AddAttribute ("Write", keyLocalMachine);
			ep.FromXml (se);
			Assert.AreEqual (keyLocalMachine, ep.GetPathList (RegistryPermissionAccess.Read), "FromXml-Read");
			Assert.AreEqual (keyLocalMachine, ep.GetPathList (RegistryPermissionAccess.Write), "FromXml-Write");
			se.AddAttribute ("Create", keyCurrentUser);
			ep.FromXml (se);
			Assert.AreEqual (keyLocalMachine, ep.GetPathList (RegistryPermissionAccess.Read), "FromXml-Read");
			Assert.AreEqual (keyLocalMachine, ep.GetPathList (RegistryPermissionAccess.Write), "FromXml-Write");
			Assert.AreEqual (keyCurrentUser, ep.GetPathList (RegistryPermissionAccess.Create), "FromXml-Create");
		}
Esempio n. 4
0
		public void GetPathList ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
#if NET_2_0
			Assert.AreEqual (String.Empty, ep.GetPathList (RegistryPermissionAccess.Create), "GetPathList-Create-Empty");
			Assert.AreEqual (String.Empty, ep.GetPathList (RegistryPermissionAccess.Read), "GetPathList-Read-Empty");
			Assert.AreEqual (String.Empty, ep.GetPathList (RegistryPermissionAccess.Write), "GetPathList-Write-Empty");
#else
			Assert.IsNull (ep.GetPathList (RegistryPermissionAccess.Create), "GetPathList-Create-Empty");
			Assert.IsNull (ep.GetPathList (RegistryPermissionAccess.Read), "GetPathList-Read-Empty");
			Assert.IsNull (ep.GetPathList (RegistryPermissionAccess.Write), "GetPathList-Write-Empty");
#endif
			ep.AddPathList (RegistryPermissionAccess.Create, keyLocalMachine);
			ep.AddPathList (RegistryPermissionAccess.Create, keyCurrentUser);
			Assert.AreEqual (keyLocalMachine + ";" + keyCurrentUser, ep.GetPathList (RegistryPermissionAccess.Create), "GetPathList-Read");

			ep.AddPathList (RegistryPermissionAccess.Read, keyLocalMachine);
			Assert.AreEqual (keyLocalMachine, ep.GetPathList (RegistryPermissionAccess.Read), "GetPathList-Read");

			ep.AddPathList (RegistryPermissionAccess.Write, keyCurrentUser);
			Assert.AreEqual (keyCurrentUser, ep.GetPathList (RegistryPermissionAccess.Write), "GetPathList-Write");
		}
Esempio n. 5
0
		public void GetPathListNoAccess ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
			ep.AddPathList (RegistryPermissionAccess.Read, keyCurrentUser);
			ep.AddPathList (RegistryPermissionAccess.Write, keyLocalMachine);
			Assert.AreEqual (String.Empty, ep.GetPathList (RegistryPermissionAccess.NoAccess), "GetPathList-NoAccess");
		}
Esempio n. 6
0
		public void GetPathListAllAccess ()
		{
			RegistryPermission ep = new RegistryPermission (PermissionState.None);
			ep.GetPathList (RegistryPermissionAccess.AllAccess);
		}