コード例 #1
0
        /// <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;
        }
コード例 #2
0
 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);
 }
コード例 #3
0
ファイル: ViewTemplate.cs プロジェクト: ermshiperete/wesay
        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();
            }
        }
コード例 #4
0
ファイル: ViewTemplate.cs プロジェクト: ermshiperete/wesay
        public void Load(string path)
        {
            NetReflectorReader r      = new NetReflectorReader(MakeTypeTable());
            XmlReader          reader = XmlReader.Create(path);

            try
            {
                r.Read(reader, this);
            }
            finally
            {
                reader.Close();
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 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);
             }
         }
     }
 }