Esempio n. 1
0
        protected ITypePrivilege CreateTypePrivilegeFromServiceResult(Type entityType, ITypePrivilegeOfService privilegeOfService)
        {
            ITypePropertyPrivilegeOfService[] propertyPrivilegesOfService = privilegeOfService.PropertyPrivileges;

            ITypePropertyPrivilege defaultPropertyPrivilege = TypePropertyPrivilegeImpl.CreateFrom(privilegeOfService);

            if (propertyPrivilegesOfService == null || propertyPrivilegesOfService.Length == 0)
            {
                return(new SimpleTypePrivilegeImpl(privilegeOfService.CreateAllowed, privilegeOfService.ReadAllowed, privilegeOfService.UpdateAllowed,
                                                   privilegeOfService.DeleteAllowed, privilegeOfService.ExecuteAllowed, defaultPropertyPrivilege));
            }
            String[]        propertyPrivilegeNames = privilegeOfService.PropertyPrivilegeNames;
            IEntityMetaData metaData = EntityMetaDataProvider.GetMetaData(entityType);

            ITypePropertyPrivilege[] primitivePropertyPrivileges = new ITypePropertyPrivilege[metaData.PrimitiveMembers.Length];
            ITypePropertyPrivilege[] relationPropertyPrivileges  = new ITypePropertyPrivilege[metaData.RelationMembers.Length];
            for (int a = primitivePropertyPrivileges.Length; a-- > 0;)
            {
                primitivePropertyPrivileges[a] = defaultPropertyPrivilege;
            }
            for (int a = relationPropertyPrivileges.Length; a-- > 0;)
            {
                relationPropertyPrivileges[a] = defaultPropertyPrivilege;
            }
            for (int b = propertyPrivilegesOfService.Length; b-- > 0;)
            {
                ITypePropertyPrivilegeOfService propertyPrivilegeOfService = propertyPrivilegesOfService[b];
                String propertyName = InterningFeature.Intern(propertyPrivilegeNames[b]);
                ITypePropertyPrivilege propertyPrivilege;
                if (propertyPrivilegeOfService != null)
                {
                    propertyPrivilege = TypePropertyPrivilegeImpl.Create(propertyPrivilegeOfService.CreateAllowed, propertyPrivilegeOfService.ReadAllowed,
                                                                         propertyPrivilegeOfService.UpdateAllowed, propertyPrivilegeOfService.DeleteAllowed);
                }
                else
                {
                    propertyPrivilege = TypePropertyPrivilegeImpl.Create(null, null, null, null);
                }
                if (metaData.IsRelationMember(propertyName))
                {
                    relationPropertyPrivileges[metaData.GetIndexByRelationName(propertyName)] = propertyPrivilege;
                }
                if (metaData.IsPrimitiveMember(propertyName))
                {
                    primitivePropertyPrivileges[metaData.GetIndexByPrimitiveName(propertyName)] = propertyPrivilege;
                }
            }
            return(EntityTypePrivilegeFactoryProvider.GetEntityTypePrivilegeFactory(metaData.EntityType, privilegeOfService.CreateAllowed,
                                                                                    privilegeOfService.ReadAllowed, privilegeOfService.UpdateAllowed, privilegeOfService.DeleteAllowed,
                                                                                    privilegeOfService.ExecuteAllowed).CreatePrivilege(privilegeOfService.CreateAllowed, privilegeOfService.ReadAllowed,
                                                                                                                                       privilegeOfService.UpdateAllowed, privilegeOfService.DeleteAllowed, privilegeOfService.ExecuteAllowed, primitivePropertyPrivileges,
                                                                                                                                       relationPropertyPrivileges));
        }
Esempio n. 2
0
 public static ITypePropertyPrivilege CreateFrom(ITypePropertyPrivilegeOfService propertyPrivilegeResult)
 {
     return(Create(propertyPrivilegeResult.CreateAllowed, propertyPrivilegeResult.ReadAllowed, propertyPrivilegeResult.UpdateAllowed,
                   propertyPrivilegeResult.DeleteAllowed));
 }