Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / InfocardExtendedInformationCollection.cs / 1 / InfocardExtendedInformationCollection.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.Xml; using System.Collections.Generic; using System.Collections; using System.Xml.Serialization; using System.Xml.Schema; using System.IO; using System.Text; using Microsoft.InfoCards.Diagnostics; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary // Additional information contained in the card as part of xs:any // We store all this information as raw xml. At present we only store // IssuerInformation element as part of this object. In future this // object can be used to store any information which is supplied in the crd file // internal class InfocardExtendedInformationCollection : List{ const Int32 InvalidRow = 0; Uri m_infoCardId; Int32 m_rowId = InvalidRow; public InfocardExtendedInformationCollection( Uri infoCardId ) { if( null == infoCardId ) { throw IDT.ThrowHelperArgumentNull( "infoCardId" ); } m_infoCardId = infoCardId; } // // Summary // Retrieves the extended information from the store and populates the collection // with it. 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 extended information object. // public void Get( StoreConnection con ) { if( null == con ) { throw IDT.ThrowHelperArgumentNull( "con" ); } IDT.TraceDebug( "Retrieving the issuer information 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 ); if( null != row ) { Deserialize( new MemoryStream( row.GetDataField() ) ); m_rowId = row.LocalId; } } // // Summary // Serialize the InfocardExtendedInformation object // // Parameter // writer - binary stream conforming to the serialization format supported by this class. // public void Serialize( System.IO.Stream stream ) { // // Setup a BinaryWriter to serialize the bytes of each member to the provided stream // System.IO.BinaryWriter writer = new BinaryWriter( stream, Encoding.Unicode ); writer.Write( this.Count ); for( int i = 0; i < this.Count; i++ ) { this[ i ].Serialize( writer ); } } // // Summary // Deserialize the InfocardExtendedInformation object // // Parameter // reader - binary stream conforming to the serialization format supported by this class. // public void Deserialize( System.IO.Stream stream ) { System.IO.BinaryReader reader = new BinaryReader( stream, Encoding.Unicode ); int count = reader.ReadInt32(); for( int i = 0; i < count; i++ ) { InfocardExtendedInformationEntry entry = new InfocardExtendedInformationEntry(); entry.Deserialize( reader ); this.Add( entry ); } } // // Summary // Writes a serialized collection of InfocardExtendedInformation objects 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 extended information object. // public void Save( StoreConnection con ) { if( null == con ) { throw IDT.ThrowHelperArgumentNull( "con" ); } // // Write the extended information to the store associated // this collection with the infocard id specified. // IDT.TraceDebug( "Saving the claims collection..." ); IDT.TraceDebug( ToString() ); // // 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.InfocardExtendedInformation; 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 string GetIssuerInformationElement() { for( int i = 0; i < this.Count; i++ ) { XmlReader reader = InfoCardSchemas.CreateReader( this[ i ].GetXml() ); reader.Read(); if( reader.IsStartElement( XmlNames.WSIdentity07.IssuerInformation, XmlNames.WSIdentity07.Namespace ) ) { reader.Close(); return this[ i ].GetXml(); } reader.Close(); } return string.Empty; } // // Summary // Queries the store for the claims 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 claims collection 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.InfocardExtendedInformation ), 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
- ThicknessAnimationUsingKeyFrames.cs
- DataTableClearEvent.cs
- WarningException.cs
- SqlMethodCallConverter.cs
- ResourceContainerWrapper.cs
- XPathMultyIterator.cs
- PageThemeCodeDomTreeGenerator.cs
- SizeLimitedCache.cs
- Material.cs
- keycontainerpermission.cs
- ContextMarshalException.cs
- TileBrush.cs
- TransferRequestHandler.cs
- unsafeIndexingFilterStream.cs
- SerializationSectionGroup.cs
- SimpleBitVector32.cs
- XmlWellformedWriter.cs
- SafeNativeMethods.cs
- DesignerActionGlyph.cs
- validationstate.cs
- Typeface.cs
- DataPointer.cs
- NameValueFileSectionHandler.cs
- SqlGatherProducedAliases.cs
- _CookieModule.cs
- Style.cs
- ApplicationTrust.cs
- StronglyTypedResourceBuilder.cs
- CssClassPropertyAttribute.cs
- CodeAccessSecurityEngine.cs
- PolyBezierSegment.cs
- TriggerActionCollection.cs
- DbBuffer.cs
- handlecollector.cs
- SectionInput.cs
- DropShadowEffect.cs
- safex509handles.cs
- PickDesigner.xaml.cs
- DateTimePicker.cs
- RSAPKCS1SignatureFormatter.cs
- StoryFragments.cs
- IISMapPath.cs
- WebPartDisplayMode.cs
- UpdateRecord.cs
- XmlAttributes.cs
- PassportPrincipal.cs
- XmlSchemaAppInfo.cs
- ObjectDataSource.cs
- UnicastIPAddressInformationCollection.cs
- AuditLog.cs
- HtmlEncodedRawTextWriter.cs
- TextDecorations.cs
- Schema.cs
- GeometryGroup.cs
- DrawingAttributeSerializer.cs
- WebPartManagerDesigner.cs
- XamlClipboardData.cs
- DataServiceRequest.cs
- SQLBytesStorage.cs
- AnonymousIdentificationSection.cs
- ServiceDesigner.cs
- BitmapData.cs
- TextWriter.cs
- TypePresenter.xaml.cs
- ProtocolState.cs
- ISFClipboardData.cs
- EncryptedKey.cs
- CodeConstructor.cs
- DrawingAttributeSerializer.cs
- DataGridLinkButton.cs
- HtmlInputButton.cs
- AuthenticatedStream.cs
- NameNode.cs
- ZoneIdentityPermission.cs
- Misc.cs
- DateTimeSerializationSection.cs
- CrossContextChannel.cs
- SelectionRange.cs
- EventLogException.cs
- SourceItem.cs
- ToolStripGripRenderEventArgs.cs
- RevocationPoint.cs
- HyperLink.cs
- ConfigUtil.cs
- UnsafeNativeMethodsCLR.cs
- MatrixCamera.cs
- SettingsSection.cs
- SiteMapNodeItem.cs
- SchemaTableColumn.cs
- ImplicitInputBrush.cs
- ISessionStateStore.cs
- RenderOptions.cs
- AttributeQuery.cs
- Transform3DGroup.cs
- ToolStripButton.cs
- entitydatasourceentitysetnameconverter.cs
- DrawingAttributes.cs
- SessionParameter.cs
- SqlWriter.cs
- ZipIOLocalFileHeader.cs