public static int ResetState(PersonalizationStateInfoCollection data) { int num = 0; PersonalizationProviderHelper.CheckNullEntries(data, "data"); StringCollection strings = null; foreach (PersonalizationStateInfo info in data) { UserPersonalizationStateInfo info2 = info as UserPersonalizationStateInfo; if (info2 != null) { if (ResetUserState(info2.Path, info2.Username)) { num++; } } else { if (strings == null) { strings = new StringCollection(); } strings.Add(info.Path); } } if (strings != null) { string[] array = new string[strings.Count]; strings.CopyTo(array, 0); num += ResetStatePrivate(PersonalizationScope.Shared, array, null); } return(num); }
public void Add(PersonalizationStateInfo data) { if (data == null) { throw new ArgumentNullException("data"); } Key key; UserPersonalizationStateInfo userData = data as UserPersonalizationStateInfo; if (userData != null) { key = new Key(userData.Path, userData.Username); } else { key = new Key(data.Path, null); } // VSWhidbey 376063: avoid key duplicate, we check here first before we add. if (_indices.ContainsKey(key)) { if (userData != null) { throw new ArgumentException(SR.GetString(SR.PersonalizationStateInfoCollection_CouldNotAddUserStateInfo, key.Path, key.Username)); } else { throw new ArgumentException(SR.GetString(SR.PersonalizationStateInfoCollection_CouldNotAddSharedStateInfo, key.Path)); } } int pos = _values.Add(data); try { _indices.Add(key, pos); } catch { // Roll back the first addition to make the whole addition atomic _values.RemoveAt(pos); throw; } }
public void Add(PersonalizationStateInfo data) { Key key; if (data == null) { throw new ArgumentNullException("data"); } UserPersonalizationStateInfo info = data as UserPersonalizationStateInfo; if (info != null) { key = new Key(info.Path, info.Username); } else { key = new Key(data.Path, null); } if (this._indices.ContainsKey(key)) { if (info != null) { throw new ArgumentException(System.Web.SR.GetString("PersonalizationStateInfoCollection_CouldNotAddUserStateInfo", new object[] { key.Path, key.Username })); } throw new ArgumentException(System.Web.SR.GetString("PersonalizationStateInfoCollection_CouldNotAddSharedStateInfo", new object[] { key.Path })); } int num = this._values.Add(data); try { this._indices.Add(key, num); } catch { this._values.RemoveAt(num); throw; } }
public static int ResetState(PersonalizationStateInfoCollection data) { int count = 0; PersonalizationProviderHelper.CheckNullEntries(data, "data"); StringCollection sharedPaths = null; foreach (PersonalizationStateInfo stateInfo in data) { UserPersonalizationStateInfo userStateInfo = stateInfo as UserPersonalizationStateInfo; if (userStateInfo != null) { if (ResetUserState(userStateInfo.Path, userStateInfo.Username)) { count += 1; } } else { if (sharedPaths == null) { sharedPaths = new StringCollection(); } sharedPaths.Add(stateInfo.Path); } } if (sharedPaths != null) { string [] sharedPathsArray = new string [sharedPaths.Count]; sharedPaths.CopyTo(sharedPathsArray, 0); count += ResetStatePrivate(PersonalizationScope.Shared, sharedPathsArray, null); } return(count); }