Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / Configuration / TypeElement.cs / 1 / TypeElement.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Runtime.Serialization.Configuration { using System; using System.Collections.Generic; using System.Configuration; using System.Diagnostics; using System.ServiceModel.Diagnostics; using System.Security; public sealed partial class TypeElement : ConfigurationElement { public TypeElement() { } public TypeElement(string typeName) : this() { if (String.IsNullOrEmpty(typeName)) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("typeName"); } this.Type = typeName; } internal string Key { get { return this.key; } } [ConfigurationProperty(ConfigurationStrings.DefaultCollectionName, DefaultValue = null, Options = ConfigurationPropertyOptions.IsDefaultCollection)] public ParameterElementCollection Parameters { get { return (ParameterElementCollection)base[ConfigurationStrings.DefaultCollectionName]; } } protected override void Reset(ConfigurationElement parentElement) { TypeElement parent = (TypeElement)parentElement; this.key = parent.key; base.Reset(parentElement); } [ConfigurationProperty(ConfigurationStrings.Type, DefaultValue = "")] [StringValidator(MinLength = 0)] public string Type { get { return (string)base[ConfigurationStrings.Type]; } set { base[ConfigurationStrings.Type] = value; } } [ConfigurationProperty(ConfigurationStrings.Index, DefaultValue = 0)] [IntegerValidator(MinValue = 0)] public int Index { get { return (int)base[ConfigurationStrings.Index]; } set { base[ConfigurationStrings.Index] = value; } } ////// Review - loads type given name in configuration. /// since this information is used to determine whether a particular type is included as a known type, /// changes to the logic should be reviewed. /// [SecurityRequiresReview] internal Type GetType(string rootType, Type[] typeArgs) { return GetType(rootType, typeArgs, this.Type, this.Index, this.Parameters); } ////// Review - loads type given name in configuration. /// since this information is used to determine whether a particular type is included as a known type, /// changes to the logic should be reviewed. /// [SecurityRequiresReview] internal static Type GetType(string rootType, Type[] typeArgs, string type, int index, ParameterElementCollection parameters) { if (String.IsNullOrEmpty(type)) { if (typeArgs == null || index >= typeArgs.Length) { int typeArgsCount = typeArgs == null ? 0 : typeArgs.Length; if (typeArgsCount == 0) { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.KnownTypeConfigIndexOutOfBoundsZero, rootType, typeArgsCount, index)); } else { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.KnownTypeConfigIndexOutOfBounds, rootType, typeArgsCount, index)); } } return typeArgs[index]; } Type t = System.Type.GetType(type, true); if (t.IsGenericTypeDefinition) { if (parameters.Count != t.GetGenericArguments().Length) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.KnownTypeConfigGenericParamMismatch, type, t.GetGenericArguments().Length, parameters.Count)); Type[] types = new Type[parameters.Count]; for (int i = 0; i < types.Length; ++i) { types[i] = parameters[i].GetType(rootType, typeArgs); } t = t.MakeGenericType(types); } return t; } string key = Guid.NewGuid().ToString(); } } // 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
- XmlReflectionMember.cs
- ImageCreator.cs
- PersonalizationStateQuery.cs
- EntityWithKeyStrategy.cs
- WebBrowserContainer.cs
- SetMemberBinder.cs
- ProviderUtil.cs
- VirtualPath.cs
- documentsequencetextpointer.cs
- KeyNotFoundException.cs
- BackgroundFormatInfo.cs
- HtmlControlAdapter.cs
- AbstractDataSvcMapFileLoader.cs
- ItemAutomationPeer.cs
- ContactManager.cs
- ConstNode.cs
- Form.cs
- X500Name.cs
- DataGridCellItemAutomationPeer.cs
- basecomparevalidator.cs
- PrivilegeNotHeldException.cs
- EpmSourcePathSegment.cs
- Semaphore.cs
- ZipIOExtraFieldZip64Element.cs
- SslStreamSecurityElement.cs
- ProtocolsSection.cs
- COAUTHIDENTITY.cs
- QilGeneratorEnv.cs
- GrammarBuilderDictation.cs
- FileDataSourceCache.cs
- ContainerSelectorBehavior.cs
- COM2PropertyDescriptor.cs
- PriorityBindingExpression.cs
- Attributes.cs
- StructuredProperty.cs
- LabelEditEvent.cs
- PropertyGridCommands.cs
- figurelengthconverter.cs
- FileSystemWatcher.cs
- AssemblyHash.cs
- ConnectionStringsSection.cs
- Compress.cs
- PersistNameAttribute.cs
- QuaternionRotation3D.cs
- ConversionValidationRule.cs
- ServiceOperationInfoTypeConverter.cs
- HttpListenerResponse.cs
- BindingGroup.cs
- InputBinding.cs
- RadioButton.cs
- DataSet.cs
- MailBnfHelper.cs
- X509ClientCertificateCredentialsElement.cs
- ColumnClickEvent.cs
- DictionaryEntry.cs
- KnownBoxes.cs
- StagingAreaInputItem.cs
- xmlsaver.cs
- SectionInput.cs
- HtmlHead.cs
- SchemaElementLookUpTableEnumerator.cs
- EntitySqlQueryCacheEntry.cs
- SmtpFailedRecipientException.cs
- SamlAudienceRestrictionCondition.cs
- ObjectDataSourceView.cs
- XamlClipboardData.cs
- XPathScanner.cs
- ProviderConnectionPoint.cs
- ListControl.cs
- SmtpFailedRecipientsException.cs
- ProfessionalColors.cs
- SafeProcessHandle.cs
- XmlWhitespace.cs
- XmlSerializationWriter.cs
- TextRange.cs
- SupportsPreviewControlAttribute.cs
- ColorTransform.cs
- MethodExecutor.cs
- CellTreeSimplifier.cs
- ProcessProtocolHandler.cs
- SecurityDocument.cs
- BinHexDecoder.cs
- DataPagerCommandEventArgs.cs
- ToolStripRenderEventArgs.cs
- Pair.cs
- IntSecurity.cs
- ProjectedWrapper.cs
- ThreadStartException.cs
- ErrorTolerantObjectWriter.cs
- BinaryMethodMessage.cs
- StyleTypedPropertyAttribute.cs
- CriticalHandle.cs
- GradientStop.cs
- PerformanceCounter.cs
- RegexCode.cs
- GenericTextProperties.cs
- Group.cs
- SqlBooleanMismatchVisitor.cs
- CodeCatchClause.cs
- X509WindowsSecurityToken.cs