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
- cache.cs
- TextServicesContext.cs
- DocumentScope.cs
- NameSpaceEvent.cs
- UpdatePanelControlTrigger.cs
- _NestedSingleAsyncResult.cs
- OleDbReferenceCollection.cs
- ListViewDeleteEventArgs.cs
- MenuItemStyle.cs
- ArcSegment.cs
- IndentTextWriter.cs
- XmlNullResolver.cs
- EncoderBestFitFallback.cs
- HtmlButton.cs
- LogicalExpr.cs
- DiscoveryClientDuplexChannel.cs
- GeometryCollection.cs
- MarkupCompilePass2.cs
- ControlIdConverter.cs
- PartialTrustValidationBehavior.cs
- graph.cs
- PrimaryKeyTypeConverter.cs
- BamlRecordReader.cs
- TabPage.cs
- FontUnitConverter.cs
- EnumConverter.cs
- DrawListViewItemEventArgs.cs
- NotifyCollectionChangedEventArgs.cs
- SerializationHelper.cs
- SafeCoTaskMem.cs
- MarkupWriter.cs
- ShaperBuffers.cs
- _BaseOverlappedAsyncResult.cs
- MethodToken.cs
- PhoneCallDesigner.cs
- PropertyItem.cs
- ProfileElement.cs
- BinaryCommonClasses.cs
- WebPartDisplayMode.cs
- WebPartDisplayModeCollection.cs
- DataBinding.cs
- PageAdapter.cs
- NavigatorOutput.cs
- EndOfStreamException.cs
- FullTextState.cs
- XmlException.cs
- MsmqTransportSecurityElement.cs
- CodeParameterDeclarationExpressionCollection.cs
- TextReader.cs
- SchemaObjectWriter.cs
- SimpleTypeResolver.cs
- Button.cs
- CustomErrorCollection.cs
- ScriptingAuthenticationServiceSection.cs
- PrivilegedConfigurationManager.cs
- HTTPNotFoundHandler.cs
- TraceContextEventArgs.cs
- basecomparevalidator.cs
- TreeView.cs
- ToolStripPanelCell.cs
- DesignerVerb.cs
- PeerSecurityHelpers.cs
- StatusBarItem.cs
- EventToken.cs
- FormView.cs
- ServiceNameCollection.cs
- Bits.cs
- RubberbandSelector.cs
- StrokeCollection2.cs
- InvalidDataContractException.cs
- FeedUtils.cs
- BreakSafeBase.cs
- EditBehavior.cs
- X509CertificateTokenFactoryCredential.cs
- NativeMethods.cs
- CompositeTypefaceMetrics.cs
- SignatureHelper.cs
- MetaModel.cs
- MetadataArtifactLoaderResource.cs
- AuthenticationModuleElementCollection.cs
- Input.cs
- AnimationLayer.cs
- SslStreamSecurityUpgradeProvider.cs
- MailBnfHelper.cs
- SoapInteropTypes.cs
- AssemblyHash.cs
- BinaryKeyIdentifierClause.cs
- ListViewItemSelectionChangedEvent.cs
- ControlBindingsCollection.cs
- Block.cs
- ASCIIEncoding.cs
- RelationshipEndCollection.cs
- BindingFormattingDialog.cs
- DockingAttribute.cs
- ContainerControl.cs
- XmlValidatingReader.cs
- Matrix3DConverter.cs
- DoubleAverageAggregationOperator.cs
- ToolStripPanelRow.cs
- ValidationManager.cs