Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / LedgerEntryCollection.cs / 1 / LedgerEntryCollection.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.IO; using System.Security; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; using Microsoft.InfoCards.Diagnostics; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary // This class represents a collection of ledger entries // internal class LedgerEntryCollection : Dictionary{ Uri m_infoCardId; private LedgerEntryCollection() { } // // Note: // Used by tools alone. // public void Add( LedgerEntry entry ) { this[ entry.Recipient.RecipientId ] = entry; } public LedgerEntryCollection( Uri infoCardId ) { m_infoCardId = infoCardId; } // // Summary // Retrieve the collection from the store. // // Parameter // con - The store connection // public void Get( StoreConnection con ) { IDT.Assert( null != m_infoCardId, "The infocard id must be specified prior to executing this operation" ); // // Retrieve a single object from the database // ICollection rows = con.Query( QueryDetails.FullRow, new QueryParameter( SecondaryIndexDefinition.ObjectTypeIndex, (Int32)StorableObjectType.LedgerEntry ), new QueryParameter( SecondaryIndexDefinition.ParentIdIndex, GlobalId.DeriveFrom( m_infoCardId.ToString() ) ) ); if( null != rows && rows.Count > 0 ) { IDT.TraceDebug( "Found {0} ledger entries in the store.", rows.Count ); //bug in clr: foreach( DataRow row in (List )rows ) { IDT.TraceDebug( "Adding ledger entry." ); LedgerEntry le = new LedgerEntry( new MemoryStream( row.GetDataField() ), con ); this[le.Recipient.RecipientId] = le; } } } // // Summary // Serialize the collection. // // Parameter // stream - The stream to which the collection is serialized. // 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( (Int32)this.Count ); foreach( KeyValuePair pair in this ) { pair.Value.Serialize( writer ); } } // // Summary // Save the collection to the store. // // Parameter // con - The store connection // public void Save( StoreConnection con ) { IDT.Assert( null != m_infoCardId, "The infocard id must be specified prior to executing this operation" ); // // Save dirty ledger entries to the store. // foreach( KeyValuePair pair in this ) { LedgerEntry entry = pair.Value; if( entry.IsDirty ) { entry.Save( con ); } } } } } // 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
- EventProxy.cs
- MenuCommand.cs
- WindowsListViewGroup.cs
- XmlSerializerFormatAttribute.cs
- Clock.cs
- SafeNativeMethods.cs
- ProgressBar.cs
- CodeMemberField.cs
- TraceEventCache.cs
- TableLayoutSettings.cs
- EndpointDesigner.cs
- LayoutInformation.cs
- TextPointerBase.cs
- KeyToListMap.cs
- DataPagerFieldCommandEventArgs.cs
- NetMsmqBindingCollectionElement.cs
- IPEndPoint.cs
- IListConverters.cs
- Not.cs
- StorageInfo.cs
- CounterSample.cs
- DependencySource.cs
- ListBindingConverter.cs
- Vector3DAnimation.cs
- StrongName.cs
- FrameSecurityDescriptor.cs
- Roles.cs
- BevelBitmapEffect.cs
- XmlnsDictionary.cs
- ItemCheckedEvent.cs
- IList.cs
- TrackBarRenderer.cs
- SymmetricAlgorithm.cs
- SelectionProviderWrapper.cs
- ValueUtilsSmi.cs
- BindingManagerDataErrorEventArgs.cs
- CommandBindingCollection.cs
- BatchParser.cs
- EventMappingSettingsCollection.cs
- ArcSegment.cs
- XamlToRtfParser.cs
- SharedDp.cs
- InputProviderSite.cs
- DecimalMinMaxAggregationOperator.cs
- GridViewCommandEventArgs.cs
- _SecureChannel.cs
- CaseDesigner.xaml.cs
- CompilerResults.cs
- TextBlockAutomationPeer.cs
- UnsafeNativeMethods.cs
- ChangeToolStripParentVerb.cs
- SafeSecurityHelper.cs
- SafeThemeHandle.cs
- FileSystemInfo.cs
- UnmanagedMarshal.cs
- WbemProvider.cs
- SiteMapPath.cs
- RoleBoolean.cs
- FilterException.cs
- MimeWriter.cs
- ProgressBarAutomationPeer.cs
- InvalidComObjectException.cs
- IsolatedStorage.cs
- MsmqIntegrationProcessProtocolHandler.cs
- GroupItem.cs
- CollectionCodeDomSerializer.cs
- QilTargetType.cs
- COM2TypeInfoProcessor.cs
- Atom10FormatterFactory.cs
- UriSection.cs
- FlowDocument.cs
- RangeBaseAutomationPeer.cs
- TranslateTransform3D.cs
- SinglePhaseEnlistment.cs
- SimpleLine.cs
- sqlstateclientmanager.cs
- LowerCaseStringConverter.cs
- AnimationLayer.cs
- WriteableOnDemandPackagePart.cs
- DataGridViewRowEventArgs.cs
- RichTextBox.cs
- InkCanvasAutomationPeer.cs
- TablePatternIdentifiers.cs
- AttributeParameterInfo.cs
- MissingManifestResourceException.cs
- KernelTypeValidation.cs
- Expression.cs
- ExpandCollapsePattern.cs
- ValueTypeFieldReference.cs
- Crypto.cs
- _SSPISessionCache.cs
- DefaultBindingPropertyAttribute.cs
- BmpBitmapEncoder.cs
- EventlogProvider.cs
- InteropEnvironment.cs
- SystemUdpStatistics.cs
- ResXResourceSet.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- OleDbParameterCollection.cs
- Html32TextWriter.cs