Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Web / System / Web / Services / Protocols / ValueCollectionParameterReader.cs / 1305376 / ValueCollectionParameterReader.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Protocols { using System.IO; using System; using System.Xml.Serialization; using System.Reflection; using System.Collections; using System.Collections.Specialized; using System.Web.Services; using System.Text; using System.Security.Permissions; ////// /// public abstract class ValueCollectionParameterReader : MimeParameterReader { ParameterInfo[] paramInfos; ///[To be supplied.] ////// /// public override void Initialize(object o) { paramInfos = (ParameterInfo[])o; } ///[To be supplied.] ////// /// public override object GetInitializer(LogicalMethodInfo methodInfo) { if (!IsSupported(methodInfo)) return null; return methodInfo.InParameters; } ///[To be supplied.] ////// /// protected object[] Read(NameValueCollection collection) { object[] parameters = new object[paramInfos.Length]; for (int i = 0; i < paramInfos.Length; i++) { ParameterInfo paramInfo = paramInfos[i]; if (paramInfo.ParameterType.IsArray) { string[] arrayValues = collection.GetValues(paramInfo.Name); Type arrayType = paramInfo.ParameterType.GetElementType(); Array array = Array.CreateInstance(arrayType, arrayValues.Length); for (int j = 0; j < arrayValues.Length; j++) { string value = arrayValues[j]; array.SetValue(ScalarFormatter.FromString(value, arrayType), j); } parameters[i] = array; } else { string value = collection[paramInfo.Name]; if (value == null) throw new InvalidOperationException(Res.GetString(Res.WebMissingParameter, paramInfo.Name)); parameters[i] = ScalarFormatter.FromString(value, paramInfo.ParameterType); } } return parameters; } ///[To be supplied.] ////// /// static public bool IsSupported(LogicalMethodInfo methodInfo) { if (methodInfo.OutParameters.Length > 0) return false; ParameterInfo[] paramInfos = methodInfo.InParameters; for (int i = 0; i < paramInfos.Length; i++) if (!IsSupported(paramInfos[i])) return false; return true; } ///[To be supplied.] ////// /// static public bool IsSupported(ParameterInfo paramInfo) { Type type = paramInfo.ParameterType; if (type.IsArray) type = type.GetElementType(); return ScalarFormatter.IsTypeSupported(type); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //[To be supplied.] ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Protocols { using System.IO; using System; using System.Xml.Serialization; using System.Reflection; using System.Collections; using System.Collections.Specialized; using System.Web.Services; using System.Text; using System.Security.Permissions; ////// /// public abstract class ValueCollectionParameterReader : MimeParameterReader { ParameterInfo[] paramInfos; ///[To be supplied.] ////// /// public override void Initialize(object o) { paramInfos = (ParameterInfo[])o; } ///[To be supplied.] ////// /// public override object GetInitializer(LogicalMethodInfo methodInfo) { if (!IsSupported(methodInfo)) return null; return methodInfo.InParameters; } ///[To be supplied.] ////// /// protected object[] Read(NameValueCollection collection) { object[] parameters = new object[paramInfos.Length]; for (int i = 0; i < paramInfos.Length; i++) { ParameterInfo paramInfo = paramInfos[i]; if (paramInfo.ParameterType.IsArray) { string[] arrayValues = collection.GetValues(paramInfo.Name); Type arrayType = paramInfo.ParameterType.GetElementType(); Array array = Array.CreateInstance(arrayType, arrayValues.Length); for (int j = 0; j < arrayValues.Length; j++) { string value = arrayValues[j]; array.SetValue(ScalarFormatter.FromString(value, arrayType), j); } parameters[i] = array; } else { string value = collection[paramInfo.Name]; if (value == null) throw new InvalidOperationException(Res.GetString(Res.WebMissingParameter, paramInfo.Name)); parameters[i] = ScalarFormatter.FromString(value, paramInfo.ParameterType); } } return parameters; } ///[To be supplied.] ////// /// static public bool IsSupported(LogicalMethodInfo methodInfo) { if (methodInfo.OutParameters.Length > 0) return false; ParameterInfo[] paramInfos = methodInfo.InParameters; for (int i = 0; i < paramInfos.Length; i++) if (!IsSupported(paramInfos[i])) return false; return true; } ///[To be supplied.] ////// /// static public bool IsSupported(ParameterInfo paramInfo) { Type type = paramInfo.ParameterType; if (type.IsArray) type = type.GetElementType(); return ScalarFormatter.IsTypeSupported(type); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.[To be supplied.] ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ZoneButton.cs
- DataGridGeneralPage.cs
- ValidatorUtils.cs
- BinHexEncoder.cs
- WebPartEditVerb.cs
- MasterPage.cs
- PropertyChangedEventManager.cs
- ServiceAppDomainAssociationProvider.cs
- MailMessageEventArgs.cs
- CreateRefExpr.cs
- XmlText.cs
- BaseHashHelper.cs
- BadImageFormatException.cs
- ToolStripItemRenderEventArgs.cs
- ParserStack.cs
- XmlBinaryReaderSession.cs
- GraphicsState.cs
- httpstaticobjectscollection.cs
- VirtualPath.cs
- BitmapMetadataEnumerator.cs
- RoleManagerSection.cs
- GridViewPageEventArgs.cs
- ObjectDataSourceDisposingEventArgs.cs
- dtdvalidator.cs
- PrivateFontCollection.cs
- DataSourceNameHandler.cs
- DragCompletedEventArgs.cs
- ExpressionParser.cs
- MailDefinition.cs
- BreakRecordTable.cs
- StrongNameKeyPair.cs
- ConfigPathUtility.cs
- WebPartConnectionsCancelVerb.cs
- MemberRelationshipService.cs
- TransformationRules.cs
- ImageList.cs
- MenuCommand.cs
- ConfigurationSchemaErrors.cs
- RequestContext.cs
- SiteMapHierarchicalDataSourceView.cs
- XmlArrayAttribute.cs
- HostingEnvironmentSection.cs
- Missing.cs
- PinnedBufferMemoryStream.cs
- EventDescriptor.cs
- ZoneButton.cs
- Encoder.cs
- ScaleTransform.cs
- RtfFormatStack.cs
- BindingExpressionUncommonField.cs
- SqlConnectionManager.cs
- XmlSchemaImport.cs
- RemotingConfigParser.cs
- UIServiceHelper.cs
- WebControlParameterProxy.cs
- SqlExpressionNullability.cs
- DbCommandTree.cs
- Renderer.cs
- UniqueEventHelper.cs
- Main.cs
- ParamArrayAttribute.cs
- WindowsFormsSynchronizationContext.cs
- AutomationProperty.cs
- TypeDescriptor.cs
- SafeCryptoHandles.cs
- PersonalizableAttribute.cs
- MediaScriptCommandRoutedEventArgs.cs
- XmlTextWriter.cs
- ReceiveMessageRecord.cs
- Font.cs
- XPathNodeIterator.cs
- CheckBoxField.cs
- TableLayoutCellPaintEventArgs.cs
- TypeNameConverter.cs
- Utility.cs
- Accessible.cs
- followingsibling.cs
- SettingsAttributes.cs
- PhysicalFontFamily.cs
- _BaseOverlappedAsyncResult.cs
- _Connection.cs
- altserialization.cs
- ProtocolElement.cs
- Identifier.cs
- HtmlElementEventArgs.cs
- GridItemCollection.cs
- XmlNodeChangedEventManager.cs
- InfoCardSymmetricCrypto.cs
- TableLayoutPanelCellPosition.cs
- NamespaceTable.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- CompareInfo.cs
- DrawingCollection.cs
- Line.cs
- Int32AnimationUsingKeyFrames.cs
- ToolbarAUtomationPeer.cs
- Decimal.cs
- _BaseOverlappedAsyncResult.cs
- XmlBoundElement.cs
- AssemblyResourceLoader.cs