Exemple #1
0
        /// <summary>
        /// Gets or creates a <see cref="Permission"/> instance for the named role
        /// on the collection.
        /// </summary>
        /// <remarks>
        /// This function should be used in preference to manually querying for the
        /// applicable Permission as it ensures that there is exactly one Permission for
        /// the given Role on the object, merging duplicates or creating and adding new ones
        /// as needed.
        /// </remarks>
        /// <param name="roleName">
        /// The name of the <see cref="PermissionRole"/> associated with that Permission. If no such
        /// Role exists, it will be created automatically.
        /// </param>
        /// <param name="permissions">
        /// The collection of permissions to which the new instance will be added.
        /// </param>
        /// <returns>
        /// A <see cref="Permission"/> instance that can be used to inspect or modify the object
        /// permissions of that <see cref="PermissionRole"/>.
        /// </returns>
        public static Permission Get(string roleName, IList <Permission> permissions)
        {
#if PCL
            RealmPCLHelpers.ThrowProxyShouldNeverBeUsed();
            return(null);
#else
            if (!(permissions is RealmList <Permission> realmPermissions))
            {
                throw new ArgumentException($"{nameof(Get)} may only be called on managed lists.", nameof(permissions));
            }

            var role = PermissionRole.Get(realmPermissions.Realm, roleName);
            return(Get(role, permissions));
#endif
        }
Exemple #2
0
 /// <summary>
 /// Gets or creates a <see cref="Permission"/> instance for the named role
 /// on the object.
 /// </summary>
 /// <remarks>
 /// This function should be used in preference to manually querying for the
 /// applicable Permission as it ensures that there is exactly one Permission for
 /// the given Role on the object, merging duplicates or creating and adding new ones
 /// as needed.
 /// <para/>
 /// The given object must have a <c>IList&lt;Permission&gt;</c> property defined on it.
 /// If more than one such property exists, the first one will be used.
 /// </remarks>
 /// <param name="roleName">
 /// The name of the <see cref="PermissionRole"/> associated with that Permission. If no such
 /// Role exists, it will be created automatically.
 /// </param>
 /// <param name="obj">
 /// The <see cref="RealmObject"/> inheritor whose permissions this
 /// <see cref="Permission"/> instance manipulates.
 /// </param>
 /// <returns>
 /// A <see cref="Permission"/> instance that can be used to inspect or modify the object
 /// permissions of that <see cref="PermissionRole"/>.
 /// </returns>
 public static Permission Get(string roleName, RealmObject obj)
 {
     return(Get(PermissionRole.Get(obj.Realm, roleName), obj));
 }
Exemple #3
0
 /// <summary>
 /// Gets or creates a <see cref="Permission"/> instance for the named role
 /// on the class.
 /// </summary>
 /// <remarks>
 /// This function should be used in preference to manually querying for the
 /// applicable Permission as it ensures that there is exactly one Permission for
 /// the given Role on the class, merging duplicates or creating and adding new ones
 /// as needed.
 /// </remarks>
 /// <param name="roleName">
 /// The name of the <see cref="PermissionRole"/> associated with that Permission. If no such
 /// Role exists, it will be created automatically.
 /// </param>
 /// <param name="className">
 /// The  name of the <see cref="RealmObject"/> subclass whose corresponding class permissions this
 /// <see cref="Permission"/> instance manipulates.
 /// </param>
 /// <param name="realm">The Realm whose class permissions this <see cref="Permission"/> instance manipulates.</param>
 /// <returns>
 /// A <see cref="Permission"/> instance that can be used to inspect or modify the class
 /// permissions of that <see cref="PermissionRole"/>.
 /// </returns>
 public static Permission Get(string roleName, string className, Realm realm)
 {
     return(Get(PermissionRole.Get(realm, roleName), ClassPermission.Get(realm, className).Permissions));
 }
Exemple #4
0
 /// <summary>
 /// Gets or creates a <see cref="Permission"/> instance for the named role
 /// on the class.
 /// </summary>
 /// <remarks>
 /// This function should be used in preference to manually querying for the
 /// applicable Permission as it ensures that there is exactly one Permission for
 /// the given Role on the class, merging duplicates or creating and adding new ones
 /// as needed.
 /// </remarks>
 /// <typeparam name="T">
 /// The <see cref="RealmObject"/> subclass whose corresponding class permissions this
 /// <see cref="Permission"/> instance manipulates.
 /// </typeparam>
 /// <param name="roleName">
 /// The name of the <see cref="PermissionRole"/> associated with that Permission. If no such
 /// Role exists, it will be created automatically.
 /// </param>
 /// <param name="realm">The Realm whose class permissions this <see cref="Permission"/> instance manipulates.</param>
 /// <returns>
 /// A <see cref="Permission"/> instance that can be used to inspect or modify the class
 /// permissions of that <see cref="PermissionRole"/>.
 /// </returns>
 public static Permission Get <T>(string roleName, Realm realm) where T : RealmObject
 {
     return(Get(PermissionRole.Get(realm, roleName), ClassPermission.Get <T>(realm).Permissions));
 }
Exemple #5
0
 /// <summary>
 /// Gets or creates a <see cref="Permission"/> instance for the named role
 /// on the Realm.
 /// </summary>
 /// <remarks>
 /// This function should be used in preference to manually querying for the
 /// applicable Permission as it ensures that there is exactly one Permission for
 /// the given Role on the Realm, merging duplicates or creating and adding new ones
 /// as needed.
 /// </remarks>
 /// <param name="roleName">
 /// The name of the <see cref="PermissionRole"/> associated with that Permission. If no such
 /// Role exists, it will be created automatically.
 /// </param>
 /// <param name="realm">The Realm whose permissions this <see cref="Permission"/> instance manipulates.</param>
 /// <returns>
 /// A <see cref="Permission"/> instance that can be used to inspect or modify the Realm
 /// permissions of that <see cref="PermissionRole"/>.
 /// </returns>
 public static Permission Get(string roleName, Realm realm)
 {
     return(Get(PermissionRole.Get(realm, roleName), realm));
 }
Exemple #6
0
 /// <summary>
 /// Gets or creates a <see cref="Permission"/> instance for the named role
 /// on the object.
 /// </summary>
 /// <remarks>
 /// This function should be used in preference to manually querying for the
 /// applicable Permission as it ensures that there is exactly one Permission for
 /// the given Role on the object, merging duplicates or creating and adding new ones
 /// as needed.
 /// <para/>
 /// The given object must have a <c>IList&lt;Permission&gt;</c> property defined on it.
 /// If more than one such property exists, the first one will be used.
 /// </remarks>
 /// <param name="roleName">
 /// The name of the <see cref="PermissionRole"/> associated with that Permission. If no such
 /// Role exists, it will be created automatically.
 /// </param>
 /// <param name="obj">
 /// The <see cref="RealmObject"/> inheritor whose permissions this
 /// <see cref="Permission"/> instance manipulates.
 /// </param>
 /// <returns>
 /// A <see cref="Permission"/> instance that can be used to inspect or modify the object
 /// permissions of that <see cref="PermissionRole"/>.
 /// </returns>
 public static Permission Get(string roleName, RealmObject obj)
 {
     Argument.NotNull(obj, nameof(obj));
     return(Get(PermissionRole.Get(obj.Realm, roleName), obj));
 }