public NetReflectorConfigurationReader() { typeTable = new NetReflectorTypeTable(); typeTable.Add(AppDomain.CurrentDomain); typeTable.Add(Directory.GetCurrentDirectory(), CONFIG_ASSEMBLY_PATTERN); typeTable.InvalidNode += new InvalidNodeEventHandler(HandleUnusedNode); reader = new NetReflectorReader(typeTable); }
public void LoadsFromXml() { NetReflectorTypeTable typeTable = new NetReflectorTypeTable(); typeTable.Add(AppDomain.CurrentDomain); NetReflectorReader reader = new NetReflectorReader(typeTable); object result = reader.Read("<fileBasedCache duration=\"5\" mode=\"Fixed\"/>"); Assert.IsInstanceOfType(typeof(FileBasedSessionCache), result); FileBasedSessionCache cache = result as FileBasedSessionCache; Assert.AreEqual(5, cache.Duration); Assert.AreEqual(SessionExpiryMode.Fixed, cache.ExpiryMode); }
public void LoadsFromXml() { NetReflectorTypeTable typeTable = new NetReflectorTypeTable(); typeTable.Add(AppDomain.CurrentDomain); NetReflectorReader reader = new NetReflectorReader(typeTable); object result = reader.Read("<inMemoryCache duration=\"5\" mode=\"Fixed\"/>"); Assert.That(result, Is.InstanceOf<InMemorySessionCache>()); InMemorySessionCache cache = result as InMemorySessionCache; Assert.AreEqual(5, cache.Duration); Assert.AreEqual(SessionExpiryMode.Fixed, cache.ExpiryMode); }
public NetReflectorConfigurationReader() { typeTable = new NetReflectorTypeTable(); typeTable.Add(AppDomain.CurrentDomain); string pluginLocation = ConfigurationManager.AppSettings["PluginLocation"]; if (!string.IsNullOrEmpty(pluginLocation)) { if (Directory.Exists(pluginLocation)) { typeTable.Add(pluginLocation, CONFIG_ASSEMBLY_PATTERN); } else { throw new CruiseControlException("Unable to find plugin directory: " + pluginLocation); } } typeTable.Add(Directory.GetCurrentDirectory(), CONFIG_ASSEMBLY_PATTERN); reader = new NetReflectorReader(typeTable); }
public void DeserializeOne() { NetReflectorTypeTable t = new NetReflectorTypeTable(); t.Add(typeof (WritingSystem)); NetReflectorReader r = new NetReflectorReader(t); WritingSystem ws = (WritingSystem) r.Read( "<WritingSystem><FontName>Tahoma</FontName><FontSize>99</FontSize><Id>one</Id><SortUsing>one</SortUsing></WritingSystem>"); // since Linux may not have Tahoma, we // need to test against the font mapping Font font = new Font("Tahoma", 99); Assert.IsNotNull(ws); Assert.AreEqual(font.Name, ws.FontName); Assert.AreEqual("one", ws.Id); Assert.AreEqual(font.Size, ws.FontSize); }
public void DeserializeOne_NonCustomSortUsing_Before_CustomSortRules() { NetReflectorTypeTable t = new NetReflectorTypeTable(); t.Add(typeof (WritingSystem)); NetReflectorReader r = new NetReflectorReader(t); WritingSystem ws = (WritingSystem) r.Read( "<WritingSystem><SortUsing>one</SortUsing><CustomSortRules>test</CustomSortRules><FontName>Tahoma</FontName><FontSize>99</FontSize><Id>one</Id></WritingSystem>"); Assert.IsNotNull(ws); Assert.IsNull(ws.CustomSortRules); Assert.AreEqual("one", ws.SortUsing); }
public void CustomSortRules_SerializeAndDeserialize() { WritingSystem ws = new WritingSystem("one", new Font("Arial", 99)); ws.SortUsing = CustomSortRulesType.CustomICU.ToString(); string rules = "&n < ng <<< Ng <<< NG"; ws.CustomSortRules = rules; string s = NetReflector.Write(ws); NetReflectorTypeTable t = new NetReflectorTypeTable(); t.Add(typeof (WritingSystem)); NetReflectorReader r = new NetReflectorReader(t); WritingSystem wsRead = (WritingSystem) r.Read(s); Assert.IsNotNull(wsRead); Assert.AreEqual(rules, ws.CustomSortRules); }
public void DeserializeCollection() { NetReflectorTypeTable t = new NetReflectorTypeTable(); t.Add(typeof (WritingSystemCollection)); t.Add(typeof (WritingSystem)); NetReflectorReader r = new NetReflectorReader(t); WritingSystemCollection c = r.Read(MakeXmlFromCollection()) as WritingSystemCollection; Assert.IsNotNull(c); Assert.AreEqual(2, c.Values.Count); }
private void InitialiseConfigReader() { myTypeTable = new NetReflectorTypeTable(); Assembly thisAssembly = typeof(IProject).Assembly; myTypeTable.Add(thisAssembly); foreach (AssemblyName referencedAssembly in thisAssembly.GetReferencedAssemblies()) { myTypeTable.Add(Assembly.Load(referencedAssembly)); } var pluginLocation = System.Configuration.ConfigurationManager.AppSettings["PluginLocation"]; if (!string.IsNullOrEmpty(pluginLocation)) { if (Directory.Exists(pluginLocation)) { myTypeTable.Add(pluginLocation, CONFIG_ASSEMBLY_PATTERN); } } try { myTypeTable.Add(Directory.GetCurrentDirectory(), CONFIG_ASSEMBLY_PATTERN); } catch (Exception error) { MessageBox.Show( "Unable to load one or more plug-ins: " + error.Message, "Plug-in Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } myTypeTable.InvalidNode += delegate(InvalidNodeEventArgs args) { throw new NetReflectorException(args.Message); }; myConfigReader = new NetReflectorReader(myTypeTable); }
/// <summary> /// Initialise the security manager. /// </summary> public override void Initialise() { if (!isInitialised) { // Initialise the reader typeTable = new NetReflectorTypeTable(); typeTable.Add(AppDomain.CurrentDomain); typeTable.Add(Directory.GetCurrentDirectory(), CONFIG_ASSEMBLY_PATTERN); typeTable.InvalidNode += delegate(InvalidNodeEventArgs args) { throw new Exception(args.Message); }; reflectionReader = new NetReflectorReader(typeTable); // Initialise the local caches SessionCache.Initialise(); loadedUsers = new Dictionary<string, IAuthentication>(); wildCardUsers = new List<IAuthentication>(); loadedPermissions = new Dictionary<string, IPermission>(); // Load each file settingFileMap = new Dictionary<string, string>(); foreach (string fileName in files) { LoadFile(fileName); } } isInitialised = true; }