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
- AsymmetricSignatureFormatter.cs
- LeaseManager.cs
- LogManagementAsyncResult.cs
- SelectedGridItemChangedEvent.cs
- XmlBinaryWriter.cs
- DynamicField.cs
- TraceLevelStore.cs
- CryptoApi.cs
- ThrowHelper.cs
- HScrollProperties.cs
- SmtpCommands.cs
- C14NUtil.cs
- DescendentsWalker.cs
- HttpContextServiceHost.cs
- RowUpdatedEventArgs.cs
- DataGridViewCellStyleEditor.cs
- DataGridViewRowConverter.cs
- Command.cs
- ArraySegment.cs
- RequestSecurityTokenResponseCollection.cs
- TypeContext.cs
- ObjectQuery.cs
- BamlLocalizationDictionary.cs
- VirtualizingStackPanel.cs
- Int16AnimationUsingKeyFrames.cs
- UpWmlPageAdapter.cs
- EllipticalNodeOperations.cs
- WindowsRichEditRange.cs
- LZCodec.cs
- NamedPipeConnectionPoolSettings.cs
- WebPartMenu.cs
- OpacityConverter.cs
- IArgumentProvider.cs
- XsdCachingReader.cs
- ScrollItemPattern.cs
- ComponentDispatcherThread.cs
- ListCollectionView.cs
- ApplicationManager.cs
- BuildManagerHost.cs
- LassoHelper.cs
- ObjectConverter.cs
- QilInvoke.cs
- WebScriptMetadataMessage.cs
- Variable.cs
- WebPartChrome.cs
- SystemUdpStatistics.cs
- NameTable.cs
- processwaithandle.cs
- TcpAppDomainProtocolHandler.cs
- Journal.cs
- FileEnumerator.cs
- CommonGetThemePartSize.cs
- SizeChangedEventArgs.cs
- CompressStream.cs
- LabelDesigner.cs
- Typography.cs
- WeakRefEnumerator.cs
- RoutedEventValueSerializer.cs
- SQLInt32Storage.cs
- DataGridViewColumnCollection.cs
- Selector.cs
- Calendar.cs
- X509UI.cs
- Misc.cs
- UIHelper.cs
- RtfControlWordInfo.cs
- AdCreatedEventArgs.cs
- _SingleItemRequestCache.cs
- StringDictionaryCodeDomSerializer.cs
- ToolStripItem.cs
- EventBuilder.cs
- ITextView.cs
- PageParserFilter.cs
- LinqDataSourceView.cs
- TableRowCollection.cs
- ValidationPropertyAttribute.cs
- ListViewHitTestInfo.cs
- DataServiceKeyAttribute.cs
- SqlServices.cs
- ComEventsMethod.cs
- PropertyValueChangedEvent.cs
- TextDecoration.cs
- TableItemProviderWrapper.cs
- RuleSettingsCollection.cs
- EncodingTable.cs
- XmlHierarchyData.cs
- StreamHelper.cs
- InlineObject.cs
- ContentType.cs
- PointCollectionConverter.cs
- _HelperAsyncResults.cs
- ObjectDataSourceDisposingEventArgs.cs
- SecurityTokenResolver.cs
- SerialPort.cs
- ImageButton.cs
- TextServicesLoader.cs
- DynamicValueConverter.cs
- TraceContext.cs
- StrokeSerializer.cs
- ContentHostHelper.cs