[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Model / ModelTreeItemHelper.cs
1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //----------------------------------------------------------------
6
7 namespace System.Activities.Presentation.Model
8 {
9     using System.Collections.Generic;
10     using System.Linq;
11     using System.Runtime;
12
13     // this class is to share common code among classes that implements IModelTreeItem, currently ModelItemImpl, ModelItemCollectionImpl and ModelItemDictionaryImpl
14     internal class ModelTreeItemHelper
15     {
16         private List<BackPointer> extraPropertyBackPointers;
17
18         public ModelTreeItemHelper()
19         {
20             this.extraPropertyBackPointers = new List<BackPointer>();
21         }
22
23         public List<BackPointer> ExtraPropertyBackPointers
24         {
25             get { return this.extraPropertyBackPointers; }
26         }
27
28         public void RemoveExtraPropertyBackPointer(ModelItem parent, string propertyName)
29         {
30             Fx.Assert(parent != null, "parent should not be null");
31             Fx.Assert(!string.IsNullOrEmpty(propertyName), "propertyName should not be null or empty");
32
33             BackPointer backPointer = this.extraPropertyBackPointers.FirstOrDefault<BackPointer>((bp) => bp.DestinationVertex == parent && propertyName == bp.PropertyName);
34             if (backPointer != null)
35             {
36                 this.extraPropertyBackPointers.Remove(backPointer);
37             }
38             else
39             {
40                 Fx.Assert("BackPointer not found");
41             }
42         }
43     }
44 }