コード例 #1
0
 void OnExtensionChanged(object s, ExtensionEventArgs args)
 {
     if (args.PathChanged("/MonoDevelop/ProjectModel/ProjectServiceExtensions"))
     {
         defaultExtensionChain = null;
     }
 }
コード例 #2
0
        internal ProjectServiceExtension GetExtensionChain(IBuildTarget target)
        {
            ProjectServiceExtension chain;

            if (target != null)
            {
                lock (target) {
                    ExtensionChainInfo einfo = (ExtensionChainInfo)target.ExtendedProperties [typeof(ExtensionChainInfo)];
                    if (einfo == null)
                    {
                        einfo = new ExtensionChainInfo();
                        ExtensionContext ctx = AddinManager.CreateExtensionContext();
                        einfo.ExtensionContext         = ctx;
                        einfo.ItemTypeCondition        = new ItemTypeCondition(target.GetType());
                        einfo.ProjectLanguageCondition = new ProjectLanguageCondition(target);
                        ctx.RegisterCondition("ItemType", einfo.ItemTypeCondition);
                        ctx.RegisterCondition("ProjectLanguage", einfo.ProjectLanguageCondition);
                        target.ExtendedProperties [typeof(ExtensionChainInfo)] = einfo;
                    }
                    else
                    {
                        einfo.ItemTypeCondition.ObjType = target.GetType();
                        einfo.ProjectLanguageCondition.TargetProject = target;
                    }
                    ProjectServiceExtension[] extensions = einfo.ExtensionContext.GetExtensionObjects <ProjectServiceExtension> ("/MonoDevelop/ProjectModel/ProjectServiceExtensions");
                    chain = CreateExtensionChain(extensions);

                    // After creating the chain there is no need to keep the reference to the target
                    einfo.ProjectLanguageCondition.TargetProject = null;
                }
            }
            else
            {
                if (defaultExtensionChain == null)
                {
                    ExtensionContext ctx = AddinManager.CreateExtensionContext();
                    ctx.RegisterCondition("ItemType", new ItemTypeCondition(typeof(UnknownItem)));
                    ctx.RegisterCondition("ProjectLanguage", new ProjectLanguageCondition(UnknownItem.Instance));
                    ProjectServiceExtension[] extensions = ctx.GetExtensionObjects <ProjectServiceExtension> ("/MonoDevelop/ProjectModel/ProjectServiceExtensions");
                    defaultExtensionChain = CreateExtensionChain(extensions);
                }
                chain  = defaultExtensionChain;
                target = UnknownItem.Instance;
            }

            if (chain.SupportsItem(target))
            {
                return(chain);
            }
            else
            {
                return(chain.GetNext(target));
            }
        }
コード例 #3
0
        public ProjectServiceExtension GetExtensionChain(IBuildTarget target)
        {
            ProjectServiceExtension chain;

            if (target != null)
            {
                ExtensionChainInfo einfo = (ExtensionChainInfo)Thread.GetData(extensionChainSlot);
                if (einfo == null)
                {
                    einfo = new ExtensionChainInfo();
                    ExtensionContext ctx = AddinManager.CreateExtensionContext();
                    einfo.ExtensionContext         = ctx;
                    einfo.ItemTypeCondition        = new ItemTypeCondition(target.GetType());
                    einfo.ProjectLanguageCondition = new ProjectLanguageCondition(target);
                    ctx.RegisterCondition("ItemType", einfo.ItemTypeCondition);
                    ctx.RegisterCondition("ProjectLanguage", einfo.ProjectLanguageCondition);
                    Thread.SetData(extensionChainSlot, einfo);
                }
                else
                {
                    einfo.ItemTypeCondition.ObjType = target.GetType();
                    einfo.ProjectLanguageCondition.TargetProject = target;
                }
                ProjectServiceExtension[] extensions = (ProjectServiceExtension[])einfo.ExtensionContext.GetExtensionObjects("/MonoDevelop/ProjectModel/ProjectServiceExtensions", typeof(ProjectServiceExtension));
                chain = CreateExtensionChain(extensions);
            }
            else
            {
                if (defaultExtensionChain == null)
                {
                    ExtensionContext ctx = AddinManager.CreateExtensionContext();
                    ctx.RegisterCondition("ItemType", new ItemTypeCondition(typeof(UnknownItem)));
                    ctx.RegisterCondition("ProjectLanguage", new ProjectLanguageCondition(UnknownItem.Instance));
                    ProjectServiceExtension[] extensions = (ProjectServiceExtension[])ctx.GetExtensionObjects("/MonoDevelop/ProjectModel/ProjectServiceExtensions", typeof(ProjectServiceExtension));
                    defaultExtensionChain = CreateExtensionChain(extensions);
                }
                chain  = defaultExtensionChain;
                target = UnknownItem.Instance;
            }

            if (chain.SupportsItem(target))
            {
                return(chain);
            }
            else
            {
                return(chain.GetNext(target));
            }
        }
コード例 #4
0
		void OnExtensionChanged (object s, ExtensionEventArgs args)
		{
			if (args.PathChanged ("/MonoDevelop/ProjectModel/ProjectServiceExtensions"))
				defaultExtensionChain = null;
		}
コード例 #5
0
		ProjectServiceExtension CreateExtensionChain (ProjectServiceExtension[] extensions)
		{
			var first = new CustomCommandExtension ();
			
			for (int n=0; n<extensions.Length - 1; n++)
				extensions [n].Next = extensions [n + 1];

			if (extensions.Length > 0) {
				extensions [extensions.Length - 1].Next = extensionChainTerminator;
				first.Next = extensions [0];
			} else {
				first.Next = extensionChainTerminator;
			}
			return first;
		}
コード例 #6
0
		public ProjectServiceExtension GetExtensionChain (IBuildTarget target)
		{
			ProjectServiceExtension chain;
			if (target != null) {
				ExtensionChainInfo einfo = (ExtensionChainInfo) Thread.GetData (extensionChainSlot);
				if (einfo == null) {
					einfo = new ExtensionChainInfo ();
					ExtensionContext ctx = AddinManager.CreateExtensionContext ();
					einfo.ExtensionContext = ctx;
					einfo.ItemTypeCondition = new ItemTypeCondition (target.GetType ());
					einfo.ProjectLanguageCondition = new ProjectLanguageCondition (target);
					ctx.RegisterCondition ("ItemType", einfo.ItemTypeCondition);
					ctx.RegisterCondition ("ProjectLanguage", einfo.ProjectLanguageCondition);
					Thread.SetData (extensionChainSlot, einfo);
				} else {
					einfo.ItemTypeCondition.ObjType = target.GetType ();
					einfo.ProjectLanguageCondition.TargetProject = target;
				}
				ProjectServiceExtension[] extensions = (ProjectServiceExtension[]) einfo.ExtensionContext.GetExtensionObjects ("/MonoDevelop/ProjectModel/ProjectServiceExtensions", typeof(ProjectServiceExtension));
				chain = CreateExtensionChain (extensions);
			}
			else {
				if (defaultExtensionChain == null) {
					ExtensionContext ctx = AddinManager.CreateExtensionContext ();
					ctx.RegisterCondition ("ItemType", new ItemTypeCondition (typeof(UnknownItem)));
					ctx.RegisterCondition ("ProjectLanguage", new ProjectLanguageCondition (UnknownItem.Instance));
					ProjectServiceExtension[] extensions = (ProjectServiceExtension[]) ctx.GetExtensionObjects ("/MonoDevelop/ProjectModel/ProjectServiceExtensions", typeof(ProjectServiceExtension));
					defaultExtensionChain = CreateExtensionChain (extensions);
				}
				chain = defaultExtensionChain;
				target = UnknownItem.Instance;
			}
			
			if (chain.SupportsItem (target))
				return chain;
			else
				return chain.GetNext (target);
		}
コード例 #7
0
		internal ProjectServiceExtension GetExtensionChain (IBuildTarget target)
		{
			ProjectServiceExtension chain;
			if (target != null) {
				lock (target) {
					ExtensionChainInfo einfo = (ExtensionChainInfo)target.ExtendedProperties [typeof(ExtensionChainInfo)];
					if (einfo == null) {
						einfo = new ExtensionChainInfo ();
						ExtensionContext ctx = AddinManager.CreateExtensionContext ();
						einfo.ExtensionContext = ctx;
						einfo.ItemTypeCondition = new ItemTypeCondition (target.GetType ());
						einfo.ProjectLanguageCondition = new ProjectLanguageCondition (target);
						ctx.RegisterCondition ("ItemType", einfo.ItemTypeCondition);
						ctx.RegisterCondition ("ProjectLanguage", einfo.ProjectLanguageCondition);
						target.ExtendedProperties [typeof(ExtensionChainInfo)] = einfo;
					} else {
						einfo.ItemTypeCondition.ObjType = target.GetType ();
						einfo.ProjectLanguageCondition.TargetProject = target;
					}
					ProjectServiceExtension[] extensions = einfo.ExtensionContext.GetExtensionObjects<ProjectServiceExtension> ("/MonoDevelop/ProjectModel/ProjectServiceExtensions");
					chain = CreateExtensionChain (extensions);
				
					// After creating the chain there is no need to keep the reference to the target
					einfo.ProjectLanguageCondition.TargetProject = null;
				}
			}
			else {
				if (defaultExtensionChain == null) {
					ExtensionContext ctx = AddinManager.CreateExtensionContext ();
					ctx.RegisterCondition ("ItemType", new ItemTypeCondition (typeof(UnknownItem)));
					ctx.RegisterCondition ("ProjectLanguage", new ProjectLanguageCondition (UnknownItem.Instance));
					ProjectServiceExtension[] extensions = ctx.GetExtensionObjects<ProjectServiceExtension> ("/MonoDevelop/ProjectModel/ProjectServiceExtensions");
					defaultExtensionChain = CreateExtensionChain (extensions);
				}
				chain = defaultExtensionChain;
				target = UnknownItem.Instance;
			}
			
			if (chain.SupportsItem (target))
				return chain;
			else
				return chain.GetNext (target);
		}