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
- DbUpdateCommandTree.cs
- DataGridRow.cs
- HtmlInputText.cs
- ProviderUtil.cs
- XmlSchemaAnyAttribute.cs
- MarshalByValueComponent.cs
- SpeechRecognizer.cs
- RectValueSerializer.cs
- XmlFormatMapping.cs
- Monitor.cs
- DataBinding.cs
- PointCollection.cs
- PersianCalendar.cs
- StickyNoteHelper.cs
- KnownAssemblyEntry.cs
- HttpCacheVaryByContentEncodings.cs
- ReflectTypeDescriptionProvider.cs
- ActionItem.cs
- UInt16Converter.cs
- TraceUtility.cs
- _LoggingObject.cs
- ExtentKey.cs
- PrintPreviewControl.cs
- ValidatorCompatibilityHelper.cs
- FormattedText.cs
- SynchronizedPool.cs
- BinaryNode.cs
- ImportContext.cs
- IMembershipProvider.cs
- SoapTypeAttribute.cs
- ToolbarAUtomationPeer.cs
- CultureSpecificStringDictionary.cs
- shaperfactoryquerycachekey.cs
- ZipIOExtraField.cs
- BindUriHelper.cs
- HttpDictionary.cs
- DBCommandBuilder.cs
- FixUpCollection.cs
- KeyedCollection.cs
- ProfileProvider.cs
- XomlDesignerLoader.cs
- FixedBufferAttribute.cs
- FunctionParameter.cs
- AccessText.cs
- HatchBrush.cs
- XMLSyntaxException.cs
- Separator.cs
- ReachSerializationUtils.cs
- GeneralTransform3D.cs
- DataGridViewColumn.cs
- HttpHandlerAction.cs
- ContentPlaceHolder.cs
- ChannelAcceptor.cs
- printdlgexmarshaler.cs
- InvalidWMPVersionException.cs
- DesignColumn.cs
- FlowDocumentReader.cs
- FontUnitConverter.cs
- StylusButton.cs
- CodeTryCatchFinallyStatement.cs
- HeaderedContentControl.cs
- FlowDocumentPageViewerAutomationPeer.cs
- CalendarDesigner.cs
- DeferredElementTreeState.cs
- SecurityTokenProviderContainer.cs
- ViewGenResults.cs
- Registration.cs
- DefaultValueTypeConverter.cs
- safemediahandle.cs
- IconBitmapDecoder.cs
- ITextView.cs
- UniqueEventHelper.cs
- CommandConverter.cs
- PermissionListSet.cs
- PartialCachingAttribute.cs
- Stacktrace.cs
- HtmlControlPersistable.cs
- PingReply.cs
- WorkflowTransactionService.cs
- OleDbDataAdapter.cs
- ObjectListShowCommandsEventArgs.cs
- ConstNode.cs
- DataControlPagerLinkButton.cs
- ISAPIWorkerRequest.cs
- MenuItemStyle.cs
- BitmapEffectState.cs
- ClientSession.cs
- ArrayWithOffset.cs
- StyleXamlParser.cs
- SwitchAttribute.cs
- ScrollContentPresenter.cs
- ProxyGenerator.cs
- MailMessageEventArgs.cs
- ContextDataSourceView.cs
- ValidatingPropertiesEventArgs.cs
- ADMembershipProvider.cs
- EntityViewContainer.cs
- AutomationAttributeInfo.cs
- QueueProcessor.cs
- DynamicPropertyReader.cs