コード例 #1
0
 public void InvalidTypeWhenGetting() {
     ExceptionAssert.Throws<ArgumentException>(() => {
         HttpApplicationStateBase appState = new HttpApplicationStateWrapper(Activator.CreateInstance(typeof(HttpApplicationState), true) as HttpApplicationState);
         dynamic d = new DynamicHttpApplicationState(appState);
         var x = d[new object()];
     }, WebPageResources.DynamicHttpApplicationState_UseOnlyStringOrIntToGet);
 }
コード例 #2
0
        public void InvalidNumberOfIndexes() {
            ExceptionAssert.Throws<ArgumentException>(() => {
                HttpApplicationStateBase appState = new HttpApplicationStateWrapper(Activator.CreateInstance(typeof(HttpApplicationState), true) as HttpApplicationState);
                dynamic d = new DynamicHttpApplicationState(appState);
                d[1, 2] = 3;
            }, WebPageResources.DynamicDictionary_InvalidNumberOfIndexes);

            ExceptionAssert.Throws<ArgumentException>(() => {
                HttpApplicationStateBase appState = new HttpApplicationStateWrapper(Activator.CreateInstance(typeof(HttpApplicationState), true) as HttpApplicationState);
                dynamic d = new DynamicHttpApplicationState(appState);
                var x = d[1, 2];
            }, WebPageResources.DynamicDictionary_InvalidNumberOfIndexes);
        }
コード例 #3
0
 public void DynamicTest() {
     HttpApplicationStateBase appState = new HttpApplicationStateWrapper(Activator.CreateInstance(typeof(HttpApplicationState), true) as HttpApplicationState);
     dynamic d = new DynamicHttpApplicationState(appState);
     d["x"] = "y";
     Assert.AreEqual("y", d.x);
     Assert.AreEqual("y", d[0]);
     d.a = "b";
     Assert.AreEqual("b", d["a"]);
     d.Foo = "bar";
     Assert.AreEqual("bar", d.Foo);
     Assert.AreEqual(null, d.XYZ);
     Assert.AreEqual(null, d["xyz"]);
     ExceptionAssert.Throws<ArgumentOutOfRangeException>(() => {
         var x = d[5];
     });
 }
コード例 #4
0
ファイル: Bootstrapper.cs プロジェクト: divyang4481/REM
        /// <summary>
        /// Creates the and configure application di container.
        /// </summary>
        /// <returns>
        /// A StructureMap Container.
        /// </returns>
        protected override IContainer CreateAndConfigureApplicationDiContainer()
        {
            var appContainer = base.CreateAndConfigureApplicationDiContainer();

            var applicationState = new HttpApplicationStateWrapper(_applicationState);
            appContainer.Configure(x => x.For<HttpApplicationStateBase>().Singleton().Use(applicationState));

            return appContainer;
        }