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
- SafeEventLogWriteHandle.cs
- OperatingSystem.cs
- Msec.cs
- XmlSchemaType.cs
- DockPanel.cs
- InstanceDescriptor.cs
- DependencyPropertyConverter.cs
- recordstate.cs
- SelectionEditingBehavior.cs
- MappingSource.cs
- Schema.cs
- ByteKeyFrameCollection.cs
- WsdlInspector.cs
- WinFormsComponentEditor.cs
- SubclassTypeValidator.cs
- BasicKeyConstraint.cs
- DirectoryNotFoundException.cs
- AdapterDictionary.cs
- ObjectDisposedException.cs
- XPathNodeList.cs
- SecurityTraceRecordHelper.cs
- RemoteWebConfigurationHostStream.cs
- COM2AboutBoxPropertyDescriptor.cs
- DataList.cs
- EmptyControlCollection.cs
- Helpers.cs
- Triangle.cs
- CatalogPartCollection.cs
- RawStylusInputCustomData.cs
- ComponentChangingEvent.cs
- TextContainerChangeEventArgs.cs
- ScriptingProfileServiceSection.cs
- SqlUdtInfo.cs
- PerspectiveCamera.cs
- HtmlTitle.cs
- ZipFileInfo.cs
- ClusterRegistryConfigurationProvider.cs
- ToolStripGripRenderEventArgs.cs
- SqlCommand.cs
- Int32Animation.cs
- ErrorHandler.cs
- OrderedDictionary.cs
- ZipFileInfoCollection.cs
- SqlFacetAttribute.cs
- CreatingCookieEventArgs.cs
- ResolveNameEventArgs.cs
- SimpleBitVector32.cs
- ExpressionCopier.cs
- IntranetCredentialPolicy.cs
- CommandHelpers.cs
- TextEditorDragDrop.cs
- serverconfig.cs
- Stackframe.cs
- WebMessageEncodingElement.cs
- ReachIDocumentPaginatorSerializerAsync.cs
- FontInfo.cs
- RadioButtonBaseAdapter.cs
- Propagator.cs
- InnerItemCollectionView.cs
- GetPageCompletedEventArgs.cs
- TableLayoutPanel.cs
- ErrorFormatter.cs
- DataGridSortingEventArgs.cs
- XPathNodePointer.cs
- Descriptor.cs
- WebBrowserEvent.cs
- ClientBuildManagerCallback.cs
- BasicBrowserDialog.cs
- Grant.cs
- BinaryFormatterWriter.cs
- HMACSHA512.cs
- Profiler.cs
- EventLogEntryCollection.cs
- DispatcherObject.cs
- _IPv6Address.cs
- MaskedTextProvider.cs
- InternalResources.cs
- ExpressionEvaluator.cs
- TextCompositionManager.cs
- ConditionalBranch.cs
- TextFindEngine.cs
- UpdateTracker.cs
- mediapermission.cs
- CaseInsensitiveHashCodeProvider.cs
- Matrix.cs
- StructuralObject.cs
- ComponentEditorForm.cs
- sqlser.cs
- DesignTimeData.cs
- XmlHierarchicalEnumerable.cs
- MimeReturn.cs
- CodeExpressionCollection.cs
- WindowsPrincipal.cs
- ListItemParagraph.cs
- ReachDocumentReferenceCollectionSerializer.cs
- UserControlBuildProvider.cs
- CommentEmitter.cs
- EnumerableCollectionView.cs
- CodeNamespace.cs
- CharEntityEncoderFallback.cs