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;
            }
        }
Beispiel #3
0
 public void Add(PersonalizationStateInfo data)
 {
 }
 public void CopyTo(PersonalizationStateInfo[] array, int index)
 {
 }
 public void Add(PersonalizationStateInfo data)
 {
 }
 public void CopyTo (PersonalizationStateInfo[] array, int index)
 {
   Contract.Ensures (array.Length >= 0);
 }