Esempio n. 1
0
        public bool ShouldUseTemplate(Microsoft.Expression.Project.IProject project, ITemplate templateToTest)
        {
            bool flag;

            Microsoft.Expression.Project.Templates.VSTemplate template;
            if (this.TemplateFilters != null)
            {
                Microsoft.Expression.Extensibility.Project.IProject project1 = null;
                TemplateBase templateBase = templateToTest as TemplateBase;
                if (templateBase != null)
                {
                    template = templateBase.Template;
                }
                else
                {
                    template = null;
                }
                Microsoft.Expression.Project.Templates.VSTemplate vSTemplate = template;
                if (vSTemplate != null)
                {
                    using (IEnumerator <ITemplateFilter> enumerator = this.TemplateFilters.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            ITemplateFilter current = enumerator.Current;
                            try
                            {
                                if (project1 == null)
                                {
                                    project1 = new Microsoft.Expression.Extensibility.Project.Project(project);
                                }
                                if (!current.ShouldUseTemplate(project1, vSTemplate.TemplateExtensibilityWrapper))
                                {
                                    flag = false;
                                    return(flag);
                                }
                            }
                            catch (Exception exception)
                            {
                            }
                        }
                        return(true);
                    }
                    return(flag);
                }
            }
            return(true);
        }
        public T FindAdapter <T>(Microsoft.Expression.Project.IProject project, out Microsoft.Expression.Extensibility.Project.IProject extensionProject)
        {
            T t;
            T t1;

            extensionProject = null;
            if (this.Adapters != null)
            {
                using (IEnumerator <IProjectAdapter> enumerator = this.Adapters.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        IProjectAdapter current = enumerator.Current;
                        if (!typeof(T).IsAssignableFrom(current.GetType()))
                        {
                            continue;
                        }
                        try
                        {
                            if (current.RequiredTargetFramework == null || project.TargetFramework != null && current.RequiredTargetFramework.Identifier.Equals(project.TargetFramework.Identifier, StringComparison.OrdinalIgnoreCase) && current.RequiredTargetFramework.Profile.Equals(project.TargetFramework.Profile, StringComparison.OrdinalIgnoreCase) && current.RequiredTargetFramework.Version <= project.TargetFramework.Version)
                            {
                                if (extensionProject == null)
                                {
                                    extensionProject = new Microsoft.Expression.Extensibility.Project.Project(project);
                                }
                                if (current.AppliesToProject(extensionProject))
                                {
                                    t = (T)current;
                                    return(t);
                                }
                            }
                        }
                        catch (Exception exception)
                        {
                            this.serviceProvider.MessageLoggingService().WriteLine(exception.Message);
                        }
                    }
                    t1 = default(T);
                    return(t1);
                }
                return(t);
            }
            t1 = default(T);
            return(t1);
        }