public override int GetCountOfState(PersonalizationScope scope, PersonalizationStateQuery query)
 {
     PersonalizationProviderHelper.CheckPersonalizationScope(scope);
     if (scope == PersonalizationScope.Shared)
     {
         string pathToMatch = null;
         if (query != null)
         {
             pathToMatch = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength);
         }
         return(GetCountOfSharedState(pathToMatch));
     }
     else
     {
         string   pathToMatch           = null;
         DateTime userInactiveSinceDate = DateTime.MinValue;
         string   usernameToMatch       = null;
         if (query != null)
         {
             pathToMatch           = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength);
             userInactiveSinceDate = query.UserInactiveSinceDate;
             usernameToMatch       = PersonalizationProviderHelper.CheckAndTrimString(
                 query.UsernameToMatch, "query.UsernameToMatch", false, MaxStringLength);
         }
         return(GetCountOfUserState(pathToMatch, userInactiveSinceDate, usernameToMatch));
     }
 }
        public override PersonalizationStateInfoCollection FindState(PersonalizationScope scope,
                                                                     PersonalizationStateQuery query,
                                                                     int pageIndex,
                                                                     int pageSize,
                                                                     out int totalRecords)
        {
            PersonalizationProviderHelper.CheckPersonalizationScope(scope);
            PersonalizationProviderHelper.CheckPageIndexAndSize(pageIndex, pageSize);

            if (scope == PersonalizationScope.Shared)
            {
                string pathToMatch = null;
                if (query != null)
                {
                    pathToMatch = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength);
                }
                return(FindSharedState(pathToMatch, pageIndex, pageSize, out totalRecords));
            }
            else
            {
                string   pathToMatch       = null;
                DateTime inactiveSinceDate = DateTime.MinValue;
                string   usernameToMatch   = null;
                if (query != null)
                {
                    pathToMatch       = PersonalizationProviderHelper.CheckAndTrimString(query.PathToMatch, "query.PathToMatch", false, MaxStringLength);
                    inactiveSinceDate = query.UserInactiveSinceDate;
                    usernameToMatch   = PersonalizationProviderHelper.CheckAndTrimString(
                        query.UsernameToMatch, "query.UsernameToMatch", false, MaxStringLength);
                }

                return(FindUserState(pathToMatch, inactiveSinceDate, usernameToMatch,
                                     pageIndex, pageSize, out totalRecords));
            }
        }
        public override int ResetState(PersonalizationScope scope, string[] paths, string[] usernames)
        {
            PersonalizationProviderHelper.CheckPersonalizationScope(scope);
            paths     = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(paths, "paths", false, false, MaxStringLength);
            usernames = PersonalizationProviderHelper.CheckAndTrimNonEmptyStringEntries(usernames, "usernames", false, true, MaxStringLength);

            if (scope == PersonalizationScope.Shared)
            {
                PersonalizationProviderHelper.CheckUsernamesInSharedScope(usernames);
                return(ResetSharedState(paths));
            }
            else
            {
                PersonalizationProviderHelper.CheckOnlyOnePathWithUsers(paths, usernames);
                return(ResetUserState(paths, usernames));
            }
        }