Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Configuration / CapabilitiesState.cs / 1 / CapabilitiesState.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System.Collections; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Security; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Web.Caching; using System.Web.Compilation; using System.Web.Hosting; using System.Security.Permissions; // // Encapsulates the evaluation state used in computing capabilities // internal class CapabilitiesState { internal HttpRequest _request; internal IDictionary _values; internal ArrayList _matchlist; internal ArrayList _regexlist; internal bool _exit; internal bool _evaluateOnlyUserAgent; internal CapabilitiesState(HttpRequest request, IDictionary values) { _request = request; _values = values; _matchlist = new ArrayList(); _regexlist = new ArrayList(); } internal bool EvaluateOnlyUserAgent { get { return _evaluateOnlyUserAgent; } set { _evaluateOnlyUserAgent = value; } } internal virtual void ClearMatch() { if (_matchlist == null) { _regexlist = new ArrayList(); _matchlist = new ArrayList(); } else { _regexlist.Clear(); _matchlist.Clear(); } } internal virtual void AddMatch(DelayedRegex regex, Match match) { _regexlist.Add(regex); _matchlist.Add(match); } internal virtual void PopMatch() { _regexlist.RemoveAt(_regexlist.Count - 1); _matchlist.RemoveAt(_matchlist.Count - 1); } internal virtual String ResolveReference(String refname) { if (_matchlist == null) return String.Empty; int i = _matchlist.Count; while (i > 0) { i--; int groupnum = ((DelayedRegex)_regexlist[i]).GroupNumberFromName(refname); if (groupnum >= 0) { Group group = ((Match)_matchlist[i]).Groups[groupnum]; if (group.Success) { return group.ToString(); } } } return String.Empty; } [AspNetHostingPermission(SecurityAction.Assert, Level=AspNetHostingPermissionLevel.Low)] string ResolveServerVariableWithAssert(string varname) { string result = _request.ServerVariables[varname]; if (result == null) return string.Empty; return result; } internal virtual String ResolveServerVariable(String varname) { if (varname.Length == 0 || varname == "HTTP_USER_AGENT") return HttpCapabilitiesEvaluator.GetUserAgent(_request); if (EvaluateOnlyUserAgent) return string.Empty; return ResolveServerVariableWithAssert(varname); } internal virtual String ResolveVariable(String varname) { String result; result = (String)_values[varname]; if (result == null) return String.Empty; return result; } internal virtual void SetVariable(String varname, String value) { _values[varname] = value; } internal virtual bool Exit { get { return _exit; } set { _exit = value; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System.Collections; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Security; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Web.Caching; using System.Web.Compilation; using System.Web.Hosting; using System.Security.Permissions; // // Encapsulates the evaluation state used in computing capabilities // internal class CapabilitiesState { internal HttpRequest _request; internal IDictionary _values; internal ArrayList _matchlist; internal ArrayList _regexlist; internal bool _exit; internal bool _evaluateOnlyUserAgent; internal CapabilitiesState(HttpRequest request, IDictionary values) { _request = request; _values = values; _matchlist = new ArrayList(); _regexlist = new ArrayList(); } internal bool EvaluateOnlyUserAgent { get { return _evaluateOnlyUserAgent; } set { _evaluateOnlyUserAgent = value; } } internal virtual void ClearMatch() { if (_matchlist == null) { _regexlist = new ArrayList(); _matchlist = new ArrayList(); } else { _regexlist.Clear(); _matchlist.Clear(); } } internal virtual void AddMatch(DelayedRegex regex, Match match) { _regexlist.Add(regex); _matchlist.Add(match); } internal virtual void PopMatch() { _regexlist.RemoveAt(_regexlist.Count - 1); _matchlist.RemoveAt(_matchlist.Count - 1); } internal virtual String ResolveReference(String refname) { if (_matchlist == null) return String.Empty; int i = _matchlist.Count; while (i > 0) { i--; int groupnum = ((DelayedRegex)_regexlist[i]).GroupNumberFromName(refname); if (groupnum >= 0) { Group group = ((Match)_matchlist[i]).Groups[groupnum]; if (group.Success) { return group.ToString(); } } } return String.Empty; } [AspNetHostingPermission(SecurityAction.Assert, Level=AspNetHostingPermissionLevel.Low)] string ResolveServerVariableWithAssert(string varname) { string result = _request.ServerVariables[varname]; if (result == null) return string.Empty; return result; } internal virtual String ResolveServerVariable(String varname) { if (varname.Length == 0 || varname == "HTTP_USER_AGENT") return HttpCapabilitiesEvaluator.GetUserAgent(_request); if (EvaluateOnlyUserAgent) return string.Empty; return ResolveServerVariableWithAssert(varname); } internal virtual String ResolveVariable(String varname) { String result; result = (String)_values[varname]; if (result == null) return String.Empty; return result; } internal virtual void SetVariable(String varname, String value) { _values[varname] = value; } internal virtual bool Exit { get { return _exit; } set { _exit = value; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClientTargetSection.cs
- XmlSchemaGroupRef.cs
- BufferModesCollection.cs
- CommittableTransaction.cs
- ConnectionPoint.cs
- SQLGuidStorage.cs
- XamlPointCollectionSerializer.cs
- Brushes.cs
- ContainerCodeDomSerializer.cs
- WindowsFormsHostAutomationPeer.cs
- SiteOfOriginPart.cs
- DataGridItemCollection.cs
- ServiceProviders.cs
- DataSourceView.cs
- CollectionChangedEventManager.cs
- AnimationException.cs
- DbConnectionPoolIdentity.cs
- Rectangle.cs
- StylusPointPropertyInfoDefaults.cs
- MethodImplAttribute.cs
- GridView.cs
- DashStyles.cs
- WebUtil.cs
- DocobjHost.cs
- MimeFormatter.cs
- BasicHttpBindingCollectionElement.cs
- NamespaceDisplay.xaml.cs
- HandlerBase.cs
- SqlExpander.cs
- SynthesizerStateChangedEventArgs.cs
- IdentityElement.cs
- SHA1.cs
- DBDataPermission.cs
- AssociatedControlConverter.cs
- ResizeGrip.cs
- compensatingcollection.cs
- SiteMap.cs
- RSACryptoServiceProvider.cs
- HelpKeywordAttribute.cs
- LocalizationParserHooks.cs
- GridViewRowCollection.cs
- ConfigXmlCDataSection.cs
- CompressedStack.cs
- TraceSource.cs
- SplitterEvent.cs
- HttpCookie.cs
- VirtualDirectoryMapping.cs
- SqlCrossApplyToCrossJoin.cs
- BaseUriHelper.cs
- XmlNodeComparer.cs
- XPathSelectionIterator.cs
- LabelLiteral.cs
- Pair.cs
- OdbcParameterCollection.cs
- NativeObjectSecurity.cs
- PointLightBase.cs
- Thread.cs
- AddInDeploymentState.cs
- Rights.cs
- XmlNullResolver.cs
- SelectorAutomationPeer.cs
- NeutralResourcesLanguageAttribute.cs
- TemplateGroupCollection.cs
- PointAnimationUsingKeyFrames.cs
- ModelTreeEnumerator.cs
- TraceFilter.cs
- Delay.cs
- ScrollBar.cs
- LinqToSqlWrapper.cs
- ScriptReference.cs
- CatalogPartChrome.cs
- EditingMode.cs
- IteratorDescriptor.cs
- ItemCollection.cs
- Vector3DAnimationUsingKeyFrames.cs
- TableCellAutomationPeer.cs
- ImplicitInputBrush.cs
- PerfCounters.cs
- OleDbConnectionInternal.cs
- VisualStyleRenderer.cs
- X509ServiceCertificateAuthentication.cs
- KnownBoxes.cs
- NullableConverter.cs
- EntityDataSourceChangedEventArgs.cs
- AdRotator.cs
- RemoveStoryboard.cs
- Wizard.cs
- File.cs
- XmlSchemaExporter.cs
- StrokeNodeOperations2.cs
- Queue.cs
- ASCIIEncoding.cs
- NameSpaceExtractor.cs
- IndicShape.cs
- Expressions.cs
- StringFormat.cs
- MimeMultiPart.cs
- ClosableStream.cs
- SQLSingle.cs
- ConstructorArgumentAttribute.cs