Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / SecurityAttributeGenerationHelper.cs / 1 / SecurityAttributeGenerationHelper.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System.CodeDom; using System.Xml; static class SecurityAttributeGenerationHelper { public static CodeAttributeDeclaration FindOrCreateAttributeDeclaration(CodeAttributeDeclarationCollection attributes) where T : Attribute { if (attributes == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("attributes"); CodeTypeReference refT = new CodeTypeReference(typeof(T)); foreach (CodeAttributeDeclaration attribute in attributes) if (attribute.AttributeType.BaseType == refT.BaseType) return attribute; CodeAttributeDeclaration result = new CodeAttributeDeclaration(refT); attributes.Add(result); return result; } public static void CreateOrOverridePropertyDeclaration (CodeAttributeDeclaration attribute, string propertyName, V value) { if (attribute == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("attribute"); if (propertyName == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("propertyName"); CodeExpression newValue; if (value is TimeSpan) newValue = new CodeObjectCreateExpression( typeof(TimeSpan), new CodePrimitiveExpression(((TimeSpan)(object)value).Ticks)); else if (value is Enum) newValue = new CodeFieldReferenceExpression( new CodeTypeReferenceExpression(typeof(V)), ((object)value).ToString()); else newValue = new CodePrimitiveExpression((object)value); CodeAttributeArgument attributeProperty = TryGetAttributeProperty(attribute, propertyName); if (attributeProperty == null) { attributeProperty = new CodeAttributeArgument(propertyName, newValue); attribute.Arguments.Add(attributeProperty); } else attributeProperty.Value = newValue; } public static CodeAttributeArgument TryGetAttributeProperty(CodeAttributeDeclaration attribute, string propertyName) { if (attribute == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("attribute"); if (propertyName == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("propertyName"); foreach (CodeAttributeArgument argument in attribute.Arguments) if (argument.Name == propertyName) return argument; return null; } } } // 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
- RegexCaptureCollection.cs
- SiteMapHierarchicalDataSourceView.cs
- WebPartTracker.cs
- QuaternionIndependentAnimationStorage.cs
- DispatchOperationRuntime.cs
- PackageRelationshipSelector.cs
- IntPtr.cs
- CompilerState.cs
- FileUtil.cs
- CompareInfo.cs
- GuidelineCollection.cs
- WebControl.cs
- ReaderContextStackData.cs
- SequenceFullException.cs
- remotingproxy.cs
- MobileControlsSectionHandler.cs
- Line.cs
- WebPartActionVerb.cs
- PeerNameRecordCollection.cs
- DataContractSerializer.cs
- AxisAngleRotation3D.cs
- RightsManagementEncryptedStream.cs
- SoapReflectionImporter.cs
- ModuleConfigurationInfo.cs
- BoundField.cs
- RowParagraph.cs
- CorrelationManager.cs
- InfoCardArgumentException.cs
- EntitySet.cs
- ZipIOCentralDirectoryFileHeader.cs
- DataKeyArray.cs
- PenLineJoinValidation.cs
- TransactionScope.cs
- SetStoryboardSpeedRatio.cs
- DispatcherOperation.cs
- FontUnit.cs
- FocusChangedEventArgs.cs
- DLinqAssociationProvider.cs
- HandleRef.cs
- EntityExpressionVisitor.cs
- SQLInt64.cs
- SocketException.cs
- FloaterParaClient.cs
- HtmlDocument.cs
- SmtpLoginAuthenticationModule.cs
- MarkupCompilePass2.cs
- VerificationException.cs
- MemberProjectedSlot.cs
- Sql8ExpressionRewriter.cs
- InputQueueChannelAcceptor.cs
- SafeSecurityHandles.cs
- XomlCompilerResults.cs
- SHA512Managed.cs
- ContextBase.cs
- HtmlInputFile.cs
- XmlAutoDetectWriter.cs
- RijndaelManaged.cs
- ProxyAttribute.cs
- IODescriptionAttribute.cs
- AxisAngleRotation3D.cs
- InternalCache.cs
- RangeValuePatternIdentifiers.cs
- WebEvents.cs
- Int32AnimationUsingKeyFrames.cs
- AddInServer.cs
- GridViewCommandEventArgs.cs
- MetaModel.cs
- WebPartZoneCollection.cs
- InvalidFilterCriteriaException.cs
- DropShadowBitmapEffect.cs
- GridViewRow.cs
- TextServicesManager.cs
- ActivityMarkupSerializer.cs
- SourceFileBuildProvider.cs
- TypeGeneratedEventArgs.cs
- Number.cs
- StructuralType.cs
- ClientOperationFormatterProvider.cs
- QueryRewriter.cs
- QueryComponents.cs
- SQLInt64.cs
- EventSource.cs
- DocumentViewerBaseAutomationPeer.cs
- GridViewCommandEventArgs.cs
- Int32RectValueSerializer.cs
- UIntPtr.cs
- XmlSchemaInclude.cs
- SingleAnimationBase.cs
- PathParser.cs
- ObjectStateFormatter.cs
- PolicyStatement.cs
- UInt16Storage.cs
- Oci.cs
- XmlWellformedWriter.cs
- LinqDataSourceContextData.cs
- ClaimTypeRequirement.cs
- NameValueFileSectionHandler.cs
- AutoGeneratedField.cs
- XmlLanguage.cs
- Screen.cs