Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / Mobile / MobileDeviceCapabilitiesSectionHandler.cs / 1305376 / MobileDeviceCapabilitiesSectionHandler.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Mobile { using System.Collections; using System.Configuration; using System.Reflection; using System.Xml; using System.Security.Permissions; ///[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] public class MobileDeviceCapabilitiesSectionHandler : IConfigurationSectionHandler { // IConfigurationSectionHandler Methods /// /// Object IConfigurationSectionHandler.Create(Object parent, Object context, XmlNode node) { return Create(parent, context, node); } protected object Create(Object parent, Object context, XmlNode node) { // see ASURT 123738 if (context == null || context.GetType() != typeof(System.Web.Configuration.HttpConfigurationContext)) { return null; } DeviceFilterDictionary currentFilterDictionary; if(parent == null) { currentFilterDictionary = new DeviceFilterDictionary(); } else { currentFilterDictionary = new DeviceFilterDictionary( (DeviceFilterDictionary)parent); } ConfigurationSectionHelper helper = new ConfigurationSectionHelper(); foreach(XmlNode child in node.ChildNodes) { helper.Node = child; // skip whitespace and comments if(helper.IsWhitespaceOrComment()) { continue; } // reject nonelements helper.RejectNonElement(); // handle tags if(child.Name.Equals("filter")) { String name = helper.RemoveStringAttribute("name", true); String className = helper.RemoveStringAttribute("type", false); if(className != null) { const String methodAttributeName = "method"; String methodName = helper.RemoveStringAttribute(methodAttributeName, false); String capabilityName = helper.RemoveStringAttribute("compare", false); String argumentValue = helper.RemoveStringAttribute("argument", false); helper.CheckForUnrecognizedAttributes(); if(className == String.Empty) { throw new ConfigurationErrorsException(SR.GetString(SR.DevCapSect_EmptyClass), child); } if(methodName == null) { throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSect_MissingAttr, methodAttributeName), child); } if(methodName == String.Empty) { throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSect_MissingValue, methodAttributeName), child); } if(capabilityName != null || argumentValue != null) { String msg; if (capabilityName != null) { msg = SR.GetString(SR.DevCapSect_ExtraCompareDelegator); } else { msg = SR.GetString(SR.DevCapSect_ExtraArgumentDelegator); } throw new ConfigurationErrorsException(msg, child); } MobileCapabilities.EvaluateCapabilitiesDelegate evaluator; Type evaluatorClass = Type.GetType(className); if(null == evaluatorClass) { String msg = SR.GetString(SR.DevCapSect_NoTypeInfo, className); throw new ConfigurationErrorsException(msg, child); } try { evaluator = (MobileCapabilities.EvaluateCapabilitiesDelegate) MobileCapabilities.EvaluateCapabilitiesDelegate.CreateDelegate( typeof(MobileCapabilities.EvaluateCapabilitiesDelegate), evaluatorClass, methodName); } catch(Exception e) { String msg = SR.GetString(SR.DevCapSect_NoCapabilityEval, methodName, e.Message); throw new ConfigurationErrorsException(msg, child); } currentFilterDictionary.AddCapabilityDelegate(name, evaluator); } else { String capabilityName = helper.RemoveStringAttribute("compare", false); String argumentValue = helper.RemoveStringAttribute("argument", false); String methodName = helper.RemoveStringAttribute("method", false); helper.CheckForUnrecognizedAttributes(); if(String.IsNullOrEmpty(capabilityName)) { throw new ConfigurationErrorsException( SR.GetString(SR.DevCapSect_MustSpecify), child); } if(methodName != null) { throw new ConfigurationErrorsException( SR.GetString(SR.DevCapSect_ComparisonAlreadySpecified), child); } try { currentFilterDictionary.AddComparisonDelegate(name, capabilityName, argumentValue); } catch(Exception e) { String msg = SR.GetString(SR.DevCapSect_UnableAddDelegate, name, e.Message); throw new ConfigurationErrorsException(msg, child); } } } else { String msg = SR.GetString(SR.DevCapSect_UnrecognizedTag, child.Name); throw new ConfigurationErrorsException(msg, child); } helper.Node = null; } return currentFilterDictionary; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Mobile { using System.Collections; using System.Configuration; using System.Reflection; using System.Xml; using System.Security.Permissions; ///[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] public class MobileDeviceCapabilitiesSectionHandler : IConfigurationSectionHandler { // IConfigurationSectionHandler Methods /// /// Object IConfigurationSectionHandler.Create(Object parent, Object context, XmlNode node) { return Create(parent, context, node); } protected object Create(Object parent, Object context, XmlNode node) { // see ASURT 123738 if (context == null || context.GetType() != typeof(System.Web.Configuration.HttpConfigurationContext)) { return null; } DeviceFilterDictionary currentFilterDictionary; if(parent == null) { currentFilterDictionary = new DeviceFilterDictionary(); } else { currentFilterDictionary = new DeviceFilterDictionary( (DeviceFilterDictionary)parent); } ConfigurationSectionHelper helper = new ConfigurationSectionHelper(); foreach(XmlNode child in node.ChildNodes) { helper.Node = child; // skip whitespace and comments if(helper.IsWhitespaceOrComment()) { continue; } // reject nonelements helper.RejectNonElement(); // handle tags if(child.Name.Equals("filter")) { String name = helper.RemoveStringAttribute("name", true); String className = helper.RemoveStringAttribute("type", false); if(className != null) { const String methodAttributeName = "method"; String methodName = helper.RemoveStringAttribute(methodAttributeName, false); String capabilityName = helper.RemoveStringAttribute("compare", false); String argumentValue = helper.RemoveStringAttribute("argument", false); helper.CheckForUnrecognizedAttributes(); if(className == String.Empty) { throw new ConfigurationErrorsException(SR.GetString(SR.DevCapSect_EmptyClass), child); } if(methodName == null) { throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSect_MissingAttr, methodAttributeName), child); } if(methodName == String.Empty) { throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSect_MissingValue, methodAttributeName), child); } if(capabilityName != null || argumentValue != null) { String msg; if (capabilityName != null) { msg = SR.GetString(SR.DevCapSect_ExtraCompareDelegator); } else { msg = SR.GetString(SR.DevCapSect_ExtraArgumentDelegator); } throw new ConfigurationErrorsException(msg, child); } MobileCapabilities.EvaluateCapabilitiesDelegate evaluator; Type evaluatorClass = Type.GetType(className); if(null == evaluatorClass) { String msg = SR.GetString(SR.DevCapSect_NoTypeInfo, className); throw new ConfigurationErrorsException(msg, child); } try { evaluator = (MobileCapabilities.EvaluateCapabilitiesDelegate) MobileCapabilities.EvaluateCapabilitiesDelegate.CreateDelegate( typeof(MobileCapabilities.EvaluateCapabilitiesDelegate), evaluatorClass, methodName); } catch(Exception e) { String msg = SR.GetString(SR.DevCapSect_NoCapabilityEval, methodName, e.Message); throw new ConfigurationErrorsException(msg, child); } currentFilterDictionary.AddCapabilityDelegate(name, evaluator); } else { String capabilityName = helper.RemoveStringAttribute("compare", false); String argumentValue = helper.RemoveStringAttribute("argument", false); String methodName = helper.RemoveStringAttribute("method", false); helper.CheckForUnrecognizedAttributes(); if(String.IsNullOrEmpty(capabilityName)) { throw new ConfigurationErrorsException( SR.GetString(SR.DevCapSect_MustSpecify), child); } if(methodName != null) { throw new ConfigurationErrorsException( SR.GetString(SR.DevCapSect_ComparisonAlreadySpecified), child); } try { currentFilterDictionary.AddComparisonDelegate(name, capabilityName, argumentValue); } catch(Exception e) { String msg = SR.GetString(SR.DevCapSect_UnableAddDelegate, name, e.Message); throw new ConfigurationErrorsException(msg, child); } } } else { String msg = SR.GetString(SR.DevCapSect_UnrecognizedTag, child.Name); throw new ConfigurationErrorsException(msg, child); } helper.Node = null; } return currentFilterDictionary; } } } // 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
- DataGridViewBand.cs
- TextBoxLine.cs
- DefaultConfirmation.cs
- EventManager.cs
- Geometry.cs
- UniqueConstraint.cs
- PropertyDescriptor.cs
- StructuredType.cs
- XmlUnspecifiedAttribute.cs
- TreeViewItemAutomationPeer.cs
- MenuStrip.cs
- ForEachAction.cs
- DataGridCaption.cs
- BamlResourceDeserializer.cs
- ThrowHelper.cs
- WindowsScroll.cs
- SqlGatherConsumedAliases.cs
- NativeMethods.cs
- XPathDescendantIterator.cs
- UIElementPropertyUndoUnit.cs
- ActivationArguments.cs
- SessionStateUtil.cs
- PerfService.cs
- SqlConnectionStringBuilder.cs
- DtrList.cs
- CharKeyFrameCollection.cs
- AsyncContentLoadedEventArgs.cs
- ProviderConnectionPointCollection.cs
- NullableBoolConverter.cs
- GridViewSelectEventArgs.cs
- WpfKnownMemberInvoker.cs
- LayoutEditorPart.cs
- ECDsaCng.cs
- PropertyReference.cs
- SerializableAuthorizationContext.cs
- PngBitmapDecoder.cs
- SocketPermission.cs
- TransformDescriptor.cs
- ConditionalBranch.cs
- SmtpReplyReaderFactory.cs
- ScrollBar.cs
- MarkupCompiler.cs
- GridItem.cs
- DataServiceStreamProviderWrapper.cs
- LambdaCompiler.Logical.cs
- Number.cs
- MenuAutomationPeer.cs
- CodeDOMProvider.cs
- ZipQueryOperator.cs
- UpdatePanelTrigger.cs
- HashAlgorithm.cs
- ViewStateModeByIdAttribute.cs
- StringCollection.cs
- ChooseAction.cs
- TemplateControlParser.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- GradientStopCollection.cs
- EventWaitHandleSecurity.cs
- XPathSelectionIterator.cs
- DataGridTextBox.cs
- HwndStylusInputProvider.cs
- OrderByExpression.cs
- ServiceModelActivationSectionGroup.cs
- XmlILConstructAnalyzer.cs
- WinFormsComponentEditor.cs
- DeviceFilterDictionary.cs
- ResourcesGenerator.cs
- GlobalAllocSafeHandle.cs
- SoapSchemaExporter.cs
- SystemWebCachingSectionGroup.cs
- HitTestFilterBehavior.cs
- EncodingTable.cs
- Image.cs
- XmlAttributeOverrides.cs
- InternalsVisibleToAttribute.cs
- WebRequestModuleElement.cs
- ListViewEditEventArgs.cs
- ObjectView.cs
- CollectionDataContractAttribute.cs
- JoinElimination.cs
- AsyncOperation.cs
- BlurEffect.cs
- SubpageParaClient.cs
- SchemaNotation.cs
- TextMessageEncodingElement.cs
- InstanceDescriptor.cs
- ScriptResourceAttribute.cs
- InputReportEventArgs.cs
- ResolveDuplexCD1AsyncResult.cs
- EntityModelBuildProvider.cs
- ScrollBar.cs
- Subtree.cs
- NegotiateStream.cs
- HttpProfileGroupBase.cs
- LazyTextWriterCreator.cs
- DnsPermission.cs
- SiteMapPath.cs
- Internal.cs
- KeyNotFoundException.cs
- DropDownButton.cs