Add() public method

public Add ( AppDomain appDomain ) : void
appDomain System.AppDomain
return void
 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 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 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);
        }
		protected override void ExecuteTask()
		{
			Log(Level.Info, "Loading assembly {0}.", assembly);
			NetReflectorTypeTable table = new NetReflectorTypeTable();
			table.Add(assembly);
			Log(Level.Info, "Loaded {0} types.", table.Count);

			Log(Level.Info, "Generating documentation. The output will be written to {0}", outfile);
			using (StreamWriter writer = new StreamWriter(outfile))
			{
				new XmlDocumentationGenerator(table).WriteIndented(writer);				
			}
		}
Exemplo n.º 6
0
		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);
		}
Exemplo n.º 7
0
		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);
		}
Exemplo n.º 8
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);
        }
		private static void SetupDefaultTable(NetReflectorTypeTable table)
		{
			table.Add(AppDomain.CurrentDomain);
		}
Exemplo n.º 10
0
        public void PreprocessParametersAddsDirectValueForValidDoublyNestedMixedDynamicValuesNodes()
        {
            var document = new XmlDocument();
            var xml = "<item attrib=\"value\"><subItems><subItem><subSubItemsDV><subSubItemDV><prop>$[value]</prop></subSubItemDV></subSubItemsDV><prop>$[value2]</prop></subItem></subItems></item>";
            document.LoadXml(xml);

            var task = new TestTask();
            NetReflectorTypeTable typeTable = new NetReflectorTypeTable();
            typeTable.Add(typeof(Item));
            typeTable.Add(typeof(SubItem));
            typeTable.Add(typeof(SubItemDV));
            typeTable.Add(typeof(subSubItemDV));
            var actual = task.PreprocessParameters(typeTable, document.DocumentElement);
            var expected = "<item attrib=\"value\"><subItems><subItem><subSubItemsDV>" +
                    "<subSubItemDV>" +
                        "<prop></prop>" +
                        "<dynamicValues>" +
                            "<directValue>" +
                                "<parameter>value</parameter>" +
                                "<property>prop</property>" +
                            "</directValue>" +
                        "</dynamicValues>" +
                    "</subSubItemDV>" +
                "</subSubItemsDV>" +
                "<prop></prop>" +
                "</subItem></subItems>" +
                "<dynamicValues>" +
                    "<directValue>" +
                        "<parameter>value2</parameter>" +
                        "<property>subItems[0].prop</property>" +
                    "</directValue>" +
                "</dynamicValues>" +
                "</item>";
            Assert.AreEqual(expected, actual.OuterXml);
        }
Exemplo n.º 11
0
        public void PreprocessParametersAddsDirectValueForValidNestedNodesDynamicValueWithoutDefaultWithComment()
        {
            var document = new XmlDocument();
            var xml = "<item attrib=\"value\"><subItems><subItem>$[value]</subItem><!-- this is a comment --><subItem>$[value2]</subItem></subItems></item>";
            document.LoadXml(xml);

            var task = new TestTask();
            NetReflectorTypeTable typeTable = new NetReflectorTypeTable();
            typeTable.Add(typeof(Item));
            var actual = task.PreprocessParameters(typeTable, document.DocumentElement);
            var expected = "<item attrib=\"value\"><subItems><subItem></subItem><!-- this is a comment --><subItem></subItem></subItems>" +
                "<dynamicValues>" +
                    "<directValue>" +
                        "<parameter>value</parameter>" +
                        "<property>subItems[0]</property>" +
                    "</directValue>" +
                    "<directValue>" +
                        "<parameter>value2</parameter>" +
                        "<property>subItems[1]</property>" +
                    "</directValue>" +
                "</dynamicValues></item>";
            Assert.AreEqual(expected, actual.OuterXml);
        }
Exemplo n.º 12
0
 private static void SetupDefaultTable(NetReflectorTypeTable table)
 {
     table.Add(AppDomain.CurrentDomain);
 }
        /// <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;
        }
Exemplo n.º 14
0
		public void DeserializeInventoryFromXmlString()
		{
			NetReflectorTypeTable t = new NetReflectorTypeTable();
			t.Add(typeof (Field));
			t.Add(typeof (ViewTemplate));

			ViewTemplate f = new ViewTemplate();
			f.LoadFromString(TestResources.viewTemplate);
			CheckInventoryMatchesDefinitionInResource(f);
		}
Exemplo n.º 15
0
		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);
		}
Exemplo n.º 16
0
		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);
		}
Exemplo n.º 17
0
        public void PreprocessParametersAddsDirectValueForValidDoublyNestedNodesDynamicValueWithoutDefaultWithTextFirstAndMiddleChild()
        {
            var document = new XmlDocument();
            var xml = "<item attrib=\"value\"><subItems><subItem><subSubItems>some text<subSubItem><value>$[value]</value></subSubItem>some text<subSubItem><value>$[value2]</value></subSubItem></subSubItems></subItem></subItems></item>";
            document.LoadXml(xml);

            var task = new TestTask();
            NetReflectorTypeTable typeTable = new NetReflectorTypeTable();
            typeTable.Add(typeof(Item));
            typeTable.Add(typeof(SubItem));
            typeTable.Add(typeof(subSubItem));
            var actual = task.PreprocessParameters(typeTable, document.DocumentElement);
            var expected = "<item attrib=\"value\"><subItems><subItem><subSubItems>some text<subSubItem><value></value></subSubItem>some text<subSubItem><value></value></subSubItem></subSubItems></subItem></subItems>" +
                "<dynamicValues>" +
                    "<directValue>" +
                        "<parameter>value</parameter>" +
                        "<property>subItems[0].subSubItems[0].value</property>" +
                    "</directValue>" +
                    "<directValue>" +
                        "<parameter>value2</parameter>" +
                        "<property>subItems[0].subSubItems[1].value</property>" +
                    "</directValue>" +
                "</dynamicValues></item>";
            Assert.AreEqual(expected, actual.OuterXml);
        }