protected virtual void Initialize() { List <Assembly> assemblies = new List <Assembly>(); #if COREFX if (RunnerContext.TargetAssemblies != null) { assemblies.AddRange(RunnerContext.TargetAssemblies); } foreach (var target in RunnerContext.Targets ?? new string[0]) #else foreach (var target in RunnerContext.Targets) #endif { var assembly = AssemblyLoaderFactory.GetAssemblyLoader(target).Load(); if (!assemblies.Contains(assembly)) { assemblies.Add(assembly); } } var assemblyCollection = new AssemblyCollection(assemblies); var processor = RunnerContext.NoConnection? InitializeConnectionlessProcessor(): #if COREFX InitializeProcessor(assemblyCollection, ConnectionString); #else InitializeProcessor(assemblyCollection); #endif Runner = new MigrationRunner(assemblyCollection, RunnerContext, processor); }
public void DuplicateKey() { AssemblyCollection c = new AssemblyCollection(); c.Add(new AssemblyInfo("System.Web.dll")); c.Add(new AssemblyInfo("System.Web.dll")); }
public void ConfigureContainer(Container container) { var config = new ConfigBuilder(); var collection = new AssemblyCollection() .AddPublicTypesAssemblies(GetType().GetTypeInfo().Assembly, typeof(Ref).Assembly, typeof(DomainRef).Assembly); config.Add(new ExistAll.SimpleConfig.Binders.ConfigurationBinder(Configuration)); var settings = config.Build(collection.Assemblies, new ConfigOptions() { ConfigSuffix = "Settings" }); foreach (var setting in settings) { container.RegisterSingleton(setting.Key, setting.Value); } container.RegisterSingleton <ISystemClock, SystemClock>(); container.RegisterSingleton <ISiteCrawler, HttpSiteCrawler>(); container.RegisterDecorator <ISiteCrawler, CacheHttpSiteCrawler>(); container.RegisterSingleton <ISiteRepository, SiteRepository>(); container.RegisterSingleton <ICrawlerSiteRequestValidator, SiteInfoRequestValidator>(); }
public void ModifiesFolders() { // Given FileSystem fileSystem = new FileSystem { RootPath = @"C:/A", OutputPath = "C" }; fileSystem.InputPaths.Add("B"); PackagesCollection packages = new PackagesCollection(fileSystem); AssemblyCollection assemblies = new AssemblyCollection(); string setup = @" FileSystem.RootPath = @""C:\X""; FileSystem.InputPaths.Add(""Y""); FileSystem.OutputPath = ""Z""; "; SetupScript setupScript = new SetupScript(setup); setupScript.Compile(); // When setupScript.Invoke(packages, assemblies, fileSystem); // Then Assert.AreEqual(@"C:/X", fileSystem.RootPath.FullPath); Assert.AreEqual(@"Z", fileSystem.OutputPath.FullPath); CollectionAssert.AreEquivalent(new[] { "input", "B", "Y" }, fileSystem.InputPaths.Select(x => x.FullPath)); }
/// <summary> /// Initializes a new instance of the <see cref="LogConfiguration"/> class. /// </summary> public LogConfiguration() { _sinks = new LogSinkCollection(); _assemblies = new AssemblyCollection(); _filters = new LogFilterCollection(); _internalLogger = new InternalLogger(); }
public void GetByNameFailure() { AssemblyCollection c = new AssemblyCollection(); AssemblyInfo a = new AssemblyInfo("System.Web.dll"); c.Add(a); Assert.IsNull(c["System.Net.dll"]); }
public void GetByName() { AssemblyCollection c = new AssemblyCollection(); AssemblyInfo a = new AssemblyInfo("System.Web.dll"); c.Add(a); Assert.AreEqual(a, c["System.Web.dll"]); }
public void TestDefaultAssemblyReferences() { AssemblyCollection references = _parameters.References; Assert.AreEqual(3, references.Count); Assert.IsTrue(references.Contains(typeof(string).Assembly), "(ms)corlib.dll must be referenced by default!"); Assert.IsTrue(references.Contains(Assembly.LoadWithPartialName("System")), "System.dll must be referenced by default!"); Assert.IsTrue(references.Contains(typeof(Boo.Lang.Builtins).Assembly), "Boo.dll must referenced by default!"); }
private IAssemblyCollection ThatOrWhich(string word) { PredicateString.Add(word); var assemblies = _assemblyCollector.Get(); var assemblyFilter = new FilteredAssemblies(assemblies); var result = new AssemblyCollection(assemblyFilter, _negate); return(_not ? result.Not() : result); }
XmlDocument LoadAssemblyInfo(string path) { AssemblyCollection collection = new AssemblyCollection(); collection.Add(path); XmlDocument result = new XmlDocument(); collection.Document = result; collection.DoOutput(); return(result); }
public BootConfiguration(AssemblyCollection assemblies = null) { if (assemblies == null) { this.assemblies = new AssemblyCollection(); } else { this.assemblies = assemblies; } }
public IEnumerator InitializeAsync() { proxies.Clear(); var typesData = AssemblyCollection.GetTypeAttributesData <NodeNameAttribute>(); foreach (var(type, attrs) in typesData) { var attr = attrs.FirstOrDefault() as NodeNameAttribute; Register(attr.Name, attr.NodeType, type); } yield return(null); }
private void ResolveAllReferences(bool supressResolveUI) { IConfiguration configuration = this.configurationManager["AssemblyBrowser"]; bool autoResolve = configuration.GetProperty("AutoResolve") == "true"; if (supressResolveUI && autoResolve == false) { configuration.SetProperty("AutoResolve", "true"); } int oldAssemblyCount = 0; ArrayList assembliesToAdd = new ArrayList(); while (assemblyManager.Assemblies.Count != oldAssemblyCount) { oldAssemblyCount = assemblyManager.Assemblies.Count; IAssemblyCollection collection = new AssemblyCollection(); foreach (IAssembly assembly in assemblyManager.Assemblies) { collection.Add(assembly); } foreach (IAssembly assembly in collection) { foreach (IModule module in assembly.Modules) { foreach (IAssemblyReference assemblyReference in module.AssemblyReferences) { IAssembly newassembly = assemblyReference.Resolve(); if (assemblyManager.Assemblies.Contains(newassembly) == false) { assembliesToAdd.Add(newassembly); } } } } foreach (IAssembly assemblyToAdd in assembliesToAdd) { assemblyManager.Load(assemblyToAdd, assemblyToAdd.Location); } } if (supressResolveUI && autoResolve == false) { configuration.SetProperty("AutoResolve", "false"); } }
protected virtual void Initialize() { var assemblies = GetTargetAssemblies(); var assemblyCollection = new AssemblyCollection(assemblies); if (!RunnerContext.NoConnection && ConnectionStringProvider == null) { RunnerContext.NoConnection = true; } var processor = RunnerContext.NoConnection? InitializeConnectionlessProcessor():InitializeProcessor(assemblyCollection); Runner = new MigrationRunner(assemblyCollection, RunnerContext, processor); }
/// <summary> /// 格式花xml /// </summary> /// <returns></returns> public XElement ParseXml() { AssemblyCollection.AddRange(FixedAssemblyCollection); AssemblyCollection = AssemblyCollection.Distinct().OrderBy(p => p.Length).GetTList <String>(); string Canvas = CanvasTemplate.ParseXml(); string aa = string.Format("<UserControl {0} >\r\n{1}\r\n</UserControl>", string.Join(" ", AssemblyCollection), Canvas); XElement result = XElement.Parse(aa); result.Add( new XAttribute("Height", this.Height), new XAttribute("Width", this.Width)); return(result); }
public void Load(AssemblyCollection collection) { try { if (collection == null || !collection.Any()) { return; } AppDomain.CurrentDomain.AssemblyResolve += LoadFromAssemblyFolder; DoLoad(collection); } finally { AppDomain.CurrentDomain.AssemblyResolve -= LoadFromAssemblyFolder; } }
public Migrator(string connectionString, params Assembly[] assemblies) { var announcer = new TextWriterAnnouncer(Console.Write); IAssemblyCollection assemblyCollection = new AssemblyCollection(assemblies); var migrationContext = new RunnerContext(announcer); var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 }; PostgresProcessorFactory factory = new PostgresProcessorFactory(); IMigrationProcessor processor = factory.Create(connectionString, announcer, options); runner = new MigrationRunner(assemblyCollection, migrationContext, processor); }
private void DoLoad(AssemblyCollection collection) { CopyAllDllsFrom(collection.SourceFolder); var files = collection.Select(f => new FileInfo(Path.Combine(AssemblyFolder, f.FileName))).ToList(); var nonexisting = files.Where(f => !f.Exists).ToArray(); if (nonexisting.Any()) { throw new InvalidOperationException(string.Format("Nonexisting dll's: {0}", string.Join(", ", nonexisting.Select(f => f.FullName)))); } foreach (var file in files) { Load(file.FullName); } }
protected override Result <MigrationResult> ExecuteCore(Session session, MigrationContract contract) { if (contract == null) { throw new ArgumentNullException(nameof(contract)); } var announcer = new TextWriterAnnouncer(Logger.Debug); var migrationContext = new RunnerContext(announcer) { NestedNamespaces = true }; var factoryProvider = new MigrationProcessorFactoryProvider(); var factory = factoryProvider.GetFactory(contract.DatabaseType); var migrationOptions = new ProcessorOptions { PreviewOnly = false, ProviderSwitches = null, Timeout = contract.Timeout }; using (var processor = factory.Create(contract.AdminConnectionString, announcer, migrationOptions)) { var migrationAssemblies = _migrationAssemblies.Select(x => x.Assembly); var assemblies = new AssemblyCollection(migrationAssemblies); var runner = new MigrationRunner(assemblies, migrationContext, processor); runner.Conventions.TypeIsMigration = IsTypeMigration; runner.Conventions.GetMigrationInfo = GetPlatformMigrationInfo; Logger.Info("Start migration"); Logger.Info($"-> Database type: {contract.DatabaseType}"); Logger.Info($"-> Command timeout: {migrationOptions.Timeout}"); Logger.Info($"-> Assemblies to scan: {string.Join("; ", assemblies.Assemblies.Select(x => x.GetName().Name))}"); runner.MigrateUp(true); } var migrationResult = new MigrationResult(_migrationAssemblies); return(Success(migrationResult)); }
public Batch() { // Initialize the object this.Transactions = new TransactionCollection(); this.Assemblies = new AssemblyCollection(); lock (Batch.threadTable) { if (Batch.threadTable.ContainsKey(Thread.CurrentThread.ManagedThreadId)) { Batch.threadTable[Thread.CurrentThread.ManagedThreadId] = this; } else { Batch.threadTable.Add(Thread.CurrentThread.ManagedThreadId, this); } } }
protected virtual void Initialize() { List <Assembly> assemblies = new List <Assembly>(); foreach (var target in RunnerContext.Targets) { var assembly = AssemblyLoaderFactory.GetAssemblyLoader(target).Load(); if (!assemblies.Contains(assembly)) { assemblies.Add(assembly); } } var assemblyCollection = new AssemblyCollection(assemblies); var processor = RunnerContext.NoConnection? InitializeConnectionlessProcessor():InitializeProcessor(assemblyCollection); Runner = new MigrationRunner(assemblyCollection, RunnerContext, processor); }
private static Type GetPropType(string typeName) { Exception exception = null; try { return(Type.GetType(typeName, true, true)); } catch (Exception exception2) { exception = exception2; } try { CompilationSection compilationAppConfig = MTConfigUtil.GetCompilationAppConfig(); if (compilationAppConfig != null) { AssemblyCollection assemblies = compilationAppConfig.Assemblies; if (assemblies != null) { foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(typeName, false, true); if (type != null) { return(type); } } } } } catch { } throw exception; }
XmlDocument LoadAssemblyInfo (string path) { AssemblyCollection collection = new AssemblyCollection (); collection.Add (path); XmlDocument result = new XmlDocument (); collection.Document = result; collection.DoOutput (); return result; }
private void InitializeInterpreter() { Interpreter.SetValue("GUI", new Func <string, BaseUI>(ui => UIManager.GetOrCreate(AssemblyCollection.GetType(ui)))); Interpreter.SetValue("STG", new Action <string>(stage => StageManager.Switch(AssemblyCollection.GetType(stage)))); Interpreter.SetValue("PST", new Func <string, PresenterBase>(controller => PresenterManager.Get(controller))); Interpreter.SetValue("CMD", new Action <string, object>((c, o) => EventManager.Publish(CommandEventArgs.EventId, new CommandEventArgs(c, o)))); }
public static bool Compare(this AssemblyCollection source, AssemblyCollection n) { return(Compare <Assembly>(source, n)); }
public static bool Compare(this AssemblyCollection source, AssemblyCollection n, Func <Assembly, Assembly, bool> checkitem) { return(Compare <Assembly>(source, n, checkitem)); }
public static bool Compare(this AssemblyCollection source, AssemblyCollection n, Func <Assembly, Assembly, Action <string, string>, bool> checkitem, Action <string, string> errAct) { return(Compare <Assembly>(source, n, checkitem, errAct)); }
internal static long GetRecompilationHash(CompilationSection ps) { HashCodeCombiner combiner = new HashCodeCombiner(); combiner.AddObject(ps.Debug); combiner.AddObject(ps.TargetFramework); combiner.AddObject(ps.Strict); combiner.AddObject(ps.Explicit); combiner.AddObject(ps.Batch); combiner.AddObject(ps.OptimizeCompilations); combiner.AddObject(ps.BatchTimeout); combiner.AddObject(ps.MaxBatchGeneratedFileSize); combiner.AddObject(ps.MaxBatchSize); combiner.AddObject(ps.NumRecompilesBeforeAppRestart); combiner.AddObject(ps.DefaultLanguage); combiner.AddObject(ps.UrlLinePragmas); if (ps.AssemblyPostProcessorTypeInternal != null) { combiner.AddObject(ps.AssemblyPostProcessorTypeInternal.FullName); } foreach (Compiler compiler in ps.Compilers) { combiner.AddObject(compiler.Language); combiner.AddObject(compiler.Extension); combiner.AddObject(compiler.Type); combiner.AddObject(compiler.WarningLevel); combiner.AddObject(compiler.CompilerOptions); } foreach (System.Web.Configuration.ExpressionBuilder builder in ps.ExpressionBuilders) { combiner.AddObject(builder.ExpressionPrefix); combiner.AddObject(builder.Type); } AssemblyCollection assemblies = ps.Assemblies; if (assemblies.Count == 0) { combiner.AddObject("__clearassemblies"); } else { foreach (AssemblyInfo info in assemblies) { combiner.AddObject(info.Assembly); } } BuildProviderCollection buildProviders = ps.BuildProviders; if (buildProviders.Count == 0) { combiner.AddObject("__clearbuildproviders"); } else { foreach (System.Web.Configuration.BuildProvider provider in buildProviders) { combiner.AddObject(provider.Type); combiner.AddObject(provider.Extension); } } FolderLevelBuildProviderCollection folderLevelBuildProviders = ps.FolderLevelBuildProviders; if (folderLevelBuildProviders.Count == 0) { combiner.AddObject("__clearfolderlevelbuildproviders"); } else { foreach (FolderLevelBuildProvider provider2 in folderLevelBuildProviders) { combiner.AddObject(provider2.Type); combiner.AddObject(provider2.Name); } } CodeSubDirectoriesCollection codeSubDirectories = ps.CodeSubDirectories; if (codeSubDirectories.Count == 0) { combiner.AddObject("__clearcodesubdirs"); } else { foreach (CodeSubDirectory directory in codeSubDirectories) { combiner.AddObject(directory.DirectoryName); } } CompilerInfo[] allCompilerInfo = CodeDomProvider.GetAllCompilerInfo(); if (allCompilerInfo != null) { foreach (CompilerInfo info2 in allCompilerInfo) { if (info2.IsCodeDomProviderTypeValid) { string compilerOptions = info2.CreateDefaultCompilerParameters().CompilerOptions; if (!string.IsNullOrEmpty(compilerOptions)) { Type codeDomProviderType = info2.CodeDomProviderType; if (codeDomProviderType != null) { combiner.AddObject(codeDomProviderType.FullName); } combiner.AddObject(compilerOptions); } if (info2.CodeDomProviderType != null) { IDictionary <string, string> providerOptions = GetProviderOptions(info2); if ((providerOptions != null) && (providerOptions.Count > 0)) { string fullName = info2.CodeDomProviderType.FullName; foreach (string str3 in providerOptions.Keys) { string str4 = providerOptions[str3]; combiner.AddObject(fullName + ":" + str3 + "=" + str4); } } } } } } return(combiner.CombinedHash); }
public static bool Compare(this AssemblyCollection source, AssemblyCollection n) { return Compare<Assembly>(source,n); }
public static bool Compare(this AssemblyCollection source, AssemblyCollection n, Func<Assembly, Assembly, bool> checkitem) { return Compare<Assembly>(source,n,checkitem); }
public static bool Compare(this AssemblyCollection source, AssemblyCollection n, Func<Assembly, Assembly, Action<string, string>, bool> checkitem, Action<string, string> errAct) { return Compare<Assembly>(source,n,checkitem,errAct); }
private DataTable getFunctionList(AssemblyCollection assColl) { Context.TraceEvent(100, 0, "ListFunctions: Starting"); // build the structure for the datatable which is returned DataTable dtFuncs = new DataTable("dtFunctions"); dtFuncs.Columns.Add("Assembly", typeof(String)); dtFuncs.Columns.Add("Class", typeof(String)); dtFuncs.Columns.Add("Method", typeof(String)); dtFuncs.Columns.Add("ReturnType", typeof(String)); dtFuncs.Columns.Add("Parameters", typeof(String)); if (Context.ExecuteForPrepare) { // we can exit after building the table function if this is only // being executed for a prepare. Context.TraceEvent(100, 0, "ListFunctions: Finished (ExecuteForPrepare)"); return(dtFuncs); } foreach (Microsoft.AnalysisServices.Assembly ass in assColl) { Context.CheckCancelled(); if (ass is ClrAssembly) // we can only use reflection against .Net assemblies { Type t = ass.GetType(); ClrAssembly clrAss = (ClrAssembly)ass; Context.TraceEvent(100, 0, "ListFunctions: Processing the " + clrAss.Name + " Assembly"); foreach (ClrAssemblyFile f in clrAss.Files) // an assembly can have multiple files { Context.CheckCancelled(); // We only want to get the "main" asembly file and only files which have data // (Some of the system assemblies appear to be registrations only and do not // have any data. if (f.Data.Count > 0 && f.Type == ClrAssemblyFileType.Main) { // assembly the assembly back into a single byte from the blocks of base64 strings byte[] rawAss = new byte[0]; int iPos = 0; byte[] buff = new byte[0]; foreach (string block in f.Data) { Context.CheckCancelled(); buff = System.Convert.FromBase64String(block); System.Array.Resize(ref rawAss, rawAss.Length + buff.Length); buff.CopyTo(rawAss, iPos); iPos += buff.Length; } // use reflection to extract the public types and methods from the // re-assembled assembly. Context.TraceEvent(100, 0, "ListFunctions: Starting reflection against " + f.Name); System.Reflection.Assembly asAss = System.Reflection.Assembly.Load(rawAss); Type[] assTypes = asAss.GetTypes(); for (int i = 0; i < assTypes.Length; i++) { Type t2 = assTypes[i]; if (t2.IsPublic) { MethodInfo[] methods; methods = t2.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); int paramCnt = 0; foreach (MethodInfo meth in methods) { Context.CheckCancelled(); // build the parameter signature as a string ParameterInfo[] Params = meth.GetParameters(); System.Text.StringBuilder paramList = new System.Text.StringBuilder(); paramCnt = Params.Length; string[] paramArray = new string[paramCnt]; // add the first parameter if (paramCnt > 0) { paramList.Append(Params[0].Name); paramList.Append(" as "); paramList.Append(StripNamespace(Params[0].ParameterType.ToString())); } // add subsequent parameters, inserting a comma before each new one. for (int j = 1; j < paramCnt; j++) { paramList.Append(", "); paramList.Append(Params[j].Name); paramList.Append(" as "); paramList.Append(StripNamespace(Params[j].ParameterType.ToString())); } DataRow rowFunc = dtFuncs.NewRow(); Object[] items = new Object[5]; items[0] = ass.Name; items[1] = t2.Name; items[2] = meth.Name; items[3] = StripNamespace(meth.ReturnType.ToString()); items[4] = paramList.ToString(); rowFunc.ItemArray = items; dtFuncs.Rows.Add(rowFunc); rowFunc.AcceptChanges(); } // foreach meth } // if t2.IsPublic } // assTypes.Length Context.TraceEvent(100, 0, "ListFunctions: Finished reflecting against " + f.Name); } // if f.data.count > 0 && f.Type == main } // foreach f } // if ass is clrAssembly } // foreach ass dtFuncs.AcceptChanges(); Context.TraceEvent(100, dtFuncs.Rows.Count, "ListFunctions: Finished (" + dtFuncs.Rows.Count.ToString() + " function signatures)"); return(dtFuncs); }
static void GetExtraAssemblies(CompilerParameters options) { StringCollection refAsm = options.ReferencedAssemblies; string asmLocation; string asmName; ArrayList al = WebConfigurationManager.ExtraAssemblies; if (al != null && al.Count > 0) { foreach (object o in al) { asmName = o as string; if (asmName != null && !refAsm.Contains(asmName)) { refAsm.Add(asmName); } } } Assembly asm; IList list = BuildManager.CodeAssemblies; if (list != null && list.Count > 0) { foreach (object o in list) { asm = o as Assembly; if (asm == null) { continue; } asmName = asm.Location; if (asmName != null && !refAsm.Contains(asmName)) { refAsm.Add(asmName); } } } list = BuildManager.TopLevelAssemblies; if (list != null && list.Count > 0) { foreach (object o in list) { asm = o as Assembly; if (o == null) { continue; } asmName = asm.Location; if (!refAsm.Contains(asmName)) { refAsm.Add(asmName); } } } CompilationSection cfg = WebConfigurationManager.GetWebApplicationSection("system.web/compilation") as CompilationSection; AssemblyCollection asmcoll = cfg != null ? cfg.Assemblies : null; if (asmcoll == null) { return; } foreach (AssemblyInfo ai in asmcoll) { asmLocation = GetAssemblyLocationFromName(ai.Assembly); if (asmLocation == null || refAsm.Contains(asmLocation)) { continue; } refAsm.Add(asmLocation); } }
private void SerializeAssemblies(XmlWriter writer, AssemblyCollection assemblies) { if (assemblies.Count > 0) { writer.WriteStartElement("Assemblies"); foreach (Assembly assembly in assemblies) { writer.WriteStartElement("Assembly"); writer.WriteAttributeString("Name", assembly.FullName); writer.WriteEndElement(); } writer.WriteEndElement(); } }