protected override TargetTemplate InferTemplate(TypeResolver res, IWarningLogger log) { TargetTemplate tmpl = null; string dtname = DirectTransformDep; if (dtname != null) { if (res.TryMatch(dtname, MatcherKind.DirectTransform, out tmpl, log)) { return(null); } if (tmpl != null) { return(tmpl); } } if (Rule == null) { if (res.TryMatch(Name, MatcherKind.Target, out tmpl, log)) { return(null); } } if (tmpl == null) { log.Error(2028, "Cannot guess the template or rule for this target", FullName); } return(tmpl); }
public bool UseNamespace (string ns, string declloc, IWarningLogger log) { if (bm == null) { // No bundle manager yet. Save the info; once our manager is // set, we can do all the loading and structure template instantiation. nsqueue[ns] = declloc; return false; } // Standard initialization. UseRawNamespace ("MBuildDynamic." + ns); // Now we load the associated structure template and instantiate // anything that needs instantiation. // XXX this was later before; why??? if (declloc == null) throw ExHelp.App ("! {0}, {1}", ns, declloc); StructureTemplate st = bm.UseNamespaceTemplate (ns, declloc, log); if (st == null) return true; known_structs[st.GetType ()] = st; return false; }
protected override bool ImportXml(XmlReader xr, IWarningLogger log) { int d = xr.Depth; while (!xr.EOF && xr.Depth >= d) { if (xr.NodeType != XmlNodeType.Element) { xr.Read(); continue; } if (xr.NodeType != XmlNodeType.Element || xr.Name != "result") { log.Warning(3019, "Expected 'result' element in dictionary but got '" + xr.Name + "' instead during XML import.", null); xr.Read(); continue; } string id; Result r = Result.ImportXml(xr, out id, log); if (r == null) { return(true); } this[id] = r; } return(false); }
public RrAddressMatcher(IKadRrService kadRrService, IMapper <AddressDetailItem, TResult> mapper, int maxNumberOfResults, IWarningLogger warnings) { _kadRrService = kadRrService; _mapper = mapper; _maxNumberOfResults = maxNumberOfResults; _warnings = warnings; }
public static BinaryLoadedGraph Load(string f, IWarningLogger log) { FileStream fs = File.OpenRead(f); using (BufferedStream bs = new BufferedStream(fs)) return(Load(bs, log)); }
public static object Load(string path, IWarningLogger log) { prereqs(path); if (!File.Exists(path)) { return(null); } object result = null; StreamingContext ctxt = new StreamingContext(StreamingContextStates.All); BinaryFormatter fmt = new BinaryFormatter(null, ctxt); try { using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { result = fmt.Deserialize(stream); } } catch (Exception e) { if (log != null) { log.Warning(1005, "Error recovering data from " + path, e.Message); } else { Console.Error.WriteLine("Unable to log error loading log; you can " + "probably ignore this message: {0}", e.Message); } return(null); } return(result); }
// return true on error public static bool Save(string path, object obj, IWarningLogger log) { prereqs(path); StreamingContext ctxt = new StreamingContext(StreamingContextStates.All); BinaryFormatter fmt = new BinaryFormatter(null, ctxt); try { using (FileStream stream = new FileStream(path + newext, FileMode.Create, FileAccess.Write)) { fmt.Serialize(stream, obj); } bool exists = File.Exists(path); if (exists) { File.Move(path, path + oldext); } File.Move(path + newext, path); if (exists) { File.Delete(path + oldext); } } catch (Exception e) { log.Warning(1006, "Error writing data to " + path + newext, e.Message); File.Delete(path + newext); return(true); } return(false); }
bool AddNamed(int aid, Result r, Fingerprint fp, int index_into_values, IWarningLogger logger) { if (aid < 0 || aid >= args.Length) { string s = String.Format("Trying to add {0} to nonexistant " + "argument ID {1}.", r, aid); logger.Error(2042, s, r.ToString()); return(true); } Result subres = CompositeResult.FindCompatible(r, args[aid].Type); if (subres == null) { string err = String.Format("Argument value should be of type {0}, but " + "its type is {1}", args[aid].Type, r.GetType()); logger.Error(2036, err, r.ToString()); return(true); } if (subres == r) { args[aid].AddResult(r, fp, index_into_values); } else { // FIXME: the FP is really invalid, right? args[aid].AddResult(r, null, index_into_values); } return(false); }
public static object Load (string path, IWarningLogger log) { prereqs (path); if (!File.Exists (path)) return null; object result = null; StreamingContext ctxt = new StreamingContext (StreamingContextStates.All); BinaryFormatter fmt = new BinaryFormatter (null, ctxt); try { using (FileStream stream = new FileStream (path, FileMode.Open, FileAccess.Read)) { result = fmt.Deserialize (stream); } } catch (Exception e) { if (log != null) log.Warning (1005, "Error recovering data from " + path, e.Message); else Console.Error.WriteLine ("Unable to log error loading log; you can " + "probably ignore this message: {0}", e.Message); return null; } return result; }
// Don't just retrieve the template instance; also Apply() it to our project, // instantiating whatever providers or whatever the template defines. public StructureTemplate UseNamespaceTemplate(string ns, string declloc, IWarningLogger log) { if (proj == null) { throw new InvalidOperationException("Must call SetProject before UseNamespaceMaster!"); } StructureTemplate tmpl = GetNamespaceTemplate(ns, log); if (tmpl == null) { return(null); } if (sused[ns]) { return(tmpl); } if (tmpl.Apply(proj, declloc, log)) { return(null); } sused[ns] = true; return(tmpl); }
public bool CreateToplevel (string topsrc, string bfname, IWarningLogger uilog) { if ((ss = SourceSettings.CreateToplevel (topsrc, bfname, uilog)) == null) return true; return false; }
public bool SetManager(BundleManager bm, IWarningLogger logger) { if (bm == null) { throw new ArgumentNullException(); } if (this.bm != null) { throw new Exception("Already have manager set"); } this.bm = bm; // This is pretty weak. foreach (string ns in nsqueue.Keys) { if (UseNamespace(ns, nsqueue[ns], logger)) { return(true); } } return(false); }
public bool Finish(BundleManager bm, IWarningLogger log) { if (DeclarationLoc == null) { throw ExHelp.App("WP Finish, basis {0}", Basis); } if (namecontext.SetManager(bm, log)) { return(true); } if (DoneRequesting(namecontext, log)) { return(true); } foreach (WrenchTarget wt in DefinedTargets) { if (wt.DoFixup(namecontext, log)) { return(true); } } return(false); }
public static BinaryLoadedGraph Load (string f, IWarningLogger log) { FileStream fs = File.OpenRead (f); using (BufferedStream bs = new BufferedStream (fs)) return Load (bs, log); }
IEnumerable <IMatcher> ListMatchers(MatcherKind kind, IWarningLogger log) { mlist_had_error = false; foreach (Type t in VisibleTypes) { object[] attrs = t.GetCustomAttributes(typeof(MatcherAttribute), false); if (attrs == null || attrs.Length == 0) { continue; } if (((MatcherAttribute)attrs[0]).Kind != kind) { continue; } object o; if (InstantiateBoundType(t, out o, log)) { mlist_had_error = true; yield break; } yield return((IMatcher)o); } }
public bool UseNamespace(string ns, string declloc, IWarningLogger log) { if (bm == null) { // No bundle manager yet. Save the info; once our manager is // set, we can do all the loading and structure template instantiation. nsqueue[ns] = declloc; return(false); } // Standard initialization. UseRawNamespace("MBuildDynamic." + ns); // Now we load the associated structure template and instantiate // anything that needs instantiation. // XXX this was later before; why??? if (declloc == null) { throw ExHelp.App("! {0}, {1}", ns, declloc); } StructureTemplate st = bm.UseNamespaceTemplate(ns, declloc, log); if (st == null) { return(true); } known_structs[st.GetType()] = st; return(false); }
protected override bool ImportXml(XmlReader xr, IWarningLogger log) { int depth = xr.Depth; while (xr.Depth >= depth) { if (xr.NodeType != XmlNodeType.Element) { xr.Read(); continue; } if (xr.Name != "enum") { log.Warning(3019, "Unknown element in EnumResult during XML import", xr.Name); xr.Skip(); break; } string s = xr.ReadElementString(); try { ValueString = s; } catch (Exception e) { log.Error(3019, "Error converting input string to enumeration value", e.Message); return(true); } } return(false); }
// Loading public bool LoadSource (IWarningLogger uilog) { if ((ss = SourceSettings.Load (uilog)) == null) return true; return false; }
public StructureTemplate GetNamespaceTemplate (string ns, IWarningLogger log) { if (sinfo.ContainsKey (ns)) return sinfo[ns]; string cfg = MBuildPrefix + ns + "." + DefaultStructureClass; Type t = null; if (LookupType (cfg, out t, log)) { log.Error (9999, "Error looking up namespacep parameter class " + cfg, null); return null; } if (t == null) { log.Error (9999, "No bundle defines the namespace parameter class" + cfg, null); return null; } StructureTemplate stmpl = (StructureTemplate) Activator.CreateInstance (t); MethodInfo mi = t.GetMethod ("ApplyDefaults"); object ret = mi.Invoke (stmpl, new object[] { this, log }); if ((bool) ret) return null; sinfo[ns] = stmpl; sused[ns] = false; return stmpl; }
public static ActionLog Load(SourceSettings ss, IWarningLogger uilog) { ActionLog ld = null; if (uilog == null) { throw new ArgumentNullException(); } string path = ss.PathToStateItem(LogName); if (File.Exists(path)) { ld = (ActionLog)SafeFileSerializer.Load(path, uilog); } if (ld == null) { // Didn't exist or failed to recover ld = new ActionLog(); } ld.uilog = uilog; return(ld); }
// return true on error public static bool Save (string path, object obj, IWarningLogger log) { prereqs (path); StreamingContext ctxt = new StreamingContext (StreamingContextStates.All); BinaryFormatter fmt = new BinaryFormatter (null, ctxt); try { using (FileStream stream = new FileStream (path + newext, FileMode.Create, FileAccess.Write)) { fmt.Serialize (stream, obj); } bool exists = File.Exists (path); if (exists) File.Move (path, path + oldext); File.Move (path + newext, path); if (exists) File.Delete (path + oldext); } catch (Exception e) { log.Warning (1006, "Error writing data to " + path + newext, e.Message); File.Delete (path + newext); return true; } return false; }
protected override bool ImportXml(XmlReader xr, IWarningLogger log) { bool gotdir = false; bool gotname = false; int depth = xr.Depth; while (xr.Depth >= depth) { if (xr.NodeType != XmlNodeType.Element) { //Console.WriteLine ("skipping {0}: {1} = \"{2}\"", xr.NodeType, xr.Name, xr.Value); xr.Read(); continue; } switch (xr.Name) { case "result": string ignore; Result r = Result.ImportXml(xr, out ignore, log); if (r == null) { return(true); } if (!(r is MBDirectory)) { log.Warning(3019, "Result embedded in file result is not directory during XML import", null); return(true); } dir = (MBDirectory)r; gotdir = true; break; case "name": name = xr.ReadElementString(); gotname = true; break; default: log.Warning(3019, "Unknown element in file result during XML import", xr.Name); xr.Skip(); break; } } if (!gotdir) { log.Warning(3019, "Did not find directory in file element during XML import", null); return(true); } if (!gotname) { log.Warning(3019, "Did not find name in file element during XML import", null); return(true); } return(false); }
public XmlBackedGraph (XmlDocument doc, IWarningLogger log) { this.doc = doc; nav = doc.CreateNavigator (); this.log = log; }
public XmlBackedGraph(XmlDocument doc, IWarningLogger log) { this.doc = doc; nav = doc.CreateNavigator(); this.log = log; }
// Loading public bool LoadSource(IWarningLogger uilog) { if ((ss = SourceSettings.Load(uilog)) == null) { return(true); } return(false); }
public XmlBackedGraph(string f, IWarningLogger log) { doc = new XmlDocument(); doc.Load(f); nav = doc.CreateNavigator(); this.log = log; }
public bool ApplyTargetDependencies(int tid, ArgCollector ac, IWarningLogger logger) { XmlNodeList nl = Select("/mbuild-graph/targets/t[@id={0}]/deps/*", tid); bool ret; ac.AddTargetName(GetTargetName(tid)); foreach (XmlNode n in nl) { switch (n.Name) { case "dor": ret = ac.AddDefaultOrdered(ReadResult(n), log); break; case "dot": ret = ac.AddDefaultOrdered(GetDepTarget(n), log); break; case "nr": ret = ac.Add(GetDepArg(n), ReadResult(n), log); break; case "nt": ret = ac.Add(GetDepArg(n), GetDepTarget(n), log); break; case "ur": ret = ac.Add(ReadResult(n), log); break; case "ut": ac.Add(GetDepTarget(n)); ret = false; break; case "Dr": ret = ac.SetDefault(GetDepArg(n), ReadResult(n), log); break; case "Dt": ret = ac.SetDefault(GetDepArg(n), GetDepTarget(n), log); break; default: throw new Exception("Unexpected dep element " + n.Name); } if (ret) { return(true); } } return(false); }
public XmlBackedGraph (string f, IWarningLogger log) { doc = new XmlDocument (); doc.Load (f); nav = doc.CreateNavigator (); this.log = log; }
public bool LoadBundles (BundleManager bm, IWarningLogger log) { foreach (System.Reflection.AssemblyName aname in Refs) { if (bm.LoadBundle (aname, log)) return true; } return false; }
//private readonly ITelemetry _telemetry; TODO: Datadog public MunicipalityMatcher(ILatestQueries latestQueries, ManualAddressMatchConfig config, IMapper <MunicipalityLatestItem, TResult> mapper, IWarningLogger warnings)//, ITelemetry telemetry) { _latestQueries = latestQueries; _config = config; _mapper = mapper; _warnings = warnings; //_telemetry = telemetry; }
public bool Add(int aid, Result r, Fingerprint fp, IWarningLogger logger) { if (r == null) { throw new ArgumentNullException(); } return(AddNamed(aid, r, fp, -1, logger)); }
public bool CreateToplevel(string topsrc, string bfname, IWarningLogger uilog) { if ((ss = SourceSettings.CreateToplevel(topsrc, bfname, uilog)) == null) { return(true); } return(false); }
public static FileStateTable Load (string path, IWarningLogger log) { FileStateTable fst; fst = (FileStateTable) SafeFileSerializer.Load (path, log); if (fst == null) fst = new FileStateTable (); return fst; }
public bool ResolveType(string name, out Type t, IWarningLogger log) { if (name == null) { throw new ArgumentNullException(); } if (bm == null) { throw new Exception("Need to set manager before performing type lookup."); } t = null; if (name.IndexOf('.') != -1) { if (bm.LookupType(name, out t, log)) { return(true); } } else { foreach (string ns in namespaces) { Type match = null; if (bm.LookupType(ns + name, out match, log)) { return(true); } if (match == null) { continue; } if (t != null) { string s = String.Format("Ambiguous type reference: {0} could be {1} or {2}", name, t.FullName, match.FullName); log.Error(2022, s, null); return(true); } t = match; } } if (t == null) { log.Error(2022, "Could not resolve type name " + name, null); return(true); } return(false); }
public bool UseIdent (string ident, string declloc, IWarningLogger log) { if (ident[0] == '/') throw new Exception ("Boo"); // UseStructureTemplate (); else if (ident.IndexOf ('/') < 0) return UseNamespace (ident, declloc, log); log.Error (9999, "Don't know how to use[] the identifier", ident); return true; }
public void DecodeInto(TargetBuilder tb, IWarningLogger log) { // This limitation is only because I am lazy and want one character // per BooleanHelper command. if (targets.Length > 10) { throw new InvalidOperationException("Limited to 10 or fewer boolean operands"); } for (int i = 0; i < targets.Length; i++) { tb.AddDefaultOrdered(targets[i]); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < commands.Length; i++) { switch (commands[i]) { case (int)OpCode.Not: sb.Append('!'); break; case (int)OpCode.And: sb.Append('&'); break; case (int)OpCode.Or: sb.Append('|'); break; case 0: sb.Append('0'); break; case 1: sb.Append('1'); break; case 2: sb.Append('2'); break; case 3: sb.Append('3'); break; case 4: sb.Append('4'); break; case 5: sb.Append('5'); break; case 6: sb.Append('6'); break; case 7: sb.Append('7'); break; case 8: sb.Append('8'); break; case 9: sb.Append('9'); break; default: throw new ArgumentException("Don't know how to handle boolean ops command " + commands[i].ToString()); } } tb.AddDep(new MBString(sb.ToString())); }
protected override bool ImportXml(XmlReader xr, IWarningLogger log) { try { value = Convert.FromBase64String(xr.ReadString()); } catch (Exception e) { log.Error(9999, "Fingerprint XML recovery hit invalid format", e.Message); return(true); } return(false); }
public override bool Initialize(WrenchProvider wp, IWarningLogger log, Queue children) { bool ret = false; ret |= wp.DefineConstantTarget("name", new MBString(pinfo.Name), log); ret |= wp.DefineConstantTarget("version", new MBString(pinfo.Version), log); ret |= wp.DefineConstantTarget("compat_code", new MBString(pinfo.CompatCode), log); ret |= wp.DefineConstantTarget("compat-code", new MBString(pinfo.CompatCode), log); return(ret); }
public AddressMatcher( ILatestQueries latestQueries, IMapper <AddressDetailItem, TResult> mapper, IWarningLogger warnings) { _latestQueries = latestQueries; _mapper = mapper; _sanitizer = new Sanitizer { Warnings = warnings }; }
public override bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children) { bool ret = false; ret |= wp.DefineConstantTarget ("name", new MBString (pinfo.Name), log); ret |= wp.DefineConstantTarget ("version", new MBString (pinfo.Version), log); ret |= wp.DefineConstantTarget ("compat_code", new MBString (pinfo.CompatCode), log); ret |= wp.DefineConstantTarget ("compat-code", new MBString (pinfo.CompatCode), log); return ret; }
public static FileStateTable Load(string path, IWarningLogger log) { FileStateTable fst; fst = (FileStateTable)SafeFileSerializer.Load(path, log); if (fst == null) { fst = new FileStateTable(); } return(fst); }
// Returns null and logs an error if the provider at the given // basis has already been defined. public ProviderBuilder DefineProvider (string basis, string decl_loc, IWarningLogger log) { if (providers.ContainsKey (basis)) { log.Error (2043, "Trying to redefine the provider at " + basis, null); return null; } ProviderBuilder pb = CreateProvider (basis); pb.Claim (decl_loc); providers[basis] = pb; return pb; }
public bool AddDefaultOrdered(int target, IWarningLogger logger) { if (default_ordered_id < 0) { logger.Error(2037, "Trying to add a dependency to the default " + "ordered argument, but no default ordered argument is defined", target.ToString()); return(true); } return(Add(default_ordered_id, target, logger)); }
public BuildfileParser (StreamReader reader, string topsrc, string resource_subdir, string location_base, WrenchProvider wp, IWarningLogger log) { lexer = new BuildfileTokenizer (reader); this.topsrc = topsrc; this.resource_subdir = resource_subdir; this.location_base = location_base; this.wp = wp; this.log = log; cur_nlc = wp.NameContext; }
public override bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children) { bool is_top = (basis == "/"); string topsrc = ss.PathToSourceRelative (""); string file = ss.PathToSourceRelative (srcrel); BuildfileParser parser = BuildfileParser.CreateForFile (topsrc, srcrel, wp, log); if (parser.Parse () > 0) // Parse errors return true; // FIXME: tell the parser whether a project[] section is OK and have // it signal the error. That way we get line info. if (!is_top && parser.PInfo != null) { log.Error (2006, "Found a project[] directive in a non-toplevel buildfile", file); return true; } else if (is_top && parser.PInfo == null) { log.Error (2006, "Toplevel buildfile did not have a project[] directive", file); return true; } if (is_top) { // kinda ugly. parser.PInfo.BuildfileName = Path.GetFileName (srcrel); if (((GraphBuilder) wp.Owner).SetProjectInfo (parser.PInfo, log)) return true; children.Enqueue (new ProjectProviderLoader (parser.PInfo)); } foreach (string sub in parser.Subdirs) children.Enqueue (new BuildfileProviderLoader (basis + sub, ss)); foreach (BuildfileParser.InsideInfo ii in parser.Insides) { foreach (string s in ii.Bases) children.Enqueue (new InsideProviderLoader (basis + s, ii.Context)); } if (parser.ManualLoads != null) { foreach (string k in parser.ManualLoads.Keys) { string srel = (string) parser.ManualLoads[k]; children.Enqueue (new BuildfileProviderLoader (basis + k, DeclarationLoc, ss, srel)); } } return false; }
public static BinaryLoadedGraph Load (Stream s, IWarningLogger log) { BinaryLoadedGraph blg = new BinaryLoadedGraph (); try { if (blg.LoadInternal (s, log)) return null; } catch (Exception e) { log.Error (1012, "Unhandled exception during graph load", e.Message); return null; } return blg; }
public TargetTemplate ResolveName (string name, IWarningLogger log) { TargetTemplate tmpl; if (ResolveName (name, out tmpl, log)) return null; if (tmpl == null) { log.Error (2023, "Template lookup failed -- did you forget a using [] directive?", name); return null; } return tmpl; }
public bool LoadRest (IWarningLogger uilog) { if ((log = ActionLog.Load (ss, uilog)) == null) return true; if ((graph = GetGraph ()) == null) return true; if (ProfileStateUsage) graph = new GraphStateProfiler (graph); proj = new WrenchProject (ss, graph, log); return false; }
public bool SetManager (BundleManager bm, IWarningLogger logger) { if (bm == null) throw new ArgumentNullException (); if (this.bm != null) throw new Exception ("Already have manager set"); this.bm = bm; // This is pretty weak. foreach (string ns in nsqueue.Keys) if (UseNamespace (ns, nsqueue[ns], logger)) return true; return false; }
bool LoadBundle (AssemblyName aname, IWarningLogger logger, bool expecting_bundle) { Assembly assy; if (this[aname] != null) return false; try { assy = System.AppDomain.CurrentDomain.Load (aname); } catch (Exception e) { logger.Error (2020, "Could not load the referenced assembly " + aname.ToString (), String.Format ("{0}: {1}", e.GetType (), e.Message)); return true; } return LoadBundle (assy, aname.Version, logger, expecting_bundle); }
public bool Finish (BundleManager bm, IWarningLogger log) { if (DeclarationLoc == null) throw ExHelp.App ("WP Finish, basis {0}", Basis); if (namecontext.SetManager (bm, log)) return true; if (DoneRequesting (namecontext, log)) return true; foreach (WrenchTarget wt in DefinedTargets) { if (wt.DoFixup (namecontext, log)) return true; } return false; }
public static BuildfileParser CreateForFile (string topsrc, string srcrel, WrenchProvider wp, IWarningLogger log) { string file = Path.Combine (topsrc, srcrel); string resdir = Path.GetDirectoryName (srcrel); if (resdir.Length == 0) resdir = "."; FileStream fs = new FileStream (file, FileMode.Open, FileAccess.Read); BufferedStream bs = new BufferedStream (fs); StreamReader reader = new StreamReader (bs); BuildfileParser p = new BuildfileParser (reader, topsrc, resdir, file, wp, log); p.AddResourceFile (Path.GetFileName (srcrel)); return p; }
bool LoadInternal (Stream s, IWarningLogger log) { BinaryReader br = new BinaryReader (s); // 4-byte identification header. byte[] b = br.ReadBytes (4); if (b[0] != (byte) 'M' || b[1] != (byte) 'B' || b[2] != (byte) 'G' || b[3] != BinaryFormatIdent) { log.Error (1012, "Invalid header in saved graph file", null); return true; } // 32-bit int check for endianness if (BinaryHelper.ReadRawInt (br) != 0x01B2C3D4) { log.Error (1012, "Endianness change in saved graph file", null); return true; } // Actual data ReadProjectInfo (br); BinaryHelper.ExpectDelimiter (br); ReadDependents (br); BinaryHelper.ExpectDelimiter (br); ReadTags (br); BinaryHelper.ExpectDelimiter (br); ReadTargetTables (br); BinaryHelper.ExpectDelimiter (br); ReadProviders (br); BinaryHelper.ExpectDelimiter (br); ReadTagTable (br); BinaryHelper.ExpectDelimiter (br); ReadTypeTable (br); BinaryHelper.ExpectDelimiter (br); ReadResultTable (br); return false; }
public bool LookupType (string name, out Type t, IWarningLogger logger) { // We need the out parameter because returning null could either mean // "no match" (ok) or "error during lookup" (bad, and we should stop). // Currently, the only error condition is that the type is defined // more than one bundle; it is annoying to have to make all the callers // of this function jump through hoops, but it is the kind of circumstance // that can occur. if (name == null) throw new ArgumentNullException (); //if (!StrUtils.StartsWith (name, MBuildPrefix)) //name = MBuildPrefix + name; t = null; // efficiency? hah! foreach (Assembly assy in BundleAssemblies) { Type match = assy.GetType (name); if (match == null) continue; if (t != null) { logger.Error (2024, String.Format ("Two assemblies define the type" + "{0}: {1} and {2}", name, t.Assembly.FullName, assy.FullName), null); return true; } t = match; } return false; }
public bool TryMatch (string name, MatcherKind kind, out TargetTemplate tmpl, IWarningLogger log) { tmpl = null; IMatcher which = null; int quality = 0; IEnumerable<IMatcher> mlist = GetMatchers (kind, log); if (mlist == null) return true; foreach (IMatcher m in mlist) { int q; TargetTemplate match = m.TryMatch (name, out q); if (match == null) continue; if (q < quality) continue; if (tmpl != null && q == quality) { // FIXME: provide a way to specify which one should take priority! string s = String.Format ("Two matches succeed with equal quality: " + "{0} and {1}; going with the first", which, m); log.Warning (2026, s, name); break; } which = m; tmpl = match; quality = q; } return false; }
public abstract bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children);
protected override bool ImportXml (XmlReader xr, IWarningLogger log) { try { value = Convert.FromBase64String (xr.ReadString ()); } catch (Exception e) { log.Error (9999, "Fingerprint XML recovery hit invalid format", e.Message); return true; } return false; }
public abstract bool ResolveName (string name, out TargetTemplate tmpl, IWarningLogger log);
protected override bool ImportXml (XmlReader xr, IWarningLogger log) { bool gotdir = false; bool gotname = false; int depth = xr.Depth; while (xr.Depth >= depth) { if (xr.NodeType != XmlNodeType.Element) { //Console.WriteLine ("skipping {0}: {1} = \"{2}\"", xr.NodeType, xr.Name, xr.Value); xr.Read (); continue; } switch (xr.Name) { case "result": string ignore; Result r = Result.ImportXml (xr, out ignore, log); if (r == null) return true; if (!(r is MBDirectory)) { log.Warning (3019, "Result embedded in file result is not directory during XML import", null); return true; } dir = (MBDirectory) r; gotdir = true; break; case "name": name = xr.ReadElementString (); gotname = true; break; default: log.Warning (3019, "Unknown element in file result during XML import", xr.Name); xr.Skip (); break; } } if (!gotdir) { log.Warning (3019, "Did not find directory in file element during XML import", null); return true; } if (!gotname) { log.Warning (3019, "Did not find name in file element during XML import", null); return true; } return false; }