예제 #1
0
        public void ShouldUseInstantiatorThatHasBeenSet()
        {
            TestInstantiator instantiator = new TestInstantiator();

            table = NetReflectorTypeTable.CreateDefault(instantiator);
            ReadCollectionTestClass();
            Assert.AreEqual(4, instantiator.instantiateCallCount);
        }
        public void ShouldUseInstantiatorThatHasBeenSet()
        {
            TestInstantiator instantiator = new TestInstantiator();

            table = NetReflectorTypeTable.CreateDefault(instantiator);
            ReadTestHashClassContainingElements();
            Assert.AreEqual(4, instantiator.instantiateCallCount);
        }
        private NetReflectorTypeTable GetTypeTable()
        {
            NetReflectorTypeTable newTypeTable = NetReflectorTypeTable.CreateDefault(instantiator);

            // split the relative search path only by ';', thats also valid with Mono on Unix
            foreach (string searchPathDir in AppDomain.CurrentDomain.RelativeSearchPath.Split(';'))
            {
                newTypeTable.Add(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, searchPathDir), CONFIG_ASSEMBLY_PATTERN);
            }
            newTypeTable.Add(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), CONFIG_ASSEMBLY_PATTERN);
            return(newTypeTable);
        }
예제 #4
0
        public void TestSomething()
        {
            SimpleDependency dependency     = new SimpleDependency("Hello NetReflector");
            ObjectionStore   objectionStore = new ObjectionStore();

            objectionStore.AddInstanceForType(typeof(SimpleDependency), dependency);

            string serializedForm = @"<mySerializableType myProperty=""MyValue"" />";

            NetReflectorTypeTable typeTable = NetReflectorTypeTable.CreateDefault(new ObjectionNetReflectorInstantiator(objectionStore));

            SerializableType deserialized = (SerializableType)NetReflector.Read(serializedForm, typeTable);

            Assert.AreEqual("MyValue", deserialized.MyProperty);
            Assert.IsNotNull("Hello NetReflector", deserialized.DependencyObject.Message);
        }
        private object Load(string xpath)
        {
            string dashboardConfig = "";

            using (StreamReader sr = new StreamReader(CalculateDashboardConfigPath()))
            {
                dashboardConfig = sr.ReadToEnd();
            }

            XmlNode node = XmlUtil.SelectNode(dashboardConfig, xpath);

            NetReflectorTypeTable typeTable = NetReflectorTypeTable.CreateDefault(instantiator);

            typeTable.Add(Path.GetDirectoryName(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.RelativeSearchPath)), "ccnet.*.plugin.dll");
            typeTable.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ccnet.*.plugin.dll");

            return(NetReflector.Read(node, typeTable));
        }
예제 #6
0
 public void Setup()
 {
     table = NetReflectorTypeTable.CreateDefault();
 }