/// <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 CruiseControlException(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; }
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 LoadFromString(string xml) { NetReflectorReader r = new NetReflectorReader(MakeTypeTable()); XmlReader reader = XmlReader.Create(new StringReader(xml)); try { r.Read(reader, this); } finally { reader.Close(); } }
public void Load(string path) { NetReflectorReader r = new NetReflectorReader(MakeTypeTable()); XmlReader reader = XmlReader.Create(path); try { r.Read(reader, this); } finally { reader.Close(); } }
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 DeserializeOne_CustomSortRules_Before_SortUsing() { NetReflectorTypeTable t = new NetReflectorTypeTable(); t.Add(typeof(WritingSystem_V1)); NetReflectorReader r = new NetReflectorReader(t); WritingSystem_V1 ws = (WritingSystem_V1) r.Read( "<WritingSystem><CustomSortRules>test</CustomSortRules><SortUsing>CustomSimple</SortUsing><FontName>Tahoma</FontName><FontSize>99</FontSize><Id>one</Id></WritingSystem>"); Assert.IsNotNull(ws); Assert.AreEqual("test", ws.CustomSortRules); Assert.AreEqual(WritingSystem_V1.CustomSortRulesType.CustomSimple.ToString(), ws.SortUsing); }
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 void DeserializeOne() { NetReflectorTypeTable t = new NetReflectorTypeTable(); t.Add(typeof(WritingSystem_V1)); NetReflectorReader r = new NetReflectorReader(t); WritingSystem_V1 ws = (WritingSystem_V1) r.Read( @"<WritingSystem> <Abbreviation>xx</Abbreviation> <CustomSortRules>B c d R</CustomSortRules> <FontName>Tahoma</FontName> <FontSize>99</FontSize> <Id>one</Id> <IsAudio>False</IsAudio> <IsUnicode>True</IsUnicode> <WindowsKeyman>IPA Unicode 5.1(ver 1.2 US) MSK</WindowsKeyman> <RightToLeft>False</RightToLeft> <SortUsing>one</SortUsing> <SpellCheckingId>xx</SpellCheckingId> </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("xx", ws.Abbreviation); Assert.AreEqual("B c d R", ws.CustomSortRules); #if __MonoCS__ // Tahoma should not be available on Linux // Checking that what you asked for is in the ws // and what you get is the standard DejaVu Sans font Assert.AreEqual(font.OriginalFontName, ws.FontName); Assert.AreEqual(font.Name, "DejaVu Sans"); #else Assert.AreEqual(font.Name, ws.FontName); #endif Assert.AreEqual(font.Size, ws.FontSize); Assert.AreEqual("one", ws.ISO); Assert.AreEqual(false, ws.IsAudio); Assert.AreEqual(true, ws.IsUnicode); Assert.AreEqual("IPA Unicode 5.1(ver 1.2 US) MSK", ws.KeyboardName); Assert.AreEqual(false, ws.RightToLeft); Assert.AreEqual("one", ws.SortUsing); Assert.AreEqual("xx", ws.SpellCheckingId); }
/// <summary> /// Initializes a new instance of the <see cref="NetReflectorConfigurationReader" /> class. /// </summary> /// <remarks></remarks> 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 CustomSortRules_SerializeAndDeserialize() { WritingSystem_V1 ws = new WritingSystem_V1("one", new Font("Arial", 99)); ws.SortUsing = WritingSystem_V1.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_V1)); NetReflectorReader r = new NetReflectorReader(t); WritingSystem_V1 wsRead = (WritingSystem_V1)r.Read(s); Assert.IsNotNull(wsRead); Assert.AreEqual(rules, ws.CustomSortRules); }
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); }
public void LoadFromLegacyWeSayFile(string PathToWritingSystemPrefsFile) { if (WeSayWritingSystemsPrefsExist(PathToWritingSystemPrefsFile)) { NetReflectorReader r = new NetReflectorReader(MakeTypeTable()); XmlReader reader = XmlReader.Create(PathToWritingSystemPrefsFile); var wesayWsFileCollection = new WritingSystemCollection_V1(); try { r.Read(reader, wesayWsFileCollection); } finally { reader.Close(); } foreach (KeyValuePair <string, WritingSystem_V1> pair in wesayWsFileCollection) { if (!ContainsKey(pair.Key)) { Add(pair.Key, pair.Value); } } } }