예제 #1
0
        /// <summary>
        /// Wrap specified data model with 'PlusAnonymousUserDataModel' (adds new user and its preferences).
        /// </summary>
        static IDataModel GetDataModelForNewUser(IDataModel baseModel, params long[] preferredItems)
        {
            var plusAnonymModel = new PlusAnonymousUserDataModel(baseModel);
            var prefArr         = new BooleanUserPreferenceArray(preferredItems.Length);

            prefArr.SetUserID(0, PlusAnonymousUserDataModel.TEMP_USER_ID);
            for (int i = 0; i < preferredItems.Length; i++)
            {
                prefArr.SetItemID(i, preferredItems[i]);
            }
            plusAnonymModel.SetTempPrefs(prefArr);
            return(plusAnonymModel);
        }
예제 #2
0
        internal static IDataModel BuildModelForUserPreferences(IDataModel baseModel, long userId, params long[] preferredItems)
        {
            var anonimousDataModel = new PlusAnonymousUserDataModel(baseModel);
            var preferencesArray   = new BooleanUserPreferenceArray(preferredItems.Length);

            preferencesArray.SetUserID(0, userId);

            for (int i = 0; i < preferredItems.Length; i++)
            {
                preferencesArray.SetItemID(i, preferredItems[i]);
            }

            anonimousDataModel.SetTempPrefs(preferencesArray);

            return(anonimousDataModel);
        }