• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SessionState.SessionStateItemCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.SessionState.SessionStateItemCollection的典型用法代码示例。如果您正苦于以下问题:C# SessionStateItemCollection类的具体用法?C# SessionStateItemCollection怎么用?C# SessionStateItemCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SessionStateItemCollection类属于System.Web.SessionState命名空间,在下文中一共展示了SessionStateItemCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FakeControllerContext

        public FakeControllerContext(
            IController controller,
            string userName = null,
            string[] roles = null,
            NameValueCollection formParams = null,
            NameValueCollection queryStringParams = null,
            HttpCookieCollection cookies = null,
            SessionStateItemCollection sessionItems = null,
            NameValueCollection headers = null,
			Uri uri = null
            )
            : base(new FakeHttpContext(
                    new FakePrincipal(
                        new FakeIdentity(userName), 
                        roles), 
                    formParams, 
                    queryStringParams, 
                    cookies, 
                    sessionItems,
                    headers,
					uri), 
                new RouteData(), 
                controller as ControllerBase)
        {
        }
开发者ID:ItWorksOnMyMachine,项目名称:RowanPAdams,代码行数:25,代码来源:FakeControllerContext.cs


示例2: TestUpdates

        public void TestUpdates()
        {
            SessionStateItemCollection items = new SessionStateItemCollection();
            items["Val1"] = "value";
            byte[] serializedItems = Serialize(items);
            Binary b = new Binary(serializedItems);
            List<string> ids = new List<string>();
            ICursor allSessions;
            using (var mongo = new Mongo(config))
            {
                mongo.Connect();
                allSessions = mongo["session_store"]["sessions"].FindAll();
                foreach (Document session in allSessions.Documents)
                {
                    string id = (string)session["SessionId"];
                    ids.Add(id);

                }
            }
            foreach (string s in ids)
            {
                var sessionStore = new SessionStore("test");
                sessionStore.UpdateSession(s, 2, b, "AppName", items.Count, 0);
            }
        }
开发者ID:GunioRobot,项目名称:MongoSessionStore,代码行数:25,代码来源:ConnectionTest.cs


示例3: MongoSessionDocument

        public MongoSessionDocument()
        {
            ApplicationName = "WinDemo.Mongodb";
            LockId = 0;
            Locked = false;
            Flags = 0;
            User = "ZYTestUser";
            Timeout = 50;
            Created = DateTime.UtcNow;
            LockDate = DateTime.UtcNow;
            Expires = Created.AddMinutes(Timeout);

            SessionStateItemCollection col = new SessionStateItemCollection();
            col["key1"] = new
            {
                ID = new Random().Next(100, 100000),
                Name = "ZY",
                Age = 11
            };
            col["key2"] = new
            {
                ID = new Random().Next(100, 100000),
                Name = "ZY",
                Age = 11
            };
            SessionItems = col;
        }
开发者ID:VqSoft,项目名称:VqDemos,代码行数:27,代码来源:MongoSessionDocument.cs


示例4: FakeHttpContext

 public FakeHttpContext(string relativeUrl, 
     IPrincipal principal, NameValueCollection formParams,
     NameValueCollection queryStringParams, HttpCookieCollection cookies,
     SessionStateItemCollection sessionItems, NameValueCollection serverVariables)
     : this(relativeUrl, null, principal, formParams, queryStringParams, cookies, sessionItems, serverVariables)
 {
 }
开发者ID:SeptemberWind,项目名称:AlvisFrameworkProject,代码行数:7,代码来源:FakeHttpContext.cs


示例5: GetItem

        public override SessionStateStoreData GetItem(HttpContext context,
				string id,
				out bool locked,
				out TimeSpan lockAge,
				out object lockId,
				out SessionStateActions actions)
        {
            var redis = GetRedisConnection();
            var getSessionData = redis.Hashes.GetAll(0, GetKeyForSessionId(id));
            locked = false;
            lockAge = new TimeSpan(0);
            lockId = null;
            actions = SessionStateActions.None;

            if (getSessionData.Result == null) {
                return null;
            }
            else {
                var sessionItems = new SessionStateItemCollection();
                var sessionDataHash = getSessionData.Result;
                if (sessionDataHash.Count == 3) {
                    sessionItems = Deserialize(sessionDataHash["data"]);

                    var timeoutMinutes = BitConverter.ToInt32(sessionDataHash["timeoutMinutes"], 0);
                    redis.Keys.Expire(0, GetKeyForSessionId(id), timeoutMinutes * 60);
                }

                return new SessionStateStoreData(sessionItems,
                     SessionStateUtility.GetSessionStaticObjects(context),
                     redisConfig.SessionTimeout);
            }
        }
开发者ID:rbwestmoreland,项目名称:AL-Redis,代码行数:32,代码来源:RedisSessionStateStore.cs


示例6: FakeHttpContext

        public FakeHttpContext(
            IPrincipal principal,
            IFormParamsProvider formParams,
            IQueryStringParamsProvider queryStringParams,
            ICookieProvider cookies,
            IServerVariablesParamsProvider serverVariablesParams,
            IHeadersParamsProvider headersParams,
            SessionStateItemCollection sessionItems,
            HttpServerUtilityBase server,
            FakeHttpRequest request,
            IHttpContextBehavior contextBehavior)
        {
            User = principal;
            _sessionItems = sessionItems ?? new SessionStateItemCollection();
            _request = request ?? new FakeHttpRequest(formParams, queryStringParams, cookies, serverVariablesParams, headersParams);
            _request.SetIsAuthenticated(User.Identity != null ? User.Identity.IsAuthenticated : false);
            _server = server ?? new Mock<HttpServerUtilityBase>().Object;

            var httpResponse = new Mock<HttpResponseBase>();
            httpResponse.Setup(x => x.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(s => s);
            _response = httpResponse.Object;

            _behavior = contextBehavior;

            _items = new Hashtable();
        }
开发者ID:mira-network,项目名称:SpecsFor,代码行数:26,代码来源:FakeHttpContext.cs


示例7: GetItem

        /// <summary>
        /// Called when SessionState = ReadOnly
        /// </summary>
        public override SessionStateStoreData GetItem(HttpContext context, string id, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actions)
        {
            RedisConnection redisConnection = ConnectionUtils.Connect("10.0.0.3:6379");
            {
                redisConnection.Open();

                var result = redisConnection.Strings.Get(0, id);
                byte[] raw = redisConnection.Wait(result);

                actions = SessionStateActions.None;

                SessionEntity sessionEntity = GetFromBytes(raw);
                if (sessionEntity == null || sessionEntity.SessionItems == null )
                {
                    locked = false;
                    lockId = _lock;
                    lockAge = TimeSpan.MinValue;
                    return null;
                }

                ISessionStateItemCollection sessionItems = new SessionStateItemCollection();
                foreach (string key in sessionEntity.SessionItems.Keys)
                {
                    sessionItems[key] = sessionEntity.SessionItems[key];
                }

                SessionStateStoreData data = new SessionStateStoreData(sessionItems, _staticObjects, context.Session.Timeout);

                locked = false;
                lockId = _lock;
                lockAge = TimeSpan.MinValue;
                return data;
            }
        }
开发者ID:ThomasSchmidt,项目名称:MixedStuff,代码行数:37,代码来源:RedisSessionStateStoreProvider.cs


示例8: ExpectedRavenDbCallsAreMade

        public void ExpectedRavenDbCallsAreMade()
        {
            // Arrange
            string expectedAppName = "You are everything ... to me";
            string appPath = "Application path";
            var subject = TestStoreProviderFactory.SetupStoreProvider(appPath, MockHostingProvider);
            NameValueCollection keyPairs = new NameValueCollection();
            keyPairs.Set("applicationName", expectedAppName);
            object lockId = 0;

            string providedSessionId = "A sessionId";

            SessionStateDocument sessionObject = TestSessionDocumentFactory.CreateSessionStateDocument(providedSessionId, expectedAppName);
            sessionObject.Expiry = DateTime.UtcNow.AddDays(1);

            var sessionItems = new SessionStateItemCollection();

            sessionItems["ACar"] = new Car("A6", "Audi");

            sessionObject.SessionItems = subject.Serialize(sessionItems);

            SessionStateStoreData item = RavenSessionStateStoreProvider.Deserialize(null, sessionObject.SessionItems, 10);

            MockDocumentSession.Setup(cmd => cmd.Store(It.IsAny<SessionStateDocument>())).Verifiable();
            MockDocumentSession.Setup(cmd => cmd.SaveChanges()).Verifiable();

            subject.Initialize("A name", keyPairs, MockDocumentStore.Object);

            // Act
            subject.CreateUninitializedItem(new HttpContext(new SimpleWorkerRequest("", "", "", "", new StringWriter())), providedSessionId, 10);

            // Assert
            MockDocumentSession.Verify(cmd => cmd.Store(It.IsAny<SessionStateDocument>()), Times.Once());
            MockDocumentSession.Verify(cmd => cmd.SaveChanges(), Times.Once());
        }
开发者ID:CorporateActionMan,项目名称:RavenDbSessionStateStoreProvider,代码行数:35,代码来源:CreateUninitializedItemTests.cs


示例9: SessionLifetimeReturnsSameInstanceForSameSessionAndDifferentInstanceForDifferentSession

		public void SessionLifetimeReturnsSameInstanceForSameSessionAndDifferentInstanceForDifferentSession()
		{
			// Arrange
			using (var container = new IocContainer())
			{
				var sessionItems1 = new SessionStateItemCollection();
				var sessionItems2 = new SessionStateItemCollection();
				var context1 = new FakeHttpContext("Http://fakeUrl1.com", null, null, null, null, sessionItems1);
				var context2 = new FakeHttpContext("Http://fakeUrl2.com", null, null, null, null, sessionItems2);

				HttpContextBase currentContext = null;

				var lifetime = new SessionLifetime(() => currentContext);		// better solution for injecting HttpContext ?

				container.Register<IFoo>(c => new Foo1()).SetLifetime(lifetime);

				// Act
				currentContext = context1;

				var result1 = container.Resolve<IFoo>();
				var result2 = container.Resolve<IFoo>();

				currentContext = context2;

				var result3 = container.Resolve<IFoo>();

				// Assert
				Assert.IsNotNull(result1);
				Assert.IsNotNull(result2);
				Assert.IsNotNull(result3);

				Assert.AreSame(result1, result2);
				Assert.AreNotSame(result1, result3);
			}
		}
开发者ID:Kingefosa,项目名称:Dynamo.IoC,代码行数:35,代码来源:SessionLifetimeTest.cs


示例10: FakeHttpContext

 public FakeHttpContext(FakePrincipal principal, NameValueCollection formParams, NameValueCollection queryStringParams, HttpCookieCollection cookies, SessionStateItemCollection sessionItems )
 {
     _principal = principal;
     _formParams = formParams;
     _queryStringParams = queryStringParams;
     _cookies = cookies;
     _sessionItems = sessionItems;
 }
开发者ID:volkanceylan,项目名称:Serenity,代码行数:8,代码来源:FakeHttpContext.cs


示例11: CreateNewStoreData

 public override SessionStateStoreData CreateNewStoreData(HttpContext context, int timeout)
 {
     var sessionItems = new SessionStateItemCollection();
     string sessionString = JsonConvert.SerializeObject(sessionItems);
     cache.PutAsync(context.Session.SessionID, sessionString, TimeSpan.FromMinutes(timeout));
     var data = new SessionStateStoreData(sessionItems, null, timeout);
     return data;
 }
开发者ID:jahmad-fareportal,项目名称:CacheSharp,代码行数:8,代码来源:CacheSharpSessionProvider.cs


示例12: SetUp

 public void SetUp()
 {
     var configure = new MongoConfigurationBuilder();
     configure.ConnectionStringAppSettingKey("mongoserver");
     config = configure.BuildConfiguration();
     SessionStateItemCollection sessionItemsCollection = new SessionStateItemCollection();
     HttpStaticObjectsCollection staticObjectsCollection = new HttpStaticObjectsCollection();
     item = new SessionStateStoreData(sessionItemsCollection, staticObjectsCollection, 1);
 }
开发者ID:jango2015,项目名称:MongoSessionStore,代码行数:9,代码来源:SessionStoreTest.cs


示例13: FakeHttpContext

 public FakeHttpContext(string relativeUrl, FakePrincipal principal, NameValueCollection formParams, NameValueCollection queryStringParams, HttpCookieCollection cookies, SessionStateItemCollection sessionItems)
 {
     this.relativeUrl = relativeUrl;
     this.principal = principal;
     this.formParams = formParams;
     this.queryStringParams = queryStringParams;
     this.cookies = cookies;
     this.sessionItems = sessionItems;
 }
开发者ID:mmozuras,项目名称:DotNetGroup,代码行数:9,代码来源:FakeHttpContext.cs


示例14: MockHttpContext

 public MockHttpContext(string relativeUrl, Models.UserPrincipal principal, NameValueCollection formParams, NameValueCollection queryStringParams, HttpCookieCollection cookies, SessionStateItemCollection sessionItems)
 {
     _relativeUrl = relativeUrl;
     _principal = principal;
     _formParams = formParams;
     _queryStringParams = queryStringParams;
     _cookies = cookies;
     _sessionItems = sessionItems;
 }
开发者ID:hhariri,项目名称:ReSharper8Demo,代码行数:9,代码来源:MockHttpContext.cs


示例15: Serialize

 private byte[] Serialize(SessionStateItemCollection items)
 {
   MemoryStream ms = new MemoryStream();
   BinaryWriter writer = new BinaryWriter(ms);
   if (items != null)
   {
     items.Serialize(writer);
   }
   writer.Close();
   return ms.ToArray();
 }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:11,代码来源:SessionTests.cs


示例16: FakeHttpContext

		public FakeHttpContext(string relativeUrl, string method, IPrincipal principal, NameValueCollection formParams, NameValueCollection queryStringParams, HttpCookieCollection cookies, SessionStateItemCollection sessionItems)
		{
			this._relativeUrl = relativeUrl;
			this._method = method;
			this._principal = principal;
			this._formParams = formParams;
			this._queryStringParams = queryStringParams;
			this._cookies = cookies;
			this._sessionItems = sessionItems;
			this._items = new Dictionary<object, object>();
		}
开发者ID:robertsimmons,项目名称:SpecsFor,代码行数:11,代码来源:FakeHttpContext.cs


示例17: Deserialize

 public object Deserialize(ObjectReader reader)
 {
     SessionStateItemCollection items = new SessionStateItemCollection();
     var count = reader.ReadInt32();
     for(int i = 0; i < count; i++)
     {
         var name = (string)reader.Deserialize();
         var value = reader.Deserialize();
         items[name] = value;
     }
     return items;
 }
开发者ID:supuy-ruby,项目名称:Aoite,代码行数:12,代码来源:RedisSessionStateStoreProvider.cs


示例18: CreateLegitStoreData

 internal static SessionStateStoreData CreateLegitStoreData(HttpContext context, ISessionStateItemCollection sessionItems, HttpStaticObjectsCollection staticObjects, int timeout)
 {
     if (sessionItems == null)
     {
         sessionItems = new SessionStateItemCollection();
     }
     if ((staticObjects == null) && (context != null))
     {
         staticObjects = GetSessionStaticObjects(context);
     }
     return new SessionStateStoreData(sessionItems, staticObjects, timeout);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:SessionStateUtility.cs


示例19: base

 public FakeControllerContext
     (
         ControllerBase controller,
         string userName,
         string[] roles,
         NameValueCollection formParams,
         NameValueCollection queryStringParams,
         HttpCookieCollection cookies,
         SessionStateItemCollection sessionItems
     )
     : base(new FakeHttpContext(new FakePrincipal(new FakeIdentity(userName), roles), formParams, queryStringParams, cookies, sessionItems), new RouteData(), controller)
 { }
开发者ID:bsommardahl,项目名称:FlickTrap,代码行数:12,代码来源:FakeControllerContext.cs


示例20: FakeHttpContext

 public FakeHttpContext(string url, FakePrincipal principal, NameValueCollection formParams, NameValueCollection queryStringParams, HttpCookieCollection cookies, SessionStateItemCollection sessionItems )
 {
     _url = url;
     _principal = principal;
     _formParams = formParams;
     _queryStringParams = queryStringParams;
     _cookies = cookies;
     _session = new FakeHttpSessionState(sessionItems);
     _request = new FakeHttpRequest(_url, _formParams, _queryStringParams, _cookies);
     _server = new FakeHttpServerUtility();
     _items = new Dictionary<string, object>();
 }
开发者ID:haithemaraissia,项目名称:RentalMVCClean,代码行数:12,代码来源:FakeHttpContext.cs



注:本文中的System.Web.SessionState.SessionStateItemCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SessionState.SessionStateStoreData类代码示例发布时间:2022-05-26
下一篇:
C# SessionState.HttpSessionState类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap