Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / UpdateTracker.cs / 1305376 / UpdateTracker.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a class used to track updates for callbacks. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services { using System.Collections.Generic; using System.Data.Services.Providers; using System.Diagnostics; using System.Reflection; ///Provides a class used to track updates for callbacks. internal class UpdateTracker { #region Private fields. ////// A dictionary of containers mapping to the changes on those /// containers, each of which consists of an element and the /// action taken on it. /// private Dictionary> items; /// Underlying data service instance. private IDataService service; #endregion Private fields. ///Initializes a new /// underlying data source instance. private UpdateTracker(IDataService service) { this.service = service; this.items = new Dictionaryinstance. >(ReferenceEqualityComparer .Instance); } /// Fires the notification for a single action. /// Service on which methods should be invoked. /// Object to be tracked. /// Container in which object is changed. /// Action affecting target. internal static void FireNotification(IDataService service, object target, ResourceSetWrapper container, UpdateOperations action) { Debug.Assert(service != null, "service != null"); AssertActionValues(target, container); MethodInfo[] methods = container.ChangeInterceptors; if (methods != null) { object[] parameters = new object[2]; parameters[0] = target; parameters[1] = action; for (int i = 0; i < methods.Length; i++) { try { methods[i].Invoke(service.Instance, parameters); } catch (TargetInvocationException exception) { ErrorHandler.HandleTargetInvocationException(exception); throw; } } } } ////// Create a new instance of update tracker /// /// underlying data service. ////// Returns a new instance of UpdateTracker. /// internal static UpdateTracker CreateUpdateTracker(IDataService service) { return new UpdateTracker(service); } ///Fires all notifications internal void FireNotifications() { object[] parameters = new object[2]; foreach (var item in this.items) { MethodInfo[] methods = item.Key.ChangeInterceptors; Debug.Assert(methods != null, "methods != null - should not have been tracking changes to the container otherwise."); foreach (var element in item.Value) { parameters[0] = this.service.Updatable.ResolveResource(element.Key); parameters[1] = element.Value; for (int i = 0; i < methods.Length; i++) { try { methods[i].Invoke(this.service.Instance, parameters); } catch (TargetInvocationException exception) { ErrorHandler.HandleTargetInvocationException(exception); throw; } } } // Make elements elegible for garbage collection. item.Value.Clear(); } // Make dictionary elegible for garbage collection. this.items = null; } ////// Tracks the specified /// Object to be tracked. /// Container in which object is changed. /// Action affecting target. ///for a /// given on the . /// /// If internal void TrackAction(object target, ResourceSetWrapper container, UpdateOperations action) { AssertActionValues(target, container); Debug.Assert(this.items != null, "this.items != null - otherwise FireNotification has already been called"); // If it won't be necessary for us to fire authorizatio methods, // skip tracking altogether. if (container.ChangeInterceptors == null) { return; } // Get the container for which the change has taken place. Dictionarywas already being tracked, the actions are OR'ed together. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ParamArrayAttribute.cs
- BulletedListDesigner.cs
- CollectionViewProxy.cs
- sqlser.cs
- HideDisabledControlAdapter.cs
- HtmlUtf8RawTextWriter.cs
- ApplicationHost.cs
- SeekStoryboard.cs
- AdditionalEntityFunctions.cs
- EpmCustomContentDeSerializer.cs
- XmlAttributeAttribute.cs
- ListViewItem.cs
- CompilerInfo.cs
- ModuleBuilder.cs
- AliasedSlot.cs
- LineServicesCallbacks.cs
- CngAlgorithmGroup.cs
- ConfigXmlWhitespace.cs
- AsymmetricSecurityProtocol.cs
- KnownTypesHelper.cs
- EventData.cs
- OptimalTextSource.cs
- XsltException.cs
- XamlSerializer.cs
- IsolationInterop.cs
- CheckBoxList.cs
- MultiSelector.cs
- BufferedReadStream.cs
- UriSectionReader.cs
- XmlQueryStaticData.cs
- TraceSource.cs
- EventLog.cs
- HostedElements.cs
- CodeGotoStatement.cs
- OleStrCAMarshaler.cs
- ToolStripDropDownItemDesigner.cs
- UnmanagedMemoryStreamWrapper.cs
- XmlSerializer.cs
- MessageBox.cs
- FontWeight.cs
- IisTraceListener.cs
- DbDataReader.cs
- KeyedHashAlgorithm.cs
- SHA512Managed.cs
- OutArgumentConverter.cs
- AstTree.cs
- DateTimeParse.cs
- ChainOfResponsibility.cs
- ImportDesigner.xaml.cs
- AddingNewEventArgs.cs
- Errors.cs
- HttpCacheParams.cs
- FileDialogPermission.cs
- ThrowHelper.cs
- SynchronizedDispatch.cs
- ProxyWebPartManager.cs
- ArrayElementGridEntry.cs
- HttpCacheParams.cs
- Trace.cs
- Trace.cs
- SchemaElementDecl.cs
- ButtonField.cs
- OleDbReferenceCollection.cs
- SqlRowUpdatingEvent.cs
- ConfigurationElement.cs
- TextFormatter.cs
- WebPartDisplayModeCancelEventArgs.cs
- Interlocked.cs
- FloaterParaClient.cs
- ArgumentNullException.cs
- SqlDataSourceView.cs
- TreeNodeCollection.cs
- RewritingSimplifier.cs
- TextServicesProperty.cs
- WebServiceResponseDesigner.cs
- UdpContractFilterBehavior.cs
- _IPv4Address.cs
- WmlImageAdapter.cs
- SystemIPGlobalProperties.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- Point3DCollection.cs
- Animatable.cs
- assertwrapper.cs
- ClientSession.cs
- documentsequencetextcontainer.cs
- dataprotectionpermissionattribute.cs
- StdRegProviderWrapper.cs
- NativeMethods.cs
- HighlightVisual.cs
- MutexSecurity.cs
- ProtocolsConfigurationHandler.cs
- Attributes.cs
- BooleanFunctions.cs
- NamedPermissionSet.cs
- DictionaryEditChange.cs
- BitmapSource.cs
- CatalogZoneBase.cs
- GenerateHelper.cs
- IntSecurity.cs
- MsdtcClusterUtils.cs