internal AddIn(IAddInTree addInTree) { if(addInTree == null) throw new ArgumentNullException("addInTree"); this.addInTree = addInTree; }
public static AddIn Load(IAddInTree addInTree, TextReader textReader, string hintPath = null, XmlNameTable nameTable = null) { if (nameTable == null) { nameTable = new NameTable(); } try { var addIn = new AddIn(addInTree); using (var reader = new XmlTextReader(textReader, nameTable)) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.LocalName) { case "AddIn": addIn.properties = Properties.ReadFromAttributes(reader); SetupAddIn(reader, addIn, hintPath); break; default: throw new AddInLoadException("Unknown add-in file."); } } } } return(addIn); } catch (XmlException ex) { throw new AddInLoadException(ex.Message, ex); } }
/// <summary> /// Create a addIn tree /// </summary> public static void CreateAddInTree() { if (addInTree == null) { addInTree = new DefaultAddInTree(); InternalFileService fileUtilityService = new InternalFileService(); StringCollection addInFiles = null; if (ignoreDefaultCoreAddInDirectory == false) //如果没有忽略默认的插件路径,即采用默认的插件路径 { addInFiles = fileUtilityService.SearchDirectory(defaultCoreAddInDirectory, "*.addin"); InsertAddIns(addInFiles); } else //如果忽略默认的插件文件的路径 { if (addInDirectories != null) { foreach (string path in addInDirectories) { addInFiles = fileUtilityService.SearchDirectory(Application.StartupPath + Path.DirectorySeparatorChar + path, "*.addin"); InsertAddIns(addInFiles); } } } } }
public TextTemplatingHostAppDomainAssemblyResolver( IAppDomain hostAppDomain, IAddInTree addInTree) { this.hostAppDomain = hostAppDomain; this.addInTree = addInTree; hostAppDomain.AssemblyResolve += ResolveAssembly; }
void CreateFakeAddInTree() { fakeAddInTree = MockRepository.GenerateStub <IAddInTree>(); addInTreeServiceProviders = new List <IServiceProvider>(); fakeAddInTree .Stub(tree => tree.BuildServiceProviders(CustomServiceTextTemplatingServiceProviders.AddInPath)) .Return(addInTreeServiceProviders); }
void CreateFakeAddInTree() { fakeAddInTree = MockRepository.GenerateStub<IAddInTree>(); addInTreeServiceProviders = new List<IServiceProvider>(); fakeAddInTree .Stub(tree => tree.BuildServiceProviders(CustomServiceTextTemplatingServiceProviders.AddInPath)) .Return(addInTreeServiceProviders); }
public void CoreExceptionErrorMessageShownAssemblyNameStartsWithDollarButHasNoForwardSlashCharacter() { IAddInTree addInTree = MockRepository.GenerateStrictMock <IAddInTree>(); DerivedRuntime runtime = new DerivedRuntime(addInTree, "$ICSharpCode.FormsDesigner.dll", String.Empty); CoreException ex = Assert.Throws <CoreException>(delegate { runtime.Load(); }); Assert.AreEqual("Expected '/' in path beginning with '$'!", ex.Message); }
public void AssemblyLoadCalledWhenAssemblyNameStartsWithColon() { IAddInTree addInTree = MockRepository.GenerateStrictMock <IAddInTree>(); DerivedRuntime runtime = new DerivedRuntime(addInTree, ":ICSharpCode.SharpDevelop", String.Empty); runtime.Load(); Assert.AreEqual("ICSharpCode.SharpDevelop", runtime.AssemblyNamePassedToLoadAssembly); }
public void AssemblyLoadFromCalledWhenAssemblyNameStartsWithDollar() { IAddInTree addInTree = CreateAddInTreeWithFormsDesignerAddIn(); DerivedRuntime runtime = new DerivedRuntime(addInTree, "$ICSharpCode.FormsDesigner/FormsDesigner.dll", String.Empty); runtime.Load(); Assert.AreEqual(@"D:\SharpDevelop\AddIns\FormsDesigner\FormsDesigner.dll", runtime.AssemblyFileNamePassedToLoadAssemblyFrom); }
internal AddIn(IAddInTree addInTree) { if (addInTree == null) { throw new ArgumentNullException("addInTree"); } this.addInTree = addInTree; }
public Runtime(IAddInTree addInTree, string assembly, string hintPath) { if (addInTree == null) throw new ArgumentNullException("addInTree"); if (assembly == null) throw new ArgumentNullException("assembly"); this.addInTree = addInTree; this.assembly = assembly; this.hintPath = hintPath; }
IAddInTree CreateAddInTreeWithFormsDesignerAddIn() { IAddInTree addInTree = MockRepository.GenerateStrictMock <IAddInTree>(); AddIn formsDesignerAddIn = AddIn.Load(addInTree, new StringReader(GetFormsDesignerAddInXml())); formsDesignerAddIn.FileName = @"D:\SharpDevelop\AddIns\FormsDesigner\FormsDesigner.addin"; formsDesignerAddIn.Enabled = true; addInTree.Expect(a => a.AddIns).Return(new[] { formsDesignerAddIn }); return(addInTree); }
public void AssemblyLoadCalledWhenAssemblyNameDoesNotStartWithColonOrDollar() { IAddInTree addInTree = MockRepository.GenerateStrictMock <IAddInTree>(); string hintPath = @"D:\SharpDevelop\AddIns\FormsDesigner"; DerivedRuntime runtime = new DerivedRuntime(addInTree, "FormsDesigner.dll", hintPath); runtime.Load(); string expectedFileName = @"D:\SharpDevelop\AddIns\FormsDesigner\FormsDesigner.dll"; Assert.AreEqual(expectedFileName, runtime.AssemblyFileNamePassedToLoadAssemblyFrom); }
public void RuntimeLoadedAssemblyMatchesAssemblyReturnedFromLoadAssemblyFromMethod() { IAddInTree addInTree = MockRepository.GenerateStrictMock <IAddInTree>(); DerivedRuntime runtime = new DerivedRuntime(addInTree, "MyAddIn.dll", @"d:\projects"); runtime.AssemblyFileNames.Add(@"MyAddIn.dll", typeof(string).Assembly); Assembly loadedAssembly = runtime.LoadedAssembly; string expectedLoadedAssemblyName = "CommonLanguageRuntimeLibrary"; Assert.AreEqual(expectedLoadedAssemblyName, loadedAssembly.ManifestModule.ToString()); }
public void RuntimeLoadedAssemblyMatchesAssemblyReturnedFromLoadAssemblyMethod() { IAddInTree addInTree = MockRepository.GenerateStrictMock <IAddInTree>(); DerivedRuntime runtime = new DerivedRuntime(addInTree, ":ICSharpCode.SharpDevelop", String.Empty); runtime.AssemblyNames.Add("ICSharpCode.SharpDevelop", typeof(string).Assembly); Assembly loadedAssembly = runtime.LoadedAssembly; string expectedLoadedAssemblyName = "CommonLanguageRuntimeLibrary"; Assert.AreEqual(expectedLoadedAssemblyName, loadedAssembly.ManifestModule.ToString()); }
public static AddIn Load(IAddInTree addInTree, string fileName, XmlNameTable nameTable = null) { try { using (TextReader textReader = File.OpenText(fileName)) { AddIn addIn = Load(addInTree, textReader, Path.GetDirectoryName(fileName), nameTable); addIn.addInFileName = fileName; return(addIn); } } catch (AddInLoadException) { throw; } catch (Exception e) { throw new AddInLoadException("Can't load " + fileName, e); } }
public Runtime(IAddInTree addInTree, string assembly, string hintPath) { if (addInTree == null) { throw new ArgumentNullException("addInTree"); } if (assembly == null) { throw new ArgumentNullException("assembly"); } this.addInTree = addInTree; this.assembly = assembly; this.hintPath = hintPath; }
public void ErrorMessageShownWhenAddInReferenceCannotBeFound() { IAddInTree addInTree = MockRepository.GenerateStrictMock <IAddInTree>(); addInTree.Expect(a => a.AddIns).Return(new AddIn[0]); DerivedRuntime runtime = new DerivedRuntime(addInTree, "$UnknownAddIn/Unknown.dll", String.Empty); runtime.Load(); string expectedErrorMessageStart = "The addin '$UnknownAddIn/Unknown.dll' could not be loaded:\n" + "System.IO.FileNotFoundException: Could not find referenced AddIn UnknownAddIn"; string errorMessage = runtime.ErrorMessageDisplayed; Assert.IsTrue(errorMessage.StartsWith(expectedErrorMessageStart), errorMessage); }
private static void CreateAddInTree() { addInTree = new DefaultAddInTree(); InternalFileService fileUtilityService = new InternalFileService(); StringCollection addInFiles = null; if (addInDirectories != null) { foreach (string path in addInDirectories) { addInFiles = fileUtilityService.SearchDirectory(Application.StartupPath + Path.DirectorySeparatorChar + path, "*.addin"); InsertAddIns(addInFiles); } } }
public void ErrorMessageShownWhenLoadAssemblyFromThrowsFileLoadException() { IAddInTree addInTree = MockRepository.GenerateStrictMock <IAddInTree>(); DerivedRuntime runtime = new DerivedRuntime(addInTree, "Missing.dll", String.Empty); FileLoadException ex = new FileLoadException("Test"); runtime.LoadAssemblyFromExceptionToThrow = ex; runtime.Load(); string expectedErrorMessageStart = "The addin 'Missing.dll' could not be loaded:\n" + "System.IO.FileLoadException: Test"; string errorMessage = runtime.ErrorMessageDisplayed; Assert.IsTrue(errorMessage.StartsWith(expectedErrorMessageStart), errorMessage); }
public static AddIn Load(IAddInTree addInTree, string fileName, XmlNameTable nameTable = null) { try { using (TextReader textReader = File.OpenText(fileName)) { AddIn addIn = Load(addInTree, textReader, Path.GetDirectoryName(fileName), nameTable); addIn.addInFileName = fileName; return(addIn); } } catch (AddInLoadException ex) { throw; } catch (Exception e) { LoggingService.Debug("Error while loading AddIn {0} => {1} \n {2}", fileName, e.Message, e.ToString()); throw new AddInLoadException("Can't load " + fileName, e); } }
private static void CreateAddInTree() { //首先创建插件树实例 addInTree = new DefaultAddInTree(); InternalFileService fileUtilityService = new InternalFileService(); StringCollection addInFiles = null; if (addInDirectories != null) { //扫描每一个插件文件,生成插件并逐个插入到插件树 foreach(string path in addInDirectories) { addInFiles = fileUtilityService.SearchDirectory(Application.StartupPath + Path.DirectorySeparatorChar + path, "*.addin"); InsertAddIns(addInFiles); } } }
/// <summary> /// Create a addIn tree /// </summary> public static void CreateAddInTree() { if(addInTree == null) { addInTree = new DefaultAddInTree(); InternalFileService fileUtilityService = new InternalFileService(); StringCollection addInFiles = null; if (ignoreDefaultCoreAddInDirectory == false) //如果没有忽略默认的插件路径,即采用默认的插件路径 { addInFiles = fileUtilityService.SearchDirectory(defaultCoreAddInDirectory, "*.addin"); InsertAddIns(addInFiles); } else //如果忽略默认的插件文件的路径 { if (addInDirectories != null) { foreach(string path in addInDirectories) { addInFiles = fileUtilityService.SearchDirectory(Application.StartupPath + Path.DirectorySeparatorChar + path, "*.addin"); InsertAddIns(addInFiles); } } } } }
public static AddIn Load(IAddInTree addInTree, string fileName, XmlNameTable nameTable = null) { try { using (TextReader textReader = File.OpenText(fileName)) { AddIn addIn = Load(addInTree, textReader, Path.GetDirectoryName(fileName), nameTable); addIn.addInFileName = fileName; return addIn; } } catch (AddInLoadException) { throw; } catch (Exception e) { throw new AddInLoadException("Can't load " + fileName, e); } }
public RegisteredTestFrameworks(IAddInTree addInTree) { testFrameworkDescriptors = addInTree.BuildItems<TestFrameworkDescriptor>(AddInPath, null); }
void ReadFileName(IAddInTree addInTree) { List <string> items = addInTree.BuildItems <string>(AddInTreePath, this); gallioEchoConsoleApplicationFileName = items[0]; }
public RegisteredTestFrameworks(IAddInTree addInTree) { testFrameworkDescriptors = addInTree.BuildItems <TestFrameworkDescriptor>(AddInPath, null); }
public DerivedRuntime(IAddInTree addInTree, string assembly, string hintPath) : base(addInTree, assembly, hintPath) { }
public static AddIn Load(IAddInTree addInTree, TextReader textReader, string hintPath = null, XmlNameTable nameTable = null) { if (nameTable == null) nameTable = new NameTable(); try { AddIn addIn = new AddIn(addInTree); using (XmlTextReader reader = new XmlTextReader(textReader, nameTable)) { while (reader.Read()){ if (reader.IsStartElement()) { switch (reader.LocalName) { case "AddIn": addIn.properties = Properties.ReadFromAttributes(reader); SetupAddIn(reader, addIn, hintPath); break; default: throw new AddInLoadException("Unknown add-in file."); } } } } return addIn; } catch (XmlException ex) { throw new AddInLoadException(ex.Message, ex); } }
public GallioEchoConsoleApplicationFactory(IAddInTree addInTree) { ReadFileName(addInTree); }
public static AddinError[] InitializeAddins() { AssemblyLoader loader = new AssemblyLoader(); try { loader.CheckAssembly (Assembly.GetEntryAssembly ()); } catch (Exception ex) { AddinError err = new AddinError (Assembly.GetEntryAssembly ().Location, ex, true); return new AddinError[] { err }; } AddinError[] errors = null; addInTree = new DefaultAddInTree (loader); FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService)); StringCollection addInFiles = null; StringCollection retryList = null; if (ignoreDefaultCoreDirectory == false) { addInFiles = fileUtilityService.SearchDirectory(defaultCoreDirectory, "*.addin.xml"); retryList = InsertAddIns (addInFiles, out errors); } else retryList = new StringCollection(); if (addInDirectories != null) { foreach(string path in addInDirectories) { addInFiles = fileUtilityService.SearchDirectory(path, "*.addin.xml"); StringCollection partialRetryList = InsertAddIns (addInFiles, out errors); if (partialRetryList.Count != 0) { string [] retryListArray = new string[partialRetryList.Count]; partialRetryList.CopyTo(retryListArray, 0); retryList.AddRange(retryListArray); } } } while (retryList.Count > 0) { StringCollection newRetryList = InsertAddIns (retryList, out errors); // break if no add-in could be inserted. if (newRetryList.Count == retryList.Count) { break; } retryList = newRetryList; } return errors; }
public CustomServiceTextTemplatingServiceProviders(IAddInTree addInTree) { serviceProviders = addInTree.BuildServiceProviders(AddInPath); }