29 using System.Collections.Generic;
32 using System.Reflection;
36 namespace OpenSim.Data.Tests
52 static class DefaultTestConns
54 private static Dictionary<Type, string> conns =
new Dictionary<Type, string>();
56 public static string Get(Type connType)
60 if (conns.TryGetValue(connType, out sConn))
63 Assembly
asm = Assembly.GetExecutingAssembly();
64 string sType = connType.Name;
70 string[] allres = asm.GetManifestResourceNames();
71 string sResFile = Array.Find(allres, s => s.Contains(
"TestDataConnections.ini"));
73 if (
String.IsNullOrEmpty(sResFile))
74 throw new Exception(
String.Format(
"Please add resource TestDataConnections.ini, with section [TestConnections] and settings like {0}=\"...\"",
77 using (Stream resource = asm.GetManifestResourceStream(sResFile))
79 IConfigSource source =
new IniConfigSource(resource);
80 var cfg = source.Configs[
"TestConnections"];
81 sConn = cfg.Get(sType,
"");
84 if (!
String.IsNullOrEmpty(sConn))
85 conns[connType] = sConn;