Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Model / ModelServiceImpl.cs / 1305376 / ModelServiceImpl.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Presentation.Model { using System.Collections.Generic; using System.Diagnostics; using System.Activities.Presentation.Services; using System.Runtime; // This is the implementaion of the ModelService, this is published by the ModelTreeManager // on the editingContext. This is just a facade to the modelTreemanager methods. class ModelServiceImpl : ModelService { ModelTreeManager modelTreeManager; public ModelServiceImpl(ModelTreeManager modelTreeManager) { if (modelTreeManager == null) { throw FxTrace.Exception.AsError( new ArgumentNullException("modelTreeManager")); } this.modelTreeManager = modelTreeManager; } public override event EventHandlerModelChanged; public override ModelItem Root { get { return modelTreeManager.Root; } } public override IEnumerable Find(ModelItem startingItem, Predicate match) { return modelTreeManager.Find(startingItem, match, false); } public override IEnumerable Find(ModelItem startingItem, Type type) { if (startingItem == null) { throw FxTrace.Exception.AsError( new ArgumentNullException("startingItem")); } if (type == null) { throw FxTrace.Exception.AsError( new ArgumentNullException("type")); } Fx.Assert(!type.IsValueType, "hmm why would some one search for modelitems for value types?"); return modelTreeManager.Find(startingItem, delegate(Type modelItemType) { return type.IsAssignableFrom(modelItemType); }, false); } public override ModelItem FromName(ModelItem scope, string name, StringComparison comparison) { // The workflow component model does not implement a unique named activity object right now // so we cannot support this feature. throw FxTrace.Exception.AsError( new NotSupportedException()); } internal void OnModelItemAdded(ModelItem modelItem) { Fx.Assert(modelItem != null, "modelItem should not be null"); if (ModelChanged != null) { Fx.Assert(modelItem != null, "trying to add empty model item"); List modelItemsAdded = new List (1); modelItemsAdded.Add(modelItem); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(modelItemsAdded, null, null)); modelTreeManager.SyncModelAndText(); } } internal void OnModelItemRemoved(ModelItem modelItem) { Fx.Assert(modelItem != null, "modelItem should not be null"); if (ModelChanged != null) { List modelItemsRemoved = new List (1); modelItemsRemoved.Add(modelItem); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, modelItemsRemoved, null)); modelTreeManager.SyncModelAndText(); } } internal void OnModelItemsRemoved(IEnumerable modelItems) { Fx.Assert(modelItems != null, "modelItem should not be null"); if (ModelChanged != null) { List modelItemsRemoved = new List (); modelItemsRemoved.AddRange(modelItems); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, modelItemsRemoved, null)); modelTreeManager.SyncModelAndText(); } } internal void OnModelPropertyChanged(ModelProperty property) { Fx.Assert(property != null,"property cannot be null"); if (ModelChanged != null) { List propertiesChanged = new List (1); propertiesChanged.Add(property); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, null, propertiesChanged)); modelTreeManager.SyncModelAndText(); } } protected override ModelItem CreateItem(object instance) { return modelTreeManager.CreateModelItem(null, instance); } protected override ModelItem CreateItem(Type itemType, CreateOptions options, params object[] arguments) { Object instance = Activator.CreateInstance(itemType, arguments); return modelTreeManager.CreateModelItem(null, instance); } protected override ModelItem CreateStaticMemberItem(Type type, string memberName) { throw FxTrace.Exception.AsError( new NotSupportedException()); } internal ModelItem WrapAsModelItem(object instance) { return CreateItem(instance); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Presentation.Model { using System.Collections.Generic; using System.Diagnostics; using System.Activities.Presentation.Services; using System.Runtime; // This is the implementaion of the ModelService, this is published by the ModelTreeManager // on the editingContext. This is just a facade to the modelTreemanager methods. class ModelServiceImpl : ModelService { ModelTreeManager modelTreeManager; public ModelServiceImpl(ModelTreeManager modelTreeManager) { if (modelTreeManager == null) { throw FxTrace.Exception.AsError( new ArgumentNullException("modelTreeManager")); } this.modelTreeManager = modelTreeManager; } public override event EventHandler ModelChanged; public override ModelItem Root { get { return modelTreeManager.Root; } } public override IEnumerable Find(ModelItem startingItem, Predicate match) { return modelTreeManager.Find(startingItem, match, false); } public override IEnumerable Find(ModelItem startingItem, Type type) { if (startingItem == null) { throw FxTrace.Exception.AsError( new ArgumentNullException("startingItem")); } if (type == null) { throw FxTrace.Exception.AsError( new ArgumentNullException("type")); } Fx.Assert(!type.IsValueType, "hmm why would some one search for modelitems for value types?"); return modelTreeManager.Find(startingItem, delegate(Type modelItemType) { return type.IsAssignableFrom(modelItemType); }, false); } public override ModelItem FromName(ModelItem scope, string name, StringComparison comparison) { // The workflow component model does not implement a unique named activity object right now // so we cannot support this feature. throw FxTrace.Exception.AsError( new NotSupportedException()); } internal void OnModelItemAdded(ModelItem modelItem) { Fx.Assert(modelItem != null, "modelItem should not be null"); if (ModelChanged != null) { Fx.Assert(modelItem != null, "trying to add empty model item"); List modelItemsAdded = new List (1); modelItemsAdded.Add(modelItem); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(modelItemsAdded, null, null)); modelTreeManager.SyncModelAndText(); } } internal void OnModelItemRemoved(ModelItem modelItem) { Fx.Assert(modelItem != null, "modelItem should not be null"); if (ModelChanged != null) { List modelItemsRemoved = new List (1); modelItemsRemoved.Add(modelItem); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, modelItemsRemoved, null)); modelTreeManager.SyncModelAndText(); } } internal void OnModelItemsRemoved(IEnumerable modelItems) { Fx.Assert(modelItems != null, "modelItem should not be null"); if (ModelChanged != null) { List modelItemsRemoved = new List (); modelItemsRemoved.AddRange(modelItems); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, modelItemsRemoved, null)); modelTreeManager.SyncModelAndText(); } } internal void OnModelPropertyChanged(ModelProperty property) { Fx.Assert(property != null,"property cannot be null"); if (ModelChanged != null) { List propertiesChanged = new List (1); propertiesChanged.Add(property); ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, null, propertiesChanged)); modelTreeManager.SyncModelAndText(); } } protected override ModelItem CreateItem(object instance) { return modelTreeManager.CreateModelItem(null, instance); } protected override ModelItem CreateItem(Type itemType, CreateOptions options, params object[] arguments) { Object instance = Activator.CreateInstance(itemType, arguments); return modelTreeManager.CreateModelItem(null, instance); } protected override ModelItem CreateStaticMemberItem(Type type, string memberName) { throw FxTrace.Exception.AsError( new NotSupportedException()); } internal ModelItem WrapAsModelItem(object instance) { return CreateItem(instance); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpHandlerAction.cs
- DeadLetterQueue.cs
- SystemWebSectionGroup.cs
- GlobalEventManager.cs
- GeometryGroup.cs
- SqlDataSourceStatusEventArgs.cs
- LayoutEvent.cs
- ErasingStroke.cs
- TreeNodeClickEventArgs.cs
- EntitySqlQueryCacheKey.cs
- COMException.cs
- TextServicesPropertyRanges.cs
- SchemaObjectWriter.cs
- InertiaTranslationBehavior.cs
- WebPartZoneAutoFormat.cs
- TextEditorThreadLocalStore.cs
- SchemaConstraints.cs
- AQNBuilder.cs
- SQLCharsStorage.cs
- DataListAutoFormat.cs
- Light.cs
- RC2.cs
- StoreContentChangedEventArgs.cs
- InsufficientMemoryException.cs
- TransactionInformation.cs
- FieldNameLookup.cs
- LogWriteRestartAreaState.cs
- ResourceExpressionBuilder.cs
- VirtualPathUtility.cs
- StrokeIntersection.cs
- AssemblySettingAttributes.cs
- RuleSettingsCollection.cs
- ObjectViewListener.cs
- XmlNavigatorStack.cs
- DataSysAttribute.cs
- UrlMappingsSection.cs
- DbConnectionPool.cs
- NativeMethods.cs
- XmlMtomWriter.cs
- AccessText.cs
- ElementFactory.cs
- TdsRecordBufferSetter.cs
- InputScopeManager.cs
- SingleAnimationUsingKeyFrames.cs
- FlagsAttribute.cs
- ImageUrlEditor.cs
- PolicyChain.cs
- XmlDocumentFragment.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- MultipleViewProviderWrapper.cs
- DesignerToolboxInfo.cs
- EntityViewGenerator.cs
- TextEditorDragDrop.cs
- SharedStatics.cs
- NoClickablePointException.cs
- SqlMultiplexer.cs
- ViewStateModeByIdAttribute.cs
- WebPartMenu.cs
- RawStylusInput.cs
- ValidationContext.cs
- DataConnectionHelper.cs
- TreeWalkHelper.cs
- ZipIOModeEnforcingStream.cs
- ConfigXmlComment.cs
- TemplateControlParser.cs
- InputScopeManager.cs
- QueueProcessor.cs
- DesignTimeVisibleAttribute.cs
- SafeNativeMethods.cs
- ListBindingHelper.cs
- ParameterElementCollection.cs
- CodeAssignStatement.cs
- XamlSerializer.cs
- ToolStripDesignerUtils.cs
- XmlQueryCardinality.cs
- ExpressionParser.cs
- GridViewSortEventArgs.cs
- InputMethod.cs
- nulltextcontainer.cs
- DynamicResourceExtensionConverter.cs
- SerializationSectionGroup.cs
- ITreeGenerator.cs
- RuntimeEnvironment.cs
- Visual3D.cs
- AuthenticateEventArgs.cs
- _UriTypeConverter.cs
- FileCodeGroup.cs
- PKCS1MaskGenerationMethod.cs
- ToolStripPanelRenderEventArgs.cs
- ResumeStoryboard.cs
- ForceCopyBuildProvider.cs
- HttpResponseInternalWrapper.cs
- BaseCollection.cs
- HelpInfo.cs
- DirectoryInfo.cs
- DataGridViewCheckBoxColumn.cs
- ErrorInfoXmlDocument.cs
- x509utils.cs
- Clause.cs
- FrameworkElementAutomationPeer.cs