Esempio n. 1
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));
            }
        }
Esempio n. 2
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));
            }
        }
 bool IsSelectable(IBuildTarget item)
 {
     if (SelectableFilter != null && !SelectableFilter(item))
     {
         return(false);
     }
     if (selectableTypes.Count > 0)
     {
         return(selectableTypes.Any(t => t.IsAssignableFrom(item.GetType())));
     }
     return(true);
 }
 protected bool IsCheckboxVisible(IBuildTarget item)
 {
     if (!ShowCheckboxes)
     {
         return(false);
     }
     if (selectableTypes.Count > 0)
     {
         return(selectableTypes.Any(t => t.IsAssignableFrom(item.GetType())));
     }
     return(true);
 }
Esempio n. 5
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);
		}
 protected bool IsCheckboxVisible(IBuildTarget item)
 {
     if (!ShowCheckboxes)
         return false;
     if (selectableTypes.Count > 0)
         return selectableTypes.Any (t => t.IsAssignableFrom (item.GetType ()));
     return true;
 }
		bool IsSelectable (IBuildTarget item)
		{
			if (SelectableFilter != null && !SelectableFilter (item))
				return false;
			if (selectableTypes.Count > 0)
				return selectableTypes.Any (t => t.IsAssignableFrom (item.GetType ()));
			return true;
		}
Esempio n. 8
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);
		}