private string PreprocessLine(string line) { string origline = line; List <PreprocChunk> ppcs = GetPPC(line); foreach (KeyValuePair <string, BYONDValue> kvp in Defines) { foreach (PreprocChunk _ppc in ppcs) { int len = _ppc.end - _ppc.start; if (len > line.Length) { throw new ArgumentOutOfRangeException(); } string currentChunk = line.Substring(_ppc.start, len); string key = kvp.Key; BYONDValue value = kvp.Value; bool updatePPCs = false; if (line.Contains(key)) { if (!defineMatchers.ContainsKey(key)) { this.defineMatchers[key] = new Regex(@"\b" + key + @"\b"); } string newChunk = this.defineMatchers[key].Replace(currentChunk, value._value.ToString()); if (newChunk != currentChunk) { if (ppcDebugOn) { log.DebugFormat("RULE: {0}", key); log.DebugFormat(" OLD: {0}", currentChunk); log.DebugFormat(" PPD: {0}", newChunk); } currentChunk = newChunk; updatePPCs = true; } } if (updatePPCs) { line = line.ReplaceAt(_ppc.start, len, currentChunk); ppcs = GetPPC(line); } } } /* * log.DebugFormat("PPC: {0}", ppcs.Count); * log.DebugFormat("OLD: {0}", origline); * log.DebugFormat("PPD: {0}", line); */ return(line); }
internal void SetProperty <T>(string key, T val) { Atom a = null; if (val.GetType() == typeof(Atom)) { object o = val; a = (Atom)o; } else { a = new BYONDValue <T>(val); } if (nativeProperties.ContainsKey(key)) { nativeProperties[key].Set(a); } else { changedProperties[key] = a; } }
public void SetDefine(string name, int value) { Defines[name] = new BYONDValue <int?>(value); }