Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / InfoCardClaim.cs / 1 / InfoCardClaim.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // // Presharp uses the c# pragma mechanism to supress its warnings. // These are not recognised by the base compiler so we need to explictly // disable the following warnings. See http://winweb/cse/Tools/PREsharp/userguide/default.asp // for details. // #pragma warning disable 1634, 1691 // unknown message, unknown pragma namespace Microsoft.InfoCards { using System; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.IdentityModel.Claims; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary // This class carries the claim value and type information. Each InfoCardClaim consists // of a URI which uniquely identifies the type. A namespace specifying the grouping // it is from and also a value. // // Remarks // Currently the InfoCard system supports only this one abstraction of a claim. // More complex claims that will require more additional class abstraction may be added at a later // date. // internal class InfoCardClaim { string m_id; string m_claimValue; string m_displayTag; string m_description; // // Summary // Create an instance of the InfoCardClaim class in the uninitialized state // // Remarks // This behavior is needed to support the construction of InfoCardClaims // from a serialized binary stream. // public InfoCardClaim() { } // // Summary // Create an instance of the InfoCardClaim class and initialize // it using the specified arguments. // public InfoCardClaim( string id, string value ) :this( id, value, null, null ) { } // // Summary // Create an instance of the InfoCardClaim class and initialize // it using the specified arguments. // public InfoCardClaim( string id, string value, string description, string displaytag ) { if( String.IsNullOrEmpty( id ) ) { throw IDT.ThrowHelperArgumentNull( "id" ); } m_id = id; m_claimValue = value; m_displayTag = displaytag; m_description = description; } public string Id { get { return m_id; } } public string Value { get { return m_claimValue; } set { m_claimValue = value; } } public string DisplayTag { get { return m_displayTag; } } public string Description { get { return m_description; } } // // Summary // Creates a string containing the value of the Claim. // public override string ToString() { return m_claimValue; } // // Summary // Throws if claim entry has not been populated. // public void ThrowIfNotComplete() { bool isComplete = ( !String.IsNullOrEmpty( m_id ) ); if( !isComplete ) { throw IDT.ThrowHelperError( new SerializationIncompleteException( this.GetType() ) ); } } // // Summary // This method serializes the claim id and value into a stream // via the specified BinaryWriter. // // Remarks // This method is typically called by the InfoCardClaimCollection class // as part of it's persistence of the claims information into the // store. // // Parameters // writer - The writer to be used to serialize the id and value for the claim. // public void Serialize( BinaryWriter writer ) { ThrowIfNotComplete(); if( null == writer ) { throw IDT.ThrowHelperArgumentNull( "writer" ); } // // Write each member to binary stream // Utility.SerializeString( writer, m_id ); Utility.SerializeString( writer, m_displayTag ); Utility.SerializeString( writer, m_description ); Utility.SerializeString( writer, m_claimValue ); } // // Summary // Populates the instance with the information in the stream wrapper // by the BinaryReader provided. // // Remarks // This method is typically called by the InfoCardClaimCollection class // as part of it's construction to create each claim value. // // Parameters // reader - The reader to be used to deserialize the id and value for the claim. // public void DeSerialize( BinaryReader reader ) { m_id = Utility.DeserializeString( reader ); m_displayTag = Utility.DeserializeString( reader ); m_description = Utility.DeserializeString( reader ); m_claimValue = Utility.DeserializeString( reader ); } // // Summary // Encrypts a claim value using the specified key information // // Parameters // pinHelper - A helper used to hold the key and related info. // public void Encrypt( PinProtectionHelper pinHelper ) { UnicodeEncoding unicode = new UnicodeEncoding(); byte[] toEncrypt = unicode.GetBytes( m_claimValue ); m_claimValue = Convert.ToBase64String( pinHelper.Encrypt( toEncrypt ) ); } // // Summary // Decrypts a claim value using the specified key information. // // Parameters // pinHelper - A helper used to hold the key and related info. // public void Decrypt( PinProtectionHelper pinHelper ) { UnicodeEncoding unicode = new UnicodeEncoding(); byte[] toDecrypt = Convert.FromBase64String( m_claimValue ); m_claimValue = unicode.GetString( pinHelper.Decrypt( toDecrypt ) ); } // // Summary // Makes a deep copy of the claim // // Returns the copy // public InfoCardClaim Clone() { return new InfoCardClaim( (string) m_id.Clone(), ( String.IsNullOrEmpty( m_claimValue ) ? null : (string) m_claimValue.Clone() ), ( String.IsNullOrEmpty( m_description ) ? null : (string) m_description.Clone() ), ( String.IsNullOrEmpty( m_displayTag ) ? null : (string) m_displayTag.Clone() ) ); } } } // 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
- ColumnResult.cs
- TemplatedControlDesigner.cs
- ListItemsPage.cs
- RegexGroup.cs
- ToolStripStatusLabel.cs
- EncryptedKey.cs
- WindowsRegion.cs
- SqlAliaser.cs
- IntegerValidator.cs
- DetailsViewUpdateEventArgs.cs
- SHA1CryptoServiceProvider.cs
- Debug.cs
- BatchParser.cs
- AdapterUtil.cs
- UrlMapping.cs
- Section.cs
- SmtpDigestAuthenticationModule.cs
- VectorValueSerializer.cs
- SHA512Managed.cs
- TreeNodeBinding.cs
- ItemCheckedEvent.cs
- TableLayoutStyleCollection.cs
- AuthenticationServiceManager.cs
- BitmapCache.cs
- PreviewPageInfo.cs
- WhitespaceRuleLookup.cs
- RelationshipFixer.cs
- OleDbPropertySetGuid.cs
- EdgeModeValidation.cs
- ZoneMembershipCondition.cs
- NativeObjectSecurity.cs
- AspNetSynchronizationContext.cs
- FusionWrap.cs
- IsolatedStorage.cs
- GraphicsState.cs
- SQLMoneyStorage.cs
- PreviewPrintController.cs
- _StreamFramer.cs
- DynamicExpression.cs
- ControlFilterExpression.cs
- ElementMarkupObject.cs
- LayoutEditorPart.cs
- xsdvalidator.cs
- DataGridAutomationPeer.cs
- ContentPropertyAttribute.cs
- GridViewRowPresenterBase.cs
- IntSumAggregationOperator.cs
- WebPartMenu.cs
- LateBoundBitmapDecoder.cs
- HttpWebResponse.cs
- PeerIPHelper.cs
- DataControlImageButton.cs
- FigureHelper.cs
- RecipientInfo.cs
- RequestCacheValidator.cs
- isolationinterop.cs
- EncoderParameter.cs
- RegexCapture.cs
- BinaryFormatter.cs
- OutputCacheProfileCollection.cs
- AssemblyNameProxy.cs
- BamlLocalizabilityResolver.cs
- ClientBuildManager.cs
- PropertyKey.cs
- XmlSchema.cs
- SafeNativeMethods.cs
- FlowThrottle.cs
- NotifyParentPropertyAttribute.cs
- XPathArrayIterator.cs
- DiscoveryEndpoint.cs
- ReferencedType.cs
- ValueChangedEventManager.cs
- HttpCookiesSection.cs
- TextContainerChangeEventArgs.cs
- FontNameEditor.cs
- ZipIOBlockManager.cs
- CollectionViewGroupInternal.cs
- TextHintingModeValidation.cs
- Item.cs
- mansign.cs
- SerialPort.cs
- ConfigurationStrings.cs
- WindowsListViewGroup.cs
- Empty.cs
- ValidationVisibilityAttribute.cs
- EntitySetDataBindingList.cs
- InternalConfigHost.cs
- LiteralTextContainerControlBuilder.cs
- ExtensionFile.cs
- ActivityPropertyReference.cs
- WpfXamlMember.cs
- EntityDataSourceEntitySetNameItem.cs
- HttpValueCollection.cs
- GenericWebPart.cs
- ContractMapping.cs
- WebPartConnectionsConnectVerb.cs
- GridItemProviderWrapper.cs
- SchemaImporterExtension.cs
- SystemResourceKey.cs
- CompiledQueryCacheKey.cs