Esempio n. 1
0
        internal static void EnsureSystemWindowsInteractivityReferenced(ITypeResolver typeResolver)
        {
            IType type = typeResolver.ResolveType(BehaviorHelper.BehaviorsProperty.DeclaringTypeId);
            ProjectXamlContext projectXamlContext = typeResolver as ProjectXamlContext;
            Uri result;

            if (typeResolver.PlatformMetadata.IsNullType((ITypeId)type) || projectXamlContext == null || !Uri.TryCreate(type.RuntimeType.Assembly.CodeBase, UriKind.Absolute, out result))
            {
                return;
            }
            projectXamlContext.EnsureAssemblyReferenced(result.LocalPath);
        }
        private bool AddReferences(IProjectContext projectContext, ReplaceStyleTemplateCommand.ExtraReferences references, string resourceKey)
        {
            ProjectXamlContext projectXamlContext = ProjectXamlContext.FromProjectContext(projectContext);

            if (projectXamlContext == null)
            {
                return(false);
            }
            if (references.Assemblies.Count > 0)
            {
                ISolution currentSolution = this.DesignerContext.ProjectManager.CurrentSolution;
                if (currentSolution != null)
                {
                    List <IProject>        list1 = new List <IProject>();
                    List <IProjectContext> list2 = new List <IProjectContext>();
                    foreach (IProject project in currentSolution.Projects)
                    {
                        ProjectXamlContext projectContext1 = ProjectXamlContext.GetProjectContext(project);
                        if (projectContext1 != null && projectContext1.ProjectAssembly != null && references.Assemblies.Contains(projectContext1.ProjectAssembly))
                        {
                            list1.Add(project);
                            list2.Add((IProjectContext)projectContext1);
                        }
                    }
                    for (int index = 0; index < list1.Count; ++index)
                    {
                        IProject        source          = list1[index];
                        IProjectContext projectContext1 = list2[index];
                        if (projectXamlContext != projectContext1 && ProjectHelper.DoesProjectReferenceHierarchyContainTarget(source, (IProjectContext)projectXamlContext))
                        {
                            this.DesignerContext.MessageDisplayService.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.DocumentRefersToUnresolvedTypesHeader, new object[1]
                            {
                                (object)resourceKey
                            }));
                            return(false);
                        }
                    }
                }
                foreach (IAssembly assembly in (IEnumerable <IAssembly>)references.Assemblies)
                {
                    projectXamlContext.EnsureAssemblyReferenceMatches(this.SceneViewModel.ProjectContext, assembly);
                }
            }
            foreach (string assemblyPath in (IEnumerable <string>)references.PlatformAssemblies)
            {
                projectXamlContext.EnsureAssemblyReferenced(assemblyPath);
            }
            this.SceneViewModel.DesignerContext.ViewUpdateManager.RebuildPostponedViews();
            return(true);
        }
Esempio n. 3
0
        protected override bool CreateProjectItem()
        {
            IProject project = this.targetedProject != null ? this.targetedProject : ProjectCommandExtensions.SelectedProjectOrNull((IProjectCommand)this);

            if (project == null)
            {
                return(false);
            }
            bool flag = false;

            string[] filesToImport = this.GetFilesToImport(this.importedPathFilter != null ? this.importedPathFilter : this.GetImportFolder());
            if (filesToImport != null && filesToImport.Length > 0)
            {
                foreach (string str in filesToImport)
                {
                    string          withoutExtension = Path.GetFileNameWithoutExtension(str);
                    ProjectAssembly projectAssembly  = project.ReferencedAssemblies.Find(withoutExtension);
                    if (projectAssembly != null && !projectAssembly.IsImplicitlyResolved)
                    {
                        ProjectCommandExtensions.DisplayCommandFailedMessage((IProjectCommand)this, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, StringTable.ReferenceExistsErrorDialogMessage, new object[2]
                        {
                            (object)str,
                            (object)withoutExtension
                        }));
                    }
                    else
                    {
                        IProjectItem projectItem = project.AddAssemblyReference(str, true);
                        if (projectItem != null)
                        {
                            ProjectCommandExtensions.ProjectManager((IProjectCommand)this).DefaultImportPath = Path.GetDirectoryName(str);
                            ProjectCommandExtensions.ProjectManager((IProjectCommand)this).ItemSelectionSet.Clear();
                            ProjectCommandExtensions.ProjectManager((IProjectCommand)this).ItemSelectionSet.ToggleSelection((IDocumentItem)projectItem);
                        }
                        ProjectXamlContext projectContext = ProjectXamlContext.GetProjectContext(project);
                        if (projectContext != null)
                        {
                            projectContext.EnsureAssemblyReferenced(str);
                        }
                        if (projectItem != null)
                        {
                            flag = true;
                        }
                    }
                }
            }
            return(flag);
        }
Esempio n. 4
0
        private bool EnsureTreeControlTypeAssembly()
        {
            if (this.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
            {
                return(true);
            }
            ProjectXamlContext projectXamlContext = ProjectXamlContext.FromProjectContext(this.ProjectContext);

            if (projectXamlContext == null)
            {
                return(false);
            }
            projectXamlContext.EnsureAssemblyReferenced(DataBindingDragDropDefaultHandler.SilverlightTreeControlAssemblyName);
            this.DragModel.TargetNode.DesignerContext.ViewUpdateManager.RebuildPostponedViews();
            return(!this.ProjectContext.PlatformMetadata.IsNullType((ITypeId)this.ProjectContext.ResolveType(DataBindingDragDropDefaultHandler.TreeControlType)));
        }