Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / UI / WebParts / PersonalizationDictionary.cs / 1 / PersonalizationDictionary.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Web.Util;
using System.Security.Permissions;
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
// This class is unsealed so it can be extended by developers who extend the personalization infrastructure
public class PersonalizationDictionary : IDictionary {
private HybridDictionary _dictionary;
public PersonalizationDictionary() {
_dictionary = new HybridDictionary(/* caseInsensitive */ true);
}
public PersonalizationDictionary(int initialSize) {
_dictionary = new HybridDictionary(initialSize, /* caseInsensitive */ true);
}
public virtual int Count {
get {
return _dictionary.Count;
}
}
public virtual bool IsFixedSize {
get {
return false;
}
}
public virtual bool IsReadOnly {
get {
return false;
}
}
public virtual bool IsSynchronized {
get {
return false;
}
}
public virtual ICollection Keys {
get {
return _dictionary.Keys;
}
}
public virtual object SyncRoot {
get {
return this;
}
}
public virtual ICollection Values {
get {
return _dictionary.Values;
}
}
public virtual PersonalizationEntry this[string key] {
get{
key = StringUtil.CheckAndTrimString(key, "key");
return (PersonalizationEntry)_dictionary[key];
}
set {
key = StringUtil.CheckAndTrimString(key, "key");
if (value == null) {
throw new ArgumentNullException("value");
}
_dictionary[key] = value;
}
}
public virtual void Add(string key, PersonalizationEntry value) {
key = StringUtil.CheckAndTrimString(key, "key");
if (value == null) {
throw new ArgumentNullException("value");
}
_dictionary.Add(key, value);
}
public virtual void Clear() {
_dictionary.Clear();
}
public virtual bool Contains(string key) {
key = StringUtil.CheckAndTrimString(key, "key");
return _dictionary.Contains(key);
}
public virtual void CopyTo(DictionaryEntry[] array, int index) {
_dictionary.CopyTo(array, index);
}
public virtual IDictionaryEnumerator GetEnumerator() {
return _dictionary.GetEnumerator();
}
public virtual void Remove(string key) {
key = StringUtil.CheckAndTrimString(key, "key");
_dictionary.Remove(key);
}
internal void RemoveSharedProperties() {
DictionaryEntry[] entries = new DictionaryEntry[Count];
CopyTo(entries, 0);
foreach (DictionaryEntry entry in entries) {
if (((PersonalizationEntry)entry.Value).Scope == PersonalizationScope.Shared) {
Remove((string)entry.Key);
}
}
}
#region Implementation of IDictionary
object IDictionary.this[object key] {
get {
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
return this[(string)key];
}
set {
if (value == null) {
throw new ArgumentNullException("value");
}
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
if (!(value is PersonalizationEntry)) {
throw new ArgumentException(SR.GetString(
SR.PersonalizationDictionary_MustBeTypePersonalizationEntry), "value");
}
this[(string)key] = (PersonalizationEntry)value;
}
}
void IDictionary.Add(object key, object value) {
if (value == null) {
throw new ArgumentNullException("value");
}
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
if (!(value is PersonalizationEntry)) {
throw new ArgumentException(SR.GetString(
SR.PersonalizationDictionary_MustBeTypePersonalizationEntry), "value");
}
Add((string)key, (PersonalizationEntry)value);
}
bool IDictionary.Contains(object key) {
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
return Contains((string)key);
}
void IDictionary.Remove(object key) {
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
Remove((string)key);
}
#endregion
#region Implementation of ICollection
void ICollection.CopyTo(Array array, int index) {
if (!(array is DictionaryEntry[])) {
throw new ArgumentException(
SR.GetString(SR.PersonalizationDictionary_MustBeTypeDictionaryEntryArray), "array");
}
CopyTo((DictionaryEntry[])array, index);
}
#endregion
#region Implementation of IEnumerable
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Web.Util;
using System.Security.Permissions;
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
// This class is unsealed so it can be extended by developers who extend the personalization infrastructure
public class PersonalizationDictionary : IDictionary {
private HybridDictionary _dictionary;
public PersonalizationDictionary() {
_dictionary = new HybridDictionary(/* caseInsensitive */ true);
}
public PersonalizationDictionary(int initialSize) {
_dictionary = new HybridDictionary(initialSize, /* caseInsensitive */ true);
}
public virtual int Count {
get {
return _dictionary.Count;
}
}
public virtual bool IsFixedSize {
get {
return false;
}
}
public virtual bool IsReadOnly {
get {
return false;
}
}
public virtual bool IsSynchronized {
get {
return false;
}
}
public virtual ICollection Keys {
get {
return _dictionary.Keys;
}
}
public virtual object SyncRoot {
get {
return this;
}
}
public virtual ICollection Values {
get {
return _dictionary.Values;
}
}
public virtual PersonalizationEntry this[string key] {
get{
key = StringUtil.CheckAndTrimString(key, "key");
return (PersonalizationEntry)_dictionary[key];
}
set {
key = StringUtil.CheckAndTrimString(key, "key");
if (value == null) {
throw new ArgumentNullException("value");
}
_dictionary[key] = value;
}
}
public virtual void Add(string key, PersonalizationEntry value) {
key = StringUtil.CheckAndTrimString(key, "key");
if (value == null) {
throw new ArgumentNullException("value");
}
_dictionary.Add(key, value);
}
public virtual void Clear() {
_dictionary.Clear();
}
public virtual bool Contains(string key) {
key = StringUtil.CheckAndTrimString(key, "key");
return _dictionary.Contains(key);
}
public virtual void CopyTo(DictionaryEntry[] array, int index) {
_dictionary.CopyTo(array, index);
}
public virtual IDictionaryEnumerator GetEnumerator() {
return _dictionary.GetEnumerator();
}
public virtual void Remove(string key) {
key = StringUtil.CheckAndTrimString(key, "key");
_dictionary.Remove(key);
}
internal void RemoveSharedProperties() {
DictionaryEntry[] entries = new DictionaryEntry[Count];
CopyTo(entries, 0);
foreach (DictionaryEntry entry in entries) {
if (((PersonalizationEntry)entry.Value).Scope == PersonalizationScope.Shared) {
Remove((string)entry.Key);
}
}
}
#region Implementation of IDictionary
object IDictionary.this[object key] {
get {
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
return this[(string)key];
}
set {
if (value == null) {
throw new ArgumentNullException("value");
}
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
if (!(value is PersonalizationEntry)) {
throw new ArgumentException(SR.GetString(
SR.PersonalizationDictionary_MustBeTypePersonalizationEntry), "value");
}
this[(string)key] = (PersonalizationEntry)value;
}
}
void IDictionary.Add(object key, object value) {
if (value == null) {
throw new ArgumentNullException("value");
}
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
if (!(value is PersonalizationEntry)) {
throw new ArgumentException(SR.GetString(
SR.PersonalizationDictionary_MustBeTypePersonalizationEntry), "value");
}
Add((string)key, (PersonalizationEntry)value);
}
bool IDictionary.Contains(object key) {
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
return Contains((string)key);
}
void IDictionary.Remove(object key) {
if (!(key is string)) {
throw new ArgumentException(SR.GetString(SR.PersonalizationDictionary_MustBeTypeString), "key");
}
Remove((string)key);
}
#endregion
#region Implementation of ICollection
void ICollection.CopyTo(Array array, int index) {
if (!(array is DictionaryEntry[])) {
throw new ArgumentException(
SR.GetString(SR.PersonalizationDictionary_MustBeTypeDictionaryEntryArray), "array");
}
CopyTo((DictionaryEntry[])array, index);
}
#endregion
#region Implementation of IEnumerable
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MarshalByValueComponent.cs
- ExpressionLexer.cs
- XmlSerializer.cs
- EntityDataSourceContextCreatedEventArgs.cs
- IndexerNameAttribute.cs
- EncodingNLS.cs
- DesignerToolboxInfo.cs
- ProcessHostFactoryHelper.cs
- ClientConvert.cs
- ModelServiceImpl.cs
- LinkedResource.cs
- Encoding.cs
- DoubleConverter.cs
- OleCmdHelper.cs
- UriTemplatePathSegment.cs
- PagerStyle.cs
- RenderDataDrawingContext.cs
- ColorConvertedBitmapExtension.cs
- _HeaderInfo.cs
- StrongNamePublicKeyBlob.cs
- UnicodeEncoding.cs
- Label.cs
- ArgumentOutOfRangeException.cs
- ProgressChangedEventArgs.cs
- PropertyReferenceSerializer.cs
- GridViewRowEventArgs.cs
- WorkflowPrinting.cs
- KeyValueConfigurationCollection.cs
- BmpBitmapEncoder.cs
- SystemIPv6InterfaceProperties.cs
- AspNetRouteServiceHttpHandler.cs
- MissingMemberException.cs
- UserPreferenceChangingEventArgs.cs
- RootBrowserWindow.cs
- BooleanAnimationBase.cs
- SqlTopReducer.cs
- SchemaEntity.cs
- DetailsViewUpdatedEventArgs.cs
- ToolStripButton.cs
- Set.cs
- RightNameExpirationInfoPair.cs
- DiscoveryMessageProperty.cs
- Rethrow.cs
- Point3D.cs
- Selection.cs
- PackageProperties.cs
- PeerToPeerException.cs
- InfoCardListRequest.cs
- XmlChildNodes.cs
- SecurityTokenProvider.cs
- InstancePersistenceContext.cs
- FixedSOMContainer.cs
- TcpServerChannel.cs
- VectorAnimationUsingKeyFrames.cs
- ResourceDisplayNameAttribute.cs
- DrawingContext.cs
- SynchronizationScope.cs
- SequentialActivityDesigner.cs
- ExpressionBindings.cs
- SectionVisual.cs
- WpfGeneratedKnownProperties.cs
- ProviderException.cs
- NativeCppClassAttribute.cs
- AssemblyNameProxy.cs
- FilterableAttribute.cs
- PriorityBinding.cs
- ImplicitInputBrush.cs
- TextSpan.cs
- ResourceExpression.cs
- _NTAuthentication.cs
- XmlNodeList.cs
- MessageFilter.cs
- DefaultDiscoveryServiceExtension.cs
- RequestCachePolicy.cs
- HtmlObjectListAdapter.cs
- BitSet.cs
- Int64.cs
- NativeMethods.cs
- TagNameToTypeMapper.cs
- CompilerScopeManager.cs
- CustomAttributeFormatException.cs
- AssertUtility.cs
- GetPageNumberCompletedEventArgs.cs
- DrawingGroup.cs
- KnownColorTable.cs
- ResourceReferenceExpression.cs
- SoapSchemaImporter.cs
- _UriTypeConverter.cs
- OdbcCommandBuilder.cs
- XmlTextReader.cs
- PointCollectionValueSerializer.cs
- MouseBinding.cs
- DataSourceSelectArguments.cs
- AdornerLayer.cs
- TableLayoutPanel.cs
- DelegateSerializationHolder.cs
- PageSetupDialog.cs
- ActiveXContainer.cs
- TextChangedEventArgs.cs
- TypeNameHelper.cs