public void DereferenceVariables() { AspectDngConfig conf = AspectDngConfig.Instance; aspectRegExp = conf.DereferenceVariablesIn(aspectRegExp); targetRegExp = conf.DereferenceVariablesIn(targetRegExp); aspectXPath = conf.DereferenceVariablesIn(aspectXPath); targetXPath = conf.DereferenceVariablesIn(targetXPath); }
public AspectDngConfig(string configFile) { m_Instance = this; try{ Decorator conf = new Decorator(configFile); conf.GoTo("/AspectDngConfig"); // Read variables from the main config file foreach(Decorator d in conf.GetDecorators("//Variable")) Variables[d["@name"]] = d["@value"]; debug = bool.Parse(conf["@debug"]); warnings = DereferenceVariablesIn(conf["@warnings"]); weaving = DereferenceVariablesIn(conf["@weaving"]); AspectsAssembly = DereferenceVariablesIn(conf["AspectsAssembly"]); TargetAssembly = DereferenceVariablesIn(conf["TargetAssembly"]); WeavedAssembly = DereferenceVariablesIn(conf["WeavedAssembly"]); PrivateLocations = conf.GetStrings("//PrivatePath"); foreach(Decorator d in conf.GetDecorators("//Advice/*[not(self::Variable)]")){ AdviceSpec spec = AdviceSpec.Create(d); spec.DereferenceVariables(); AddAdvice(spec, configFile); } foreach(string path in conf.GetStrings("//AdviceFile")){ Decorator otherConf = new Decorator(DereferenceVariablesIn(path)); foreach(Decorator otherD in otherConf.GetDecorators("//Advice/*[not(self::Variable)]")){ AdviceSpec spec = AdviceSpec.Create(otherD); spec.DereferenceVariables(); AddAdvice(spec, path); } foreach(Decorator otherD in otherConf.GetDecorators("//Variable")) Variables[otherD["@name"]] = otherD["@value"]; } Log.Level = debug ? LogLevel.Debug : LogLevel.Warn; } catch(Exception e){ if (e.GetType().FullName.StartsWith("System.Xml")) throw new ConfigurationException(e); else throw e; } foreach(AdviceSpec spec in Advice) spec.origin = configFile; Environment.CurrentDirectory = new FileInfo(configFile).Directory.FullName; m_Instance = this; }
public AspectDngConfig(string configFile) { m_Instance = this; try{ Decorator conf = new Decorator(configFile); conf.GoTo("/AspectDngConfig"); // Read variables from the main config file foreach (Decorator d in conf.GetDecorators("//Variable")) { Variables[d["@name"]] = d["@value"]; } debug = bool.Parse(conf["@debug"]); warnings = DereferenceVariablesIn(conf["@warnings"]); weaving = DereferenceVariablesIn(conf["@weaving"]); AspectsAssembly = DereferenceVariablesIn(conf["AspectsAssembly"]); TargetAssembly = DereferenceVariablesIn(conf["TargetAssembly"]); WeavedAssembly = DereferenceVariablesIn(conf["WeavedAssembly"]); PrivateLocations = conf.GetStrings("//PrivatePath"); foreach (Decorator d in conf.GetDecorators("//Advice/*[not(self::Variable)]")) { AdviceSpec spec = AdviceSpec.Create(d); spec.DereferenceVariables(); AddAdvice(spec, configFile); } foreach (string path in conf.GetStrings("//AdviceFile")) { Decorator otherConf = new Decorator(DereferenceVariablesIn(path)); foreach (Decorator otherD in otherConf.GetDecorators("//Advice/*[not(self::Variable)]")) { AdviceSpec spec = AdviceSpec.Create(otherD); spec.DereferenceVariables(); AddAdvice(spec, path); } foreach (Decorator otherD in otherConf.GetDecorators("//Variable")) { Variables[otherD["@name"]] = otherD["@value"]; } } Log.Level = debug ? LogLevel.Debug : LogLevel.Warn; } catch (Exception e) { if (e.GetType().FullName.StartsWith("System.Xml")) { throw new ConfigurationException(e); } else { throw e; } } foreach (AdviceSpec spec in Advice) { spec.origin = configFile; } Environment.CurrentDirectory = new FileInfo(configFile).Directory.FullName; m_Instance = this; }
private void Weave(string configFile) { AspectDngConfig conf = new AspectDngConfig(configFile); if (!File.Exists(conf.TargetAssembly)) throw new ConfigurationException("File doesn't exist: " + conf.TargetAssembly); if (!File.Exists(conf.AspectsAssembly)) throw new ConfigurationException("File doesn't exist: " + conf.AspectsAssembly); string backup = CopyToBackup(conf.TargetAssembly); if (conf.TargetAssembly == conf.AspectsAssembly || conf.AspectsAssembly == null || conf.AspectsAssembly == "") Cil.Init(backup, backup); else Cil.Init(backup, conf.AspectsAssembly); PerformWeave(); Cil.SaveTo(conf.WeavedAssembly); }