Exemplo n.º 1
0
        void InitializeExtensionChain()
        {
            // Create an initial empty extension chain. This avoid crashes in case a call to SupportsObject ends
            // calling methods from the extension

            var tempExtensions = new List <WorkspaceObjectExtension> ();

            tempExtensions.AddRange(CreateDefaultExtensions().Reverse());
            extensionChain = ExtensionChain.Create(tempExtensions.ToArray());
            foreach (var e in tempExtensions)
            {
                e.Init(this);
            }

            // Collect extensions that support this object

            var extensions = new List <WorkspaceObjectExtension> ();

            foreach (ProjectModelExtensionNode node in GetModelExtensions(extensionContext))
            {
                if (node.CanHandleObject(this))
                {
                    var ext = node.CreateExtension();
                    if (ext.SupportsObject(this))
                    {
                        ext.SourceExtensionNode = node;
                        extensions.Add(ext);
                    }
                }
            }

            foreach (var e in tempExtensions)
            {
                e.Dispose();
            }

            // Now create the final extension chain

            extensions.Reverse();
            var defaultExts = CreateDefaultExtensions().ToList();

            defaultExts.Reverse();
            extensions.AddRange(defaultExts);
            extensionChain = ExtensionChain.Create(extensions.ToArray());
            extensionChain.SetDefaultInsertionPosition(defaultExts.FirstOrDefault());

            foreach (var e in extensions)
            {
                e.Init(this);
            }

            itemExtension = ExtensionChain.GetExtension <WorkspaceObjectExtension> ();

            foreach (var e in extensions)
            {
                e.OnExtensionChainCreated();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Called when an extension is dynamically loaded after object initialization
 /// </summary>
 /// <param name="extension">The extension.</param>
 /// <remarks>
 /// This method is called when an extension is loaded after the object initialization process.
 /// This may happen for example when calling RefreshExtensions.
 /// </remarks>
 protected virtual void OnExtensionActivated(WorkspaceObjectExtension extension)
 {
 }
Exemplo n.º 3
0
 public void DetachExtension(WorkspaceObjectExtension ext)
 {
     AssertMainThread();
     ExtensionChain.RemoveExtension(ext);
 }
Exemplo n.º 4
0
 public void AttachExtension(WorkspaceObjectExtension ext)
 {
     AssertMainThread();
     ExtensionChain.AddExtension(ext);
     ext.Init(this);
 }
Exemplo n.º 5
0
 internal protected override void InitializeChain(ChainedExtension next)
 {
     base.InitializeChain(next);
     this.next = FindNextImplementation <WorkspaceObjectExtension> (next);
 }
		internal protected override void InitializeChain (ChainedExtension next)
		{
			base.InitializeChain (next);
			this.next = FindNextImplementation<WorkspaceObjectExtension> (next);
		}