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
- OracleConnectionString.cs
- MulticastOption.cs
- ChameleonKey.cs
- NetworkInformationException.cs
- NameTable.cs
- DataGridViewSelectedCellCollection.cs
- ProfilePropertySettings.cs
- DateTimeParse.cs
- DBCommand.cs
- DataGridViewButtonColumn.cs
- TileModeValidation.cs
- GroupBox.cs
- SimpleNameService.cs
- LassoHelper.cs
- ToolStripManager.cs
- LongValidator.cs
- ResourceType.cs
- PanelStyle.cs
- ComponentCodeDomSerializer.cs
- LoggedException.cs
- TypefaceMetricsCache.cs
- XmlNode.cs
- WebBrowserPermission.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- CommandHelpers.cs
- MimeBasePart.cs
- OpCellTreeNode.cs
- GridProviderWrapper.cs
- VarRefManager.cs
- OdbcEnvironmentHandle.cs
- TypeInitializationException.cs
- Matrix3DStack.cs
- SqlOuterApplyReducer.cs
- XPathPatternParser.cs
- WindowInteractionStateTracker.cs
- SapiAttributeParser.cs
- RegexCharClass.cs
- ToolStripControlHost.cs
- GeneralTransform3DCollection.cs
- MetadataPropertyvalue.cs
- RelationshipEndMember.cs
- Invariant.cs
- ConstructorBuilder.cs
- HwndStylusInputProvider.cs
- TypeUtils.cs
- InstalledFontCollection.cs
- NamespaceDecl.cs
- XmlSchemaIdentityConstraint.cs
- SqlParameter.cs
- SecurityIdentifierElement.cs
- TextTreeRootNode.cs
- SystemWebSectionGroup.cs
- InvalidateEvent.cs
- SqlFactory.cs
- SmiXetterAccessMap.cs
- RequestCache.cs
- HttpModuleCollection.cs
- CTreeGenerator.cs
- FillRuleValidation.cs
- ThreadAttributes.cs
- ScriptingAuthenticationServiceSection.cs
- _HelperAsyncResults.cs
- OleDbConnectionFactory.cs
- DataSourceSelectArguments.cs
- GlyphTypeface.cs
- MsmqIntegrationSecurityElement.cs
- MsmqActivation.cs
- CustomAssemblyResolver.cs
- Grammar.cs
- XPathChildIterator.cs
- HttpVersion.cs
- DataGridLinkButton.cs
- DBDataPermissionAttribute.cs
- querybuilder.cs
- CodePageEncoding.cs
- ProcessingInstructionAction.cs
- DocumentsTrace.cs
- ObjectTag.cs
- GroupDescription.cs
- GeneralTransform3DGroup.cs
- ActiveXContainer.cs
- ClientUtils.cs
- SpeechRecognizer.cs
- sqlmetadatafactory.cs
- BooleanStorage.cs
- ConfigurationSectionCollection.cs
- QuaternionAnimation.cs
- BlockUIContainer.cs
- DelayedRegex.cs
- PrintPreviewGraphics.cs
- PenContext.cs
- ActivityCodeDomSerializationManager.cs
- SmtpReplyReader.cs
- CultureSpecificStringDictionary.cs
- TraceSwitch.cs
- CannotUnloadAppDomainException.cs
- UrlMappingsSection.cs
- DeviceContext.cs
- _BasicClient.cs
- CallContext.cs