Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / RPIdentityRequirement.cs / 1 / RPIdentityRequirement.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.IO; using System.Xml; using Microsoft.InfoCards.Diagnostics; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary // This class contains the RP identity requirement of the card // // Remarks // The parentId index is populated with the URI of the InfoCard associated with this set of PII. // internal class RPIdentityRequirement { const Int32 InvalidRow = 0; Uri m_infoCardId; Int32 m_rowId = InvalidRow; bool m_RPIdentityRequirement = false; // // Summary // Creates an uninitialized instance of the RPIdentityRequirement. // // Remarks // This behavior is not supported and is thus declared as private. // private RPIdentityRequirement() { } // // Summary // Creates a new instance of the RPIdentityRequirement associated with the // InfoCard whose Id is specified. // // Parameters // infoCardId - Id of the owning InfoCard // public RPIdentityRequirement( Uri infoCardId, bool RPIdentityRequirement ) : this() { if( null == infoCardId ) { throw IDT.ThrowHelperArgumentNull( "infoCardId" ); } m_infoCardId = infoCardId; m_RPIdentityRequirement = RPIdentityRequirement; } // // Summary // Retrieves the RPIdentityRequirement from the store. // The InfoCard Id specified in the constructor is used as the parent key. // // Parameters // con - Connection to the store to be used to retrieve the object. // public void Get( StoreConnection con ) { if( null == con ) { throw IDT.ThrowHelperArgumentNull( "con" ); } IDT.TraceDebug( "Retrieving the claims for infocard({0})", m_infoCardId ); // // Find the row for the object from the database, returns null if not exists // DataRow row = TryGetRow( con, QueryDetails.FullRow ); // // A RPIdentityRequirement object does not necessarily exist for this infocard // if( null != row ) { // // Populate the claims from the byte array // Deserialize( new MemoryStream( row.GetDataField() ) ); // // Update the row id from the database // m_rowId = row.LocalId; } } // // Summary // Writes all of the RPIdentityRequirement into a binary stream in an unordered sequence. // // Parameters // stream - Stream that will receive the byte stream of each claim. // public void Serialize( Stream stream ) { // // Setup a BinaryWriter to serialize the bytes of each member to the provided stream // BinaryWriter writer = new BinaryWriter( stream, System.Text.Encoding.Unicode ); writer.Write( m_RPIdentityRequirement ); } // // Summary // Reads a RPIdentityRequirement. // // Parameters // stream - Stream that will provide the byte stream of claims. // public void Deserialize( Stream stream ) { BinaryReader reader = new InfoCardBinaryReader( stream, System.Text.Encoding.Unicode ); m_RPIdentityRequirement = reader.ReadBoolean(); } // // Summary // Writes a serialized RPIdentityRequirement object to the store. // // Remarks // The parentId index field is set to the Id of the associated InfoCard. // // Parameters // con - Connection to the store to be used to store the RPIdentityRequirement. // public void Save( StoreConnection con ) { if( null == con ) { throw IDT.ThrowHelperArgumentNull( "con" ); } // // Write the RPIdentityRequirement to the store associated // this collection with the infocard id specified. // IDT.TraceDebug( "Saving the RPIdentityRequirement..." ); // // Try and get the database header information to // see if this is an insert or update. // // Note: The datafield is not part of the projection // in order to avoid unnecessary decryption. // DataRow row = TryGetRow( con, QueryDetails.FullHeader ); if( null == row ) { row = new DataRow(); row.ObjectType = (Int32)StorableObjectType.RPIdentityRequirement; row.GlobalId = Guid.NewGuid(); } // // Populate the parentId index field // row.SetIndexValue( SecondaryIndexDefinition.ParentIdIndex, GlobalId.DeriveFrom( m_infoCardId.ToString() ) ); // // Populate the data object // MemoryStream ms = new MemoryStream(); Serialize( ms ); row.SetDataField( ms.ToArray() ); // // Save the row to the database // con.Save( row ); // // Update the row id in the object in case // this was an insert. // m_rowId = row.LocalId; } public bool StrongIdentityRequired { get { return m_RPIdentityRequirement; } set { m_RPIdentityRequirement = value; } } // // Summary // Queries the store for the RPIdentityRequirement object associated with the InfoCard Id // currently in m_infoCardId. // // Remarks // This function will return null if no object is found in the store. // // Parameters // con - Connection to the store to be used to find the RPIdentityRequirement object. // details - The projection of the store information to be returned. // protected DataRow TryGetRow( StoreConnection con, QueryDetails details ) { IDT.Assert( null != m_infoCardId, "null infocard id" ); // // Retrieve a single object from the database // DataRow row = con.GetSingleRow( details, new QueryParameter( SecondaryIndexDefinition.ObjectTypeIndex, (Int32)StorableObjectType.RPIdentityRequirement ), new QueryParameter( SecondaryIndexDefinition.ParentIdIndex, GlobalId.DeriveFrom( m_infoCardId.ToString() ) ) ); return row; } } } // 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
- DataGridItem.cs
- TcpChannelHelper.cs
- TextClipboardData.cs
- FormsIdentity.cs
- DesignerContextDescriptor.cs
- CreateUserWizardStep.cs
- PerfService.cs
- Translator.cs
- DocumentReferenceCollection.cs
- UInt64Storage.cs
- MailSettingsSection.cs
- DbConnectionFactory.cs
- SettingsSavedEventArgs.cs
- SafeLibraryHandle.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- CheckBoxFlatAdapter.cs
- ConfigurationStrings.cs
- RangeValueProviderWrapper.cs
- PolicyLevel.cs
- RuleSettings.cs
- SQLInt16.cs
- DateTimeConstantAttribute.cs
- ObjectListFieldCollection.cs
- ScrollProperties.cs
- IisTraceListener.cs
- StrongTypingException.cs
- CacheAxisQuery.cs
- MetadataImporter.cs
- Errors.cs
- AccessedThroughPropertyAttribute.cs
- ToolboxDataAttribute.cs
- XmlBindingWorker.cs
- MaskedTextBoxTextEditorDropDown.cs
- ListViewCommandEventArgs.cs
- CompressedStack.cs
- IPipelineRuntime.cs
- TextOnlyOutput.cs
- GestureRecognitionResult.cs
- StorageTypeMapping.cs
- BitmapImage.cs
- Semaphore.cs
- PasswordPropertyTextAttribute.cs
- OutOfProcStateClientManager.cs
- WindowsSolidBrush.cs
- OutArgumentConverter.cs
- DelegateHelpers.cs
- Relationship.cs
- Span.cs
- ListViewUpdateEventArgs.cs
- StatusBarItem.cs
- Mappings.cs
- PositiveTimeSpanValidatorAttribute.cs
- ImageDrawing.cs
- XmlHierarchicalEnumerable.cs
- InlinedAggregationOperatorEnumerator.cs
- TraceUtils.cs
- OleDbErrorCollection.cs
- TreeChangeInfo.cs
- PropertyValueChangedEvent.cs
- FloatAverageAggregationOperator.cs
- SqlBulkCopyColumnMappingCollection.cs
- GuidelineCollection.cs
- ObjectHandle.cs
- RefreshPropertiesAttribute.cs
- CachingHintValidation.cs
- ServicePointManager.cs
- IPipelineRuntime.cs
- PageContent.cs
- SqlSelectStatement.cs
- SecurityException.cs
- XPathPatternBuilder.cs
- AdPostCacheSubstitution.cs
- CompositeFontFamily.cs
- BackoffTimeoutHelper.cs
- QuaternionConverter.cs
- DeclaredTypeValidator.cs
- SoapReflectionImporter.cs
- VirtualPathProvider.cs
- EventData.cs
- CultureSpecificStringDictionary.cs
- WindowsScroll.cs
- ObjectParameter.cs
- BindingContext.cs
- GridProviderWrapper.cs
- QueuePathDialog.cs
- InternalConfigHost.cs
- SchemaDeclBase.cs
- DistinctQueryOperator.cs
- RNGCryptoServiceProvider.cs
- StylusDownEventArgs.cs
- CalendarDataBindingHandler.cs
- COM2AboutBoxPropertyDescriptor.cs
- CodeMemberProperty.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- ViewSimplifier.cs
- ReliabilityContractAttribute.cs
- AutomationEvent.cs
- XhtmlBasicCalendarAdapter.cs
- DBConnectionString.cs
- FloaterParaClient.cs