1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation.Hosting
9 using System.Collections.ObjectModel;
10 using System.Activities.Presentation.Services;
11 using System.Activities.Presentation.Model;
14 [Fx.Tag.XamlVisible(false)]
15 public sealed class ImportedNamespaceContextItem : ContextItem
17 bool initialized = false;
18 Collection<string> importedNamespaces;
20 public Collection<string> ImportedNamespaces
24 if (this.importedNamespaces == null)
27 this.importedNamespaces = new Collection<string>();
29 return this.importedNamespaces;
33 public override Type ItemType
35 get { return typeof(ImportedNamespaceContextItem); }
38 public void EnsureInitialized(EditingContext context)
42 ModelService modelService = context.Services.GetService<ModelService>();
43 Fx.Assert(modelService != null, "ModelService shouldn't be null in EditingContext.");
44 Fx.Assert(modelService.Root != null, "model must have a root");
45 ModelItemCollection importsModelItem = modelService.Root.Properties[NamespaceListPropertyDescriptor.ImportCollectionPropertyName].Collection;
46 Fx.Assert(importsModelItem != null, "root must have imports");
47 foreach (ModelItem import in importsModelItem)
49 this.ImportedNamespaces.Add(import.Properties[NamespaceListPropertyDescriptor.NamespacePropertyName].ComputedValue as string);