public override void Execute(object parameter)
        {
            var classBrowser = SD.GetService <IClassBrowser>();

            if (classBrowser != null)
            {
                IAssemblyModel assemblyModel = parameter as IAssemblyModel;
                if (assemblyModel == null)
                {
                    // Node is a project?
                    IProject project = parameter as IProject;
                    if (project != null)
                    {
                        assemblyModel = project.AssemblyModel;
                    }
                }

                if (assemblyModel == null)
                {
                    // Node is an assembly reference?
                    IAssemblyReferenceModel assemblyReference = parameter as IAssemblyReferenceModel;
                    if (assemblyReference != null)
                    {
                        // Model is an assembly reference
                        IAssemblyParserService   assemblyParserService = SD.GetRequiredService <IAssemblyParserService>();
                        IEntityModelContext      entityModelContext    = assemblyReference.ParentAssemblyModel.Context;
                        CombinedAssemblySearcher searcher = new CombinedAssemblySearcher();
                        if ((entityModelContext != null) && (entityModelContext.Project != null))
                        {
                            searcher.AddSearcher(new ProjectAssemblyReferenceSearcher(entityModelContext.Project));
                        }
                        searcher.AddSearcher(new DefaultAssemblySearcher(assemblyReference.ParentAssemblyModel.Location));
                        var resolvedFile = searcher.FindAssembly(assemblyReference.AssemblyName);
                        if (resolvedFile != null)
                        {
                            assemblyModel = assemblyParserService.GetAssemblyModelSafe(resolvedFile);
                        }
                        else
                        {
                            // Assembly file not resolvable
                            SD.MessageService.ShowWarningFormatted("Could not resolve reference '{0}'.", assemblyReference.AssemblyName.ShortName);
                        }
                    }
                }

                if (assemblyModel != null)
                {
                    // Try to remove AssemblyModel from list of UnpinnedAssemblies
                    classBrowser.UnpinnedAssemblies.Assemblies.RemoveAll(a => a.FullAssemblyName == assemblyModel.FullAssemblyName);

                    if (!classBrowser.MainAssemblyList.Assemblies.Contains(assemblyModel))
                    {
                        classBrowser.MainAssemblyList.Assemblies.Add(assemblyModel);
                    }

                    // Bring the node into view
                    classBrowser.GotoAssemblyModel(assemblyModel);
                }
            }
        }
 public ITypeDefinitionModel CreateTypeDefinitionModel(IEntityModelContext context, params IUnresolvedTypeDefinition[] parts)
 {
     var model = new TypeDefinitionModel(context, parts[0]);
     for (int i = 1; i < parts.Length; i++) {
         model.Update(null, parts[i]);
     }
     return model;
 }
Beispiel #3
0
		public MemberModel(IEntityModelContext context, IUnresolvedMember member)
		{
			if (context == null)
				throw new ArgumentNullException("context");
			if (member == null)
				throw new ArgumentNullException("member");
			this.context = context;
			this.member = member;
		}
 public TopLevelTypeDefinitionModelCollection(IEntityModelContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     this.context           = context;
     collectionChangedEvent = new ModelCollectionChangedEvent <ITypeDefinitionModel>();
 }
Beispiel #5
0
        public ITypeDefinitionModel CreateTypeDefinitionModel(IEntityModelContext context, params IUnresolvedTypeDefinition[] parts)
        {
            var model = new TypeDefinitionModel(context, parts[0]);

            for (int i = 1; i < parts.Length; i++)
            {
                model.Update(null, parts[i]);
            }
            return(model);
        }
Beispiel #6
0
		public AssemblyModel(IEntityModelContext context)
		{
			if (context == null)
				throw new ArgumentNullException("context");
			this.context = context;
			this.rootNamespace = new NamespaceModel(context.Project, null, "");
			this.typeDeclarations = new TopLevelTypeDefinitionModelCollection(context);
			this.typeDeclarations.CollectionChanged += TypeDeclarationsCollectionChanged;
			this.namespaces = new KeyedModelCollection<string, NamespaceModel>(value => value.FullName);
			this.referencesModel = new AssemblyReferencesModel(this);
		}
        public virtual void SetUp()
        {
            SD.InitializeForUnitTests();
            SD.Services.AddStrictMockService <IParserService>();
            project        = MockRepository.GenerateStrictMock <IProject>();
            projectContent = new CSharpProjectContent().AddAssemblyReferences(AssemblyLoader.Corlib);
            context        = new ProjectEntityModelContext(project, ".cs");
            assemblyModel  = new AssemblyModel(context);

            SD.ParserService.Stub(p => p.GetCompilation(project)).WhenCalled(c => c.ReturnValue = projectContent.CreateCompilation());
        }
Beispiel #8
0
 public AssemblyModel(IEntityModelContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     this.context          = context;
     this.rootNamespace    = new NamespaceModel(context.Project, null, "");
     this.typeDeclarations = new TopLevelTypeDefinitionModelCollection(context);
     this.typeDeclarations.CollectionChanged += TypeDeclarationsCollectionChanged;
     this.namespaces      = new KeyedModelCollection <string, NamespaceModel>(value => value.FullName);
     this.referencesModel = new AssemblyReferencesModel(this);
 }
 public MemberModel(IEntityModelContext context, IUnresolvedMember member)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (member == null)
     {
         throw new ArgumentNullException("member");
     }
     this.context = context;
     this.member  = member;
 }
 public TypeDefinitionModel(IEntityModelContext context, IUnresolvedTypeDefinition firstPart)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (firstPart == null)
     {
         throw new ArgumentNullException("firstPart");
     }
     this.context = context;
     this.parts.Add(firstPart);
     this.fullTypeName = firstPart.FullTypeName;
 }
Beispiel #11
0
 public IMemberModel CreateMemberModel(IEntityModelContext context, IUnresolvedMember member)
 {
     return new MemberModel(context, member);
 }
Beispiel #12
0
 public IUpdateableAssemblyModel CreateAssemblyModel(IEntityModelContext context)
 {
     return new AssemblyModel(context);
 }
Beispiel #13
0
 public IMemberModel CreateMemberModel(IEntityModelContext context, IUnresolvedMember member)
 {
     return(new MemberModel(context, member));
 }
Beispiel #14
0
 public IUpdateableAssemblyModel CreateAssemblyModel(IEntityModelContext context)
 {
     return(new AssemblyModel(context));
 }
Beispiel #15
0
 public NestedTypeDefinitionModelCollection(IEntityModelContext context)
 {
     this.context           = context;
     collectionChangedEvent = new ModelCollectionChangedEvent <ITypeDefinitionModel>();
 }