Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / HttpCookieCollection.cs / 4 / HttpCookieCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Collection of Http cookies for request and response intrinsics * * Copyright (c) 1998 Microsoft Corporation */ namespace System.Web { using System.Runtime.InteropServices; using System.Collections; using System.Collections.Specialized; using System.Security.Permissions; using System.Web.Util; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class HttpCookieCollection : NameObjectCollectionBase { // Response object to notify about changes in collection private HttpResponse _response; // cached All[] arrays private HttpCookie[] _all; private String[] _allKeys; private bool _changed; internal HttpCookieCollection(HttpResponse response, bool readOnly) : base(StringComparer.OrdinalIgnoreCase) { _response = response; IsReadOnly = readOnly; } ////// Provides a type-safe /// way to manipulate HTTP cookies. /// ////// public HttpCookieCollection(): base(StringComparer.OrdinalIgnoreCase) { } internal bool Changed { get { return _changed; } set { _changed = value; } } internal void AddCookie(HttpCookie cookie, bool append) { _all = null; _allKeys = null; if (append) { // mark cookie as new cookie.Added = true; BaseAdd(cookie.Name, cookie); } else { if (BaseGet(cookie.Name) != null) { // mark the cookie as changed because we are overriding the existing one cookie.Changed = true; } BaseSet(cookie.Name, cookie); } } internal void RemoveCookie(String name) { _all = null; _allKeys = null; BaseRemove(name); _changed = true; } internal void Reset() { _all = null; _allKeys = null; BaseClear(); _changed = true; } // // Public APIs to add / remove // ////// Initializes a new instance of the HttpCookieCollection /// class. /// ////// public void Add(HttpCookie cookie) { if (_response != null) _response.BeforeCookieCollectionChange(); AddCookie(cookie, true); if (_response != null) _response.OnCookieAdd(cookie); } ////// Adds a cookie to the collection. /// ////// public void CopyTo(Array dest, int index) { if (_all == null) { int n = Count; _all = new HttpCookie[n]; for (int i = 0; i < n; i++) _all[i] = Get(i); } _all.CopyTo(dest, index); } ///[To be supplied.] ////// public void Set(HttpCookie cookie) { if (_response != null) _response.BeforeCookieCollectionChange(); AddCookie(cookie, false); if (_response != null) _response.OnCookieCollectionChange(); } ///Updates the value of a cookie. ////// public void Remove(String name) { if (_response != null) _response.BeforeCookieCollectionChange(); RemoveCookie(name); if (_response != null) _response.OnCookieCollectionChange(); } ////// Removes a cookie from the collection. /// ////// public void Clear() { Reset(); } // // Access by name // ////// Clears all cookies from the collection. /// ////// public HttpCookie Get(String name) { HttpCookie cookie = (HttpCookie)BaseGet(name); if (cookie == null && _response != null) { // response cookies are created on demand cookie = new HttpCookie(name); AddCookie(cookie, true); _response.OnCookieAdd(cookie); } return cookie; } ///Returns an ///item from the collection. /// public HttpCookie this[String name] { get { return Get(name);} } // // Indexed access // ///Indexed value that enables access to a cookie in the collection. ////// public HttpCookie Get(int index) { return(HttpCookie)BaseGet(index); } ////// Returns an ////// item from the collection. /// /// public String GetKey(int index) { return BaseGetKey(index); } ////// Returns key name from collection. /// ////// public HttpCookie this[int index] { get { return Get(index);} } // // Access to keys and values as arrays // /* * All keys */ ////// Default property. /// Indexed property that enables access to a cookie in the collection. /// ////// public String[] AllKeys { get { if (_allKeys == null) _allKeys = BaseGetAllKeys(); return _allKeys; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ ///// Returns /// an array of all cookie keys in the cookie collection. /// ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Collection of Http cookies for request and response intrinsics * * Copyright (c) 1998 Microsoft Corporation */ namespace System.Web { using System.Runtime.InteropServices; using System.Collections; using System.Collections.Specialized; using System.Security.Permissions; using System.Web.Util; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class HttpCookieCollection : NameObjectCollectionBase { // Response object to notify about changes in collection private HttpResponse _response; // cached All[] arrays private HttpCookie[] _all; private String[] _allKeys; private bool _changed; internal HttpCookieCollection(HttpResponse response, bool readOnly) : base(StringComparer.OrdinalIgnoreCase) { _response = response; IsReadOnly = readOnly; } ////// Provides a type-safe /// way to manipulate HTTP cookies. /// ////// public HttpCookieCollection(): base(StringComparer.OrdinalIgnoreCase) { } internal bool Changed { get { return _changed; } set { _changed = value; } } internal void AddCookie(HttpCookie cookie, bool append) { _all = null; _allKeys = null; if (append) { // mark cookie as new cookie.Added = true; BaseAdd(cookie.Name, cookie); } else { if (BaseGet(cookie.Name) != null) { // mark the cookie as changed because we are overriding the existing one cookie.Changed = true; } BaseSet(cookie.Name, cookie); } } internal void RemoveCookie(String name) { _all = null; _allKeys = null; BaseRemove(name); _changed = true; } internal void Reset() { _all = null; _allKeys = null; BaseClear(); _changed = true; } // // Public APIs to add / remove // ////// Initializes a new instance of the HttpCookieCollection /// class. /// ////// public void Add(HttpCookie cookie) { if (_response != null) _response.BeforeCookieCollectionChange(); AddCookie(cookie, true); if (_response != null) _response.OnCookieAdd(cookie); } ////// Adds a cookie to the collection. /// ////// public void CopyTo(Array dest, int index) { if (_all == null) { int n = Count; _all = new HttpCookie[n]; for (int i = 0; i < n; i++) _all[i] = Get(i); } _all.CopyTo(dest, index); } ///[To be supplied.] ////// public void Set(HttpCookie cookie) { if (_response != null) _response.BeforeCookieCollectionChange(); AddCookie(cookie, false); if (_response != null) _response.OnCookieCollectionChange(); } ///Updates the value of a cookie. ////// public void Remove(String name) { if (_response != null) _response.BeforeCookieCollectionChange(); RemoveCookie(name); if (_response != null) _response.OnCookieCollectionChange(); } ////// Removes a cookie from the collection. /// ////// public void Clear() { Reset(); } // // Access by name // ////// Clears all cookies from the collection. /// ////// public HttpCookie Get(String name) { HttpCookie cookie = (HttpCookie)BaseGet(name); if (cookie == null && _response != null) { // response cookies are created on demand cookie = new HttpCookie(name); AddCookie(cookie, true); _response.OnCookieAdd(cookie); } return cookie; } ///Returns an ///item from the collection. /// public HttpCookie this[String name] { get { return Get(name);} } // // Indexed access // ///Indexed value that enables access to a cookie in the collection. ////// public HttpCookie Get(int index) { return(HttpCookie)BaseGet(index); } ////// Returns an ////// item from the collection. /// /// public String GetKey(int index) { return BaseGetKey(index); } ////// Returns key name from collection. /// ////// public HttpCookie this[int index] { get { return Get(index);} } // // Access to keys and values as arrays // /* * All keys */ ////// Default property. /// Indexed property that enables access to a cookie in the collection. /// ////// public String[] AllKeys { get { if (_allKeys == null) _allKeys = BaseGetAllKeys(); return _allKeys; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// Returns /// an array of all cookie keys in the cookie collection. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- QuaternionAnimationUsingKeyFrames.cs
- HeaderedContentControl.cs
- Cell.cs
- LogReservationCollection.cs
- XmlSchemaCompilationSettings.cs
- ThreadPool.cs
- Odbc32.cs
- SafeBitVector32.cs
- DataControlButton.cs
- RepeatBehavior.cs
- BindingContext.cs
- WrapperEqualityComparer.cs
- ClientSettings.cs
- UnitySerializationHolder.cs
- DataSourceControl.cs
- DataGridViewSelectedRowCollection.cs
- PreservationFileWriter.cs
- TextAction.cs
- FloaterParagraph.cs
- StringComparer.cs
- SharedStream.cs
- ScriptComponentDescriptor.cs
- EncodingInfo.cs
- BindStream.cs
- WindowsHyperlink.cs
- DES.cs
- CustomAttribute.cs
- SyndicationElementExtensionCollection.cs
- DodSequenceMerge.cs
- DbExpressionRules.cs
- ToolStripSplitStackLayout.cs
- SspiSafeHandles.cs
- SHA512.cs
- ClonableStack.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- SByte.cs
- QuaternionValueSerializer.cs
- WebPartDisplayModeCancelEventArgs.cs
- ComponentCollection.cs
- Substitution.cs
- TableLayoutStyleCollection.cs
- NameSpaceExtractor.cs
- CryptographicAttribute.cs
- EntityAdapter.cs
- MimeTypeAttribute.cs
- QilIterator.cs
- Transactions.cs
- ComboBoxAutomationPeer.cs
- XamlFigureLengthSerializer.cs
- BuildManager.cs
- GridItemPatternIdentifiers.cs
- IDReferencePropertyAttribute.cs
- GorillaCodec.cs
- DurableMessageDispatchInspector.cs
- FixedSOMPage.cs
- HttpValueCollection.cs
- PropertyValueChangedEvent.cs
- ClientOperation.cs
- HitTestParameters3D.cs
- SubpageParagraph.cs
- InternalConfigSettingsFactory.cs
- DoubleStorage.cs
- SimpleTableProvider.cs
- AnimatedTypeHelpers.cs
- InputLanguageSource.cs
- DirectoryNotFoundException.cs
- SynchronousReceiveElement.cs
- Enlistment.cs
- ValueQuery.cs
- ContractSearchPattern.cs
- BaseTreeIterator.cs
- InputMethod.cs
- InstanceData.cs
- SystemIPAddressInformation.cs
- EntityTemplateUserControl.cs
- ConfigXmlCDataSection.cs
- ThreadExceptionEvent.cs
- Metafile.cs
- DataGridViewRowEventArgs.cs
- ChannelServices.cs
- ToolStripSeparatorRenderEventArgs.cs
- DataBindingExpressionBuilder.cs
- StorageAssociationSetMapping.cs
- URLIdentityPermission.cs
- ModifiableIteratorCollection.cs
- XsltLibrary.cs
- cryptoapiTransform.cs
- XPathDescendantIterator.cs
- XmlCustomFormatter.cs
- TemplateControlCodeDomTreeGenerator.cs
- Timer.cs
- SqlNodeTypeOperators.cs
- MailWriter.cs
- XmlReaderSettings.cs
- ComboBoxItem.cs
- WaitHandleCannotBeOpenedException.cs
- HtmlInputHidden.cs
- Trace.cs
- DataServiceHost.cs
- ReadWriteObjectLock.cs