Exemplo n.º 1
0
        /// <exclude />
        public override int GetHashCode()
        {
            int hashCode = this._providerName.GetHashCode() ^ _entityToken.GetHashCode();

            foreach (KeyValuePair <string, string> kvp in this.Piggyback)
            {
                hashCode ^= kvp.Key.GetHashCode();
                hashCode ^= kvp.Value.GetHashCode();
            }

            return(hashCode);
        }
Exemplo n.º 2
0
    private void PrettyPrintEntityToken(EntityToken entityToken, string color)
    {
        var idList = new List <object>();

        if (entityToken.Id.Contains("="))
        {
            Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(entityToken.Id);

            idList.Add(new XElement("br"));

            foreach (KeyValuePair <string, string> kvp in dic)
            {
                idList.Add(new XElement("span", new XAttribute("style", "padding-left: 15px; color: " + color),
                                        string.Format("{0} = {1}", kvp.Key, kvp.Value)));
                idList.Add(new XElement("br"));
            }
        }
        else
        {
            idList.Add(entityToken.Id);
        }


        var userPermissionsDefinedHere  = new List <object>();
        var currentUsersPermissionTypes = new List <object>();

        string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

        var usernames = UserValidationFacade.AllUsernames.OrderBy(u => u).ToList();

        foreach (string username in usernames)
        {
            IEnumerable <PermissionType> userPermissionTypes = PermissionTypeFacade.GetLocallyDefinedUserPermissionTypes(
                new UserToken(username), entityToken);

            AddPersissionsLine(userPermissionsDefinedHere, username, userPermissionTypes);

            var currentPermissionTypes = PermissionTypeFacade.GetCurrentPermissionTypes(
                new UserToken(username), entityToken,
                PermissionTypeFacade.GetUserPermissionDefinitions(username),
                PermissionTypeFacade.GetUserGroupPermissionDefinitions(username));

            AddPersissionsLine(currentUsersPermissionTypes, username, currentPermissionTypes);
        }


        var userGroupPermissionsDefinedHere = new List <object>();
        var inheritedGroupPermissions       = new List <object>();

        var userGroups = DataFacade.GetData <IUserGroup>().OrderBy(ug => ug.Name).ToList();

        foreach (IUserGroup userGroup in userGroups)
        {
            var userGroupPermissionTypes = PermissionTypeFacade.GetLocallyDefinedUserGroupPermissionTypes(userGroup.Id, entityToken);

            AddPersissionsLine(userGroupPermissionsDefinedHere, userGroup.Name, userGroupPermissionTypes);

            IEnumerable <PermissionType> inheritedUserGroupPermissionTypes = PermissionTypeFacade.GetInheritedGroupPermissionsTypes(userGroup.Id, entityToken);

            AddPersissionsLine(inheritedGroupPermissions, userGroup.Name, inheritedUserGroupPermissionTypes);
        }



        var element =
            new XElement("div",
                         new XAttribute("style",
                                        string.Format(
                                            "border:2px; border-style: solid; border-color: {0}; margin-bottom: 2px; margin-left:5px; margin-right:5px; padding: 3px;",
                                            color)),
                         new XElement("b", "Runtime type: "),
                         entityToken.GetType().ToString(),
                         new XElement("br"),
                         new XElement("b", "Hashcode: "),
                         entityToken.GetHashCode().ToString(),
                         new XElement("br"),
                         new XElement("b", "Source: "),
                         entityToken.Source,
                         new XElement("br"),
                         new XElement("b", "Type: "),
                         entityToken.Type,
                         new XElement("br"),
                         new XElement("b", "Id: "),
                         idList,
                         new XElement("br"),
                         new XElement("b", "Serialized entity token: "),
                         serializedEntityToken,
                         new XElement("br"),
                         new XElement("br"));


        if (currentUsersPermissionTypes.Any())
        {
            element.Add(
                new XElement("b", "Resolved users permissions here: "),
                new XElement("br"),
                currentUsersPermissionTypes,
                new XElement("br"));
        }


        if (userPermissionsDefinedHere.Any())
        {
            element.Add(
                new XElement("b", "Users permissions defined here: "),
                new XElement("br"),
                userPermissionsDefinedHere,
                new XElement("br"));
        }

        if (inheritedGroupPermissions.Any())
        {
            element.Add(
                new XElement("b", "Inherted user group permissions: "),
                new XElement("br"),
                inheritedGroupPermissions,
                new XElement("br"));
        }

        if (userGroupPermissionsDefinedHere.Any())
        {
            element.Add(
                new XElement("b", "User group permissions defined here: "),
                new XElement("br"),
                userGroupPermissionsDefinedHere,
                new XElement("br"));
        }


        RelationshipGraphHolder.Controls.Add(new LiteralControl(element.ToString()));
    }
    private void PrettyPrintEntityToken(EntityToken entityToken, string color)
    {
        List <object> idList = new List <object>();

        if (entityToken.Id.Contains("=") == true)
        {
            Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(entityToken.Id);

            idList.Add(new XElement("br"));

            foreach (KeyValuePair <string, string> kvp in dic)
            {
                idList.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"),
                                        string.Format("{0} = {1}", kvp.Key, kvp.Value)));
                idList.Add(new XElement("br"));
            }
        }
        else
        {
            idList.Add(entityToken.Id);
        }



        List <object> usersermisstionsDefinedHere  = new List <object>();
        List <object> currentUsersPermisstionTypes = new List <object>();

        string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

        IEnumerable <string> usernames = UserValidationFacade.AllUsernames;

        foreach (string username in usernames)
        {
            IEnumerable <PermissionType> userPermissionTypes = PermissionTypeFacade.GetLocallyDefinedUserPermissionTypes(new UserToken(username), entityToken);

            StringBuilder sb = new StringBuilder();
            foreach (PermissionType permissionType in userPermissionTypes)
            {
                if (sb.ToString() != "")
                {
                    sb.Append(", ");
                }

                sb.Append(new PermissionDescriptor(permissionType).Label);
            }

            usersermisstionsDefinedHere.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", username, sb.ToString())));
            usersermisstionsDefinedHere.Add(new XElement("br"));



            IEnumerable <PermissionType> currentPermissionTypes = PermissionTypeFacade.GetCurrentPermissionTypes(new UserToken(username), entityToken, PermissionTypeFacade.GetUserPermissionDefinitions(username), PermissionTypeFacade.GetUserGroupPermissionDefinitions(username));


            StringBuilder currentSb = new StringBuilder();
            foreach (PermissionType permissionType in currentPermissionTypes)
            {
                if (currentSb.ToString() != "")
                {
                    currentSb.Append(", ");
                }

                currentSb.Append(new PermissionDescriptor(permissionType).Label);
            }

            currentUsersPermisstionTypes.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", username, currentSb.ToString())));
            currentUsersPermisstionTypes.Add(new XElement("br"));
        }


        List <object> userGroupPermissionsDefinedHere = new List <object>();
        List <object> inheritedGroupPermissions       = new List <object>();

        List <IUserGroup> userGroups = DataFacade.GetData <IUserGroup>().ToList();

        foreach (IUserGroup userGroup in userGroups)
        {
            IEnumerable <PermissionType> userGroupPermissionTypes = PermissionTypeFacade.GetLocallyDefinedUserGroupPermissionTypes(userGroup.Id, entityToken);

            StringBuilder sb = new StringBuilder();
            foreach (PermissionType permissionType in userGroupPermissionTypes)
            {
                if (sb.ToString() != "")
                {
                    sb.Append(", ");
                }

                sb.Append(new PermissionDescriptor(permissionType).Label);
            }

            userGroupPermissionsDefinedHere.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", userGroup.Name, sb.ToString())));
            userGroupPermissionsDefinedHere.Add(new XElement("br"));


            IEnumerable <PermissionType> inheritedUserGroupPermissionTypes = PermissionTypeFacade.GetInheritedGroupPermissionsTypes(userGroup.Id, entityToken);
            sb = new StringBuilder();
            foreach (PermissionType permissionType in inheritedUserGroupPermissionTypes)
            {
                if (sb.ToString() != "")
                {
                    sb.Append(", ");
                }

                sb.Append(new PermissionDescriptor(permissionType).Label);
            }

            inheritedGroupPermissions.Add(new XElement("span", new XAttribute("style", "padding-left: 15px;"), string.Format("{0} = {1}", userGroup.Name, sb.ToString())));
            inheritedGroupPermissions.Add(new XElement("br"));
        }



        XElement element =
            new XElement("div", new XAttribute("style", string.Format("border:2px; border-style: solid; border-color: {0}; margin-bottom: 2px; margin-left:5px; margin-right:5px; padding: 3px;", color)),
                         new XElement("b", "Runtime type: "),
                         entityToken.GetType().ToString(),
                         new XElement("br"),
                         new XElement("b", "Hashcode: "),
                         entityToken.GetHashCode().ToString(),
                         new XElement("br"),
                         new XElement("b", "Source: "),
                         entityToken.Source,
                         new XElement("br"),
                         new XElement("b", "Type: "),
                         entityToken.Type,
                         new XElement("br"),
                         new XElement("b", "Id: "),
                         idList,
                         new XElement("br"),
                         new XElement("b", "Serialized entity token: "),
                         serializedEntityToken,
                         new XElement("br"),

                         new XElement("b", "Users permissions defined here: "),
                         new XElement("br"),
                         usersermisstionsDefinedHere,
                         new XElement("br"),

                         new XElement("b", "Current users permissions here: "),
                         new XElement("br"),
                         currentUsersPermisstionTypes,
                         new XElement("br"),

                         new XElement("b", "User group permissions defined here: "),
                         new XElement("br"),
                         userGroupPermissionsDefinedHere,
                         new XElement("br"),

                         new XElement("b", "Inherted user group permissions: "),
                         new XElement("br"),
                         inheritedGroupPermissions,
                         new XElement("br")
                         );

        RelationshipGraphHolder.Controls.Add(new LiteralControl(element.ToString()));
    }