Esempio n. 1
0
        public static MyTypeFinder Create(OpenedFile file)
        {
            MyTypeFinder f = new MyTypeFinder();

            f.file = file;
            f.ImportFrom(CreateWpfTypeFinder());

            var pc = MyTypeFinder.GetProjectContent(file);

            foreach (var referencedProjectContent in pc.ThreadSafeGetReferencedContents())
            {
                string fileName = null;
                try{
                    if (referencedProjectContent is ParseProjectContent)
                    {
                        var prj = ((ParseProjectContent)referencedProjectContent).Project as AbstractProject;
                        if (prj != null)
                        {
                            fileName = prj.OutputAssemblyFullPath;
                        }
                    }
                    else if (referencedProjectContent is ReflectionProjectContent)
                    {
                        fileName = ((ReflectionProjectContent)referencedProjectContent).AssemblyLocation;
                    }
                    var assembly = Assembly.LoadFrom(fileName);
                    f.RegisterAssembly(assembly);
                }
                catch (Exception ex) {
                    ICSharpCode.Core.LoggingService.Warn("Error loading Assembly : " + (fileName ?? ""), ex);
                }
            }
            return(f);
        }
Esempio n. 2
0
        public object GetDescription(DesignItemProperty property)
        {
            IProjectContent pc = MyTypeFinder.GetProjectContent(file);

            if (pc != null)
            {
                // For attached Properties
                if (property.DependencyFullName != null && property.Name.Contains("."))
                {
                    IClass c = pc.GetClassByReflectionName(property.DependencyProperty.OwnerType.FullName, true);
                    if (c != null)
                    {
                        IMember m = DefaultProjectContent.GetMemberByReflectionName(c, property.DependencyProperty.Name + "Property");
                        if (m != null)
                        {
                            return(CodeCompletionItem.ConvertDocumentation(m.Documentation));
                        }
                    }
                }
                else
                {
                    IClass c = pc.GetClassByReflectionName(property.DeclaringType.FullName, true);
                    if (c != null)
                    {
                        IMember m = DefaultProjectContent.GetMemberByReflectionName(c, property.Name);
                        if (m != null)
                        {
                            return(CodeCompletionItem.ConvertDocumentation(m.Documentation));
                        }
                    }
                }
            }
            return(null);
        }
        public void AddProjectDlls(OpenedFile file)
        {
            var pc = MyTypeFinder.GetProjectContent(file);

            foreach (var referencedProjectContent in pc.ThreadSafeGetReferencedContents())
            {
                string f = null;
                if (referencedProjectContent is ParseProjectContent)
                {
                    var prj = ((ParseProjectContent)referencedProjectContent).Project as AbstractProject;
                    if (prj != null)
                    {
                        f = prj.OutputAssemblyFullPath;
                    }
                }
                else if (referencedProjectContent is ReflectionProjectContent)
                {
                    f = ((ReflectionProjectContent)referencedProjectContent).AssemblyLocation;
                }

                if (f != null && !addedAssemblys.Contains(f))
                {
                    try
                    {
                        var assembly = Assembly.LoadFrom(f);

                        SideTab sideTab = new SideTab(sideBar, assembly.FullName.Split(new[] { ',' })[0]);
                        sideTab.DisplayName         = StringParser.Parse(sideTab.Name);
                        sideTab.CanBeDeleted        = false;
                        sideTab.ChoosedItemChanged += OnChoosedItemChanged;

                        sideTab.Items.Add(new WpfSideTabItem());

                        foreach (var t in assembly.GetExportedTypes())
                        {
                            if (IsControl(t))
                            {
                                sideTab.Items.Add(new WpfSideTabItem(t));
                            }
                        }

                        if (sideTab.Items.Count > 1)
                        {
                            sideBar.Tabs.Add(sideTab);
                        }

                        addedAssemblys.Add(f);
                    }
                    catch (Exception ex)
                    {
                        WpfViewContent.DllLoadErrors.Add(
                            new Task(new BuildError(f, ex.Message)));
                    }
                }
            }
        }