protected ADServerSettings CreateADServerSettingsForOrganization(bool useDCInAnySite = false) { ISessionState sessionState = this.CurrentTaskContext.SessionState; bool flag = false; if (sessionState != null) { flag = ExchangePropertyContainer.IsContainerInitialized(sessionState); } OrganizationId orgId = null; if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsCmdletInvokedWithoutPSFramework && this.CurrentTaskContext.UserInfo != null) { orgId = this.CurrentTaskContext.UserInfo.CurrentOrganizationId; } else if (flag) { ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = ExchangePropertyContainer.GetExchangeRunspaceConfiguration(sessionState); if (exchangeRunspaceConfiguration != null) { orgId = exchangeRunspaceConfiguration.OrganizationId; } } return(this.CreateServerSettings(orgId, useDCInAnySite)); }
private void AddConfigSystem <T>(ISessionState sessionState, string asset, string bundleName = "tables") where T : AbstractConfigManager <T>, IConfigParser, new() { AddSystem(new DefaultConfigInitSystem <T>(sessionState, new AssetInfo(bundleName, asset), SingletonManager.Get <T>())); }
public LocalizeSessionSystem(ISessionState sessionState, IUnityAssetManager assetManager) { _sessionState = sessionState; _assetManager = assetManager; sessionState.CreateExitCondition(typeof(LocalizeSessionSystem)); assetManager.LoadAssetAsync("", new AssetInfo(ASSETBUNDLENAME, ASSETNAME), OnLoadSucc); }
public async Task SetAsync(IDeviceIdentity identity, ISessionState sessionState) { var state = sessionState as BlobSessionState; if (state == null) { throw new ArgumentException("Cannot set Session State object that hasn't been acquired from provider.", "sessionState"); } if (state.IsTransient) { return; } CloudBlockBlob blob = this.container.GetBlockBlobReference(identity.Id); using (var memoryStream = new MemoryStream()) using (var streamWriter = new StreamWriter(memoryStream)) { JsonSerializer serializer = JsonSerializer.Create(SerializerSettings); serializer.Serialize(streamWriter, state); streamWriter.Flush(); memoryStream.Position = 0; AccessCondition accessCondition = state.ETag == null ? AccessCondition.GenerateIfNoneMatchCondition("*") // create : AccessCondition.GenerateIfMatchCondition(state.ETag); // update await blob.UploadFromStreamAsync(memoryStream, accessCondition, null, null); state.ETag = blob.Properties.ETag; } }
public void FetchEmptySession() { using (ISessionState sessionState = sessionStorage.LoadSession("testId")) { Assert.IsNotNull(sessionState); } }
public ClientWeaponConfigInitSystem(Contexts contexts, ISessionState sessionState) { _contexts = contexts; this._sessionState = sessionState; _sessionState.CreateExitCondition(typeof(ClientWeaponConfigInitSystem)); }
public InputManagerConfigInitSystem(Contexts contexts, ISessionState sessionState) { _contexts = contexts; _sessionState = sessionState; _sessionState.CreateExitCondition(typeof(InputManagerConfigInitSystem)); SingletonManager.Get <SubProgressBlackBoard>().Add(); }
public int Count <T>(ISessionState sessionState, SelectQuery <T> query) where T : class, new() { this.EnsureConfigurationLoaded(); var countQuery = this.countWriter.GenerateCountSql(query); return(sessionState.GetConnection().Query <int>(countQuery.Sql, countQuery.Parameters, sessionState.GetTransaction()).SingleOrDefault()); }
public Engine(IReader reader, IWriter writer, IProcessor processor, ISessionState state) { this.Reader = reader; this.Writer = writer; this.Processor = processor; this.State = state; }
private void AddConfigSystem <T>(ISessionState sessionState, string asset, SubReousourcesHandler subResourceHandler = null) where T : AbstractConfigManager <T>, IConfigParser, new() { SingletonManager.Get <T>().IsServer = _isServer; AddSystem(new DefaultConfigInitSystem <T>(sessionState, new AssetInfo("tables", asset), SingletonManager.Get <T>(), subResourceHandler)); }
/// <summary> /// Saves the session state to the storage. /// </summary> /// <param name="sessionState">Session state to be saved.</param> public void SaveSession(ISessionState sessionState) { string sessionFileName = ConstuctSessionFileName(sessionState.SessionHolderId); fileManager.EnsurePathExists(sessionFileName); fileManager.SerializeIntoFile(sessionFileName, sessionState); }
public TerrainDataLoadSystem(ISessionState sessionState, Contexts ctx) : this(ctx) { _sessionState = sessionState; _sessionState.CreateExitCondition(typeof(TerrainDataLoadSystem)); }
/// <summary> /// Froms the specified page. /// </summary> /// <param name="page">The page.</param> /// <returns></returns> public static SearchResultsScript Initialize(SearchResults page) { SearchResultsScript searchResultsScript = new SearchResultsScript(); searchResultsScript.Id = page.ID; searchResultsScript.ClientId = page.ClientID; searchResultsScript.TargetAccount = _integrationManager.TargetMapping.Name; searchResultsScript.SourceAccountId = _integrationManager.SourceAccount.Id.ToString(); searchResultsScript.ResourceTypeName = "tradingAccount"; searchResultsScript.OptionRefineSearchId = page.rdbRefineSearch.ClientID; searchResultsScript.DescriptionText = page.GetLocalResourceObject("refineSearch_DescriptionText"); searchResultsScript.HeaderText = page.GetLocalResourceObject("refineSearch_HeaderText"); searchResultsScript.PropertyValue = page.GetLocalResourceObject("refineSearch_PropertyValue"); searchResultsScript.OperatorValue = page.GetLocalResourceObject("refineSearch_OperatorValue"); searchResultsScript.SearchValue = page.GetLocalResourceObject("refineSearch_SearchValue"); searchResultsScript.DialogCaption = page.GetLocalResourceObject("refineSearch_DialogCaption"); searchResultsScript.ErrorSaveConfig = page.GetLocalResourceObject("refineSearch_error_saveConfig"); searchResultsScript.CancelButton = page.GetLocalResourceObject("refineSearch_CancelButton"); searchResultsScript.OKButton = page.GetLocalResourceObject("refineSearch_OkButton"); searchResultsScript.RefreshGridId = page.btnRefreshGrid.ClientID; searchResultsScript.FiltersId = page.txtFilters.ClientID; searchResultsScript.RowLinkToId = page.rowLinkTo.ClientID; searchResultsScript.RowSearchResultsId = page.rowSearchResults.ClientID; searchResultsScript.ResultsMsgId = page.lblResultsMsg.ClientID; searchResultsScript.LoadingDisplay = page.GetLocalResourceObject("lblLoading.Caption"); ISessionService sessionService = ApplicationContext.Current.Services.Get <ISessionService>(true); ISessionState sessionState = sessionService.GetSessionState(); sessionState["IntegrationManager"] = _integrationManager; return(searchResultsScript); }
protected GenericSession(Client client, IEventAggregator aggregator) { this.client = client; this.aggregator = aggregator; State = new InvalidState(); }
async void ProcessPendingSubscriptionChanges(IChannelHandlerContext context) { try { do { ISessionState newState = this.sessionState.Copy(); Queue <Packet> queue = this.subscriptionChangeQueue; Contract.Assert(queue != null); var acks = new List <Packet>(queue.Count); foreach (Packet packet in queue) // todo: if can queue be null here, don't force creation { switch (packet.PacketType) { case PacketType.SUBSCRIBE: acks.Add(Util.AddSubscriptions(newState, (SubscribePacket)packet, this.maxSupportedQosToClient)); break; case PacketType.UNSUBSCRIBE: acks.Add(Util.RemoveSubscriptions(newState, (UnsubscribePacket)packet)); break; default: throw new ArgumentOutOfRangeException(); } } queue.Clear(); if (!this.sessionState.IsTransient) { // save updated session state, make it current once successfully set await this.sessionStateManager.SetAsync(this.identity, newState); } this.sessionState = newState; this.CapabilitiesChanged?.Invoke(this, EventArgs.Empty); // release ACKs var tasks = new List <Task>(acks.Count); foreach (Packet ack in acks) { tasks.Add(context.WriteAsync(ack)); } context.Flush(); await Task.WhenAll(tasks); PerformanceCounters.PacketsSentPerSecond.IncrementBy(acks.Count); }while (this.subscriptionChangeQueue.Count > 0); this.subscriptionChangeQueue = null; this.ResetState(StateFlags.ChangingSubscriptions); } catch (Exception ex) { ShutdownOnError(context, "-> UN/SUBSCRIBE", ex); } }
public int ExecuteBulkDelete <T>(ISessionState sessionState, IEnumerable <Expression <Func <T, bool> > > predicates) where T : class, new() { this.EnsureConfigurationLoaded(); var sqlQuery = this.deleteWriter.GenerateBulkSql(predicates); return(sessionState.GetConnection().Execute(sqlQuery.Sql, sqlQuery.Parameters, sessionState.GetTransaction())); }
public UiLoadSystem(ISessionState sessionState, Contexts contexts) { _sessionState = sessionState; _contexts = contexts; UiModule.contexts = contexts;//暂时提前赋值,避免tip初始化时读不到 _sessionState.CreateExitCondition(typeof(UiLoadSystem)); }
public SceneConfigInitSystem(ISessionState sessionState, ICommonSessionObjects sessionObjects) { _sessionState = sessionState; _sessionState.CreateExitCondition(typeof(SceneConfigInitSystem)); MapConfigManager.Generate(sessionObjects.RoomInfo.MapId, ReduceFinishTimes); _logger.InfoFormat("SceneConfigInitSystem :mapId:{0}", sessionObjects.RoomInfo.MapId); }
public static ISessionState GetSessionState() { if (sessionState == null) { // find the implementation from a configuration entry // get the settings from configuration file //ControllerConfigSection config = ConfigurationManager.GetSection("triton/content") as ControllerConfigSection; //// make sure we have the proper configuration info //if (config == null) { // throw new ConfigurationErrorsException("Load of triton/content configuration section failed."); //} string typeName = "Triton.Web.Support.Session.HttpSessionState, Triton.Extensions.Web"; if (ConfigurationManager.AppSettings["sessionProvider"] != null) { typeName = ConfigurationManager.AppSettings["sessionProvider"]; } Type type = Type.GetType(typeName); // make sure we successfully got the type for the provider to instantiate if (type == null) { throw new ConfigurationErrorsException(string.Format("Type not found: '{0}'.", ConfigurationManager.AppSettings["sessionProvider"])); } // instantiate the new ContentProvider sessionState = (ISessionState)Activator.CreateInstance(type); if (sessionState == null) { throw new ConfigurationErrorsException(string.Format("Instantiation of type '{0}' failed.", ConfigurationManager.AppSettings["sessionProvider"])); } } return sessionState; }
public virtual int Insert <T>(ISessionState sessionState, IEnumerable <T> entities) where T : class, new() { this.EnsureConfigurationLoaded(); var i = 0; var map = this.Configuration.GetMap <T>(); var getLastInsertedId = this.insertWriter.GenerateGetIdSql <T>(); foreach (var entity in entities) { var sqlQuery = this.insertWriter.GenerateSql(entity); if (map.PrimaryKey.IsAutoGenerated) { var idResult = sessionState.GetConnection() .Query <int>(sqlQuery.Sql + ";" + getLastInsertedId, sqlQuery.Parameters, sessionState.GetTransaction()); map.SetPrimaryKeyValue(entity, idResult.Single()); } else { sessionState.GetConnection().Execute(sqlQuery.Sql, sqlQuery.Parameters, sessionState.GetTransaction()); } ((ITrackedEntity)entity).EnableTracking(); // turn on tracking ++i; } return(i); }
private void CheckSessions() { var now = TimeProvider.Now.ToUniversalTime(); foreach (var expiredSession in _sessions.Values.AsParallel().Where((s) => s.ExpiresBy(now))) { ISessionState externalSession = _sessionStateProvider.GetSessionState(expiredSession.SessionKey) ?? expiredSession; if (externalSession.ExpiresBy(now)) { KillSession(expiredSession.SessionKey, SessionEndingReason.EXPIRED); } else { _sessions[expiredSession.SessionKey] = externalSession; } } var expiresBy = now + TimeSpan.FromSeconds(_config.WarnUserSessionExpirationSeconds); foreach (var expiringSession in _sessions.Values.AsParallel().Where((s) => s.ExpiresBy(expiresBy))) { ISessionState externalSession = _sessionStateProvider.GetSessionState(expiringSession.SessionKey) ?? expiringSession; _sessions[expiringSession.SessionKey] = externalSession; if (externalSession.ExpiresBy(expiresBy)) { RaiseSessionExpiring(expiringSession, expiringSession.Expires); } } }
public SceneConfigLoadModule(Contexts context, ISessionState sessionState, ICommonSessionObjects sessionObjects, bool IsServer) { _isServer = IsServer; AddSystem(new SceneConfigInitSystem(sessionState, sessionObjects)); }
private static ExchangePropertyContainer GetPropertyContainer(ISessionState sessionState) { object obj; sessionState.Variables.TryGetValue(ExchangePropertyContainer.ExchangePropertyContainerName, out obj); return(obj as ExchangePropertyContainer); }
public virtual IEnumerable <T> Query <T>(ISessionState sessionState, SelectQuery <T> query) where T : class, new() { this.EnsureConfigurationLoaded(); var sqlQuery = this.selectWriter.GenerateSql(query); if (query.HasFetches()) { Func <SelectWriterResult, SelectQuery <T>, IDbConnection, IDbTransaction, IEnumerable <T> > queryFunc; if (sqlQuery.NumberCollectionsFetched > 0) { queryFunc = this.delegateQueryCreator.GetCollectionFunction <T>(sqlQuery); } else { queryFunc = this.delegateQueryCreator.GetNoCollectionFunction <T>(sqlQuery); } return(queryFunc(sqlQuery, query, sessionState.GetConnection(), sessionState.GetTransaction())); } return(sessionState.GetConnection().Query <T>(sqlQuery.Sql, sqlQuery.Parameters, sessionState.GetTransaction()).Select( t => { ((ITrackedEntity)t).EnableTracking(); return t; })); ; }
public static SubAckPacket AddSubscriptions(ISessionState session, SubscribePacket packet, QualityOfService maxSupportedQos) { List <Subscription> subscriptions = session.Subscriptions; var returnCodes = new List <QualityOfService>(subscriptions.Count); foreach (SubscriptionRequest request in packet.Requests) { Subscription existingSubscription = null; for (int i = subscriptions.Count - 1; i >= 0; i--) { Subscription subscription = subscriptions[i]; if (subscription.TopicFilter.Equals(request.TopicFilter, StringComparison.Ordinal)) { subscriptions.RemoveAt(i); existingSubscription = subscription; break; } } QualityOfService finalQos = request.QualityOfService < maxSupportedQos ? request.QualityOfService : maxSupportedQos; subscriptions.Add(existingSubscription == null ? new Subscription(request.TopicFilter, request.QualityOfService) : existingSubscription.CreateUpdated(finalQos)); returnCodes.Add(finalQos); } var ack = new SubAckPacket { PacketId = packet.PacketId, ReturnCodes = returnCodes }; return(ack); }
public PreLoadSystem(ISessionState sessionState, IAssetInfoProvider assetInfoProvider) { _sessionState = sessionState; _assetInfoProvider = assetInfoProvider; _sessionState.CreateExitCondition(typeof(PreLoadSystem)); SingletonManager.Get <SubProgressBlackBoard>().Add((uint)_assetInfoProvider.AssetInfos.Count); }
/// <summary> /// Loads and updates (as necessary) session state. /// </summary> /// <param name="cleanSession">Determines whether session has to be deleted if it already exists.</param> /// <returns></returns> async Task <bool> EstablishSessionStateAsync(bool cleanSession) { ISessionState existingSessionState = await this.sessionStateManager.GetAsync(this.identity); if (cleanSession) { if (existingSessionState != null) { await this.sessionStateManager.DeleteAsync(this.identity, existingSessionState); // todo: loop in case of concurrent access? how will we resolve conflict with concurrent connections? } this.sessionState = await this.sessionStateManager.CreateAsync(true); return(false); } else { if (existingSessionState == null) { this.sessionState = await this.sessionStateManager.CreateAsync(false); return(false); } else { this.sessionState = existingSessionState; return(true); } } }
public IEnumerable <T> Query <T>(ISessionState sessionState, SelectQuery <T> query) where T : class, new() { this.AssertConfigured(); var table = this.tables[typeof(T)]; var whereClauseNullCheckRewriter = new WhereClauseNullCheckRewriter(); var fetchCloner = new FetchCloner(this.Configuration); var enumerable = typeof(InMemoryTable <,>).MakeGenericType(typeof(T), this.Configuration.GetMap(typeof(T)).PrimaryKey.Type) .GetMethod("Query") .Invoke(table, new object[0]) as IEnumerable <T>; var fetchParser = new FetchTreeParser(this.Configuration); int numberCollectionFetches; int aliasCounter; var fetchTree = fetchParser.GetFetchTree(query, out aliasCounter, out numberCollectionFetches); // we may have to query across non-fetched stuff var baseWriter = new BaseWriter(new SqlServer2012Dialect(), this.configuration); baseWriter.AddWhereClause(query.WhereClauses, new StringBuilder(), ref fetchTree); // note that this fetches all the things in the tree as the whereclause may reference things not fetched if (fetchTree != null) { enumerable = enumerable.Fetch(fetchTree, this.tables); } foreach (var whereClause in query.WhereClauses) { enumerable = enumerable.Where(whereClauseNullCheckRewriter.Rewrite(whereClause).Compile()); } foreach (var orderClause in query.OrderClauses) { var expr = Expression.Lambda(orderClause.Expression, Expression.Parameter(typeof(T))).Compile(); var orderBy = typeof(Enumerable).GetMethods() .Single( m => m.GetParameters().Count() == 2 && m.Name == (orderClause.Direction == ListSortDirection.Ascending ? "OrderBy" : "OrderByDescending")); enumerable = (IEnumerable <T>)orderBy.Invoke(enumerable, new object[] { expr }); } if (query.SkipN > 0) { enumerable = enumerable.Skip(query.SkipN); } if (query.TakeN > 0) { enumerable = enumerable.Take(query.TakeN); } foreach (var entity in enumerable) { yield return(fetchCloner.Clone(query, entity)); } }
/// <summary> /// Called when the dialog is closing. /// </summary> protected override void OnClosing() { _loadSearchResults = false; ISessionService sessionService = ApplicationContext.Current.Services.Get <ISessionService>(true); ISessionState sessionState = sessionService.GetSessionState(); sessionState.Remove("IntegrationManager"); }
public void TestCreate_ShouldReturn_Session() { var sessionProvider = new SessionStateStoragePersistenceProvider(Mock.Of <IEdgeHub>(), this.entityStore); ISessionState session = sessionProvider.Create(true); Assert.NotNull(session); Assert.False(session.IsTransient); }
private IGameModule CreateSystems(Contexts contexts, ISessionState sessionState) { GameModule module = new GameModule(); module.AddSystem(new InitMapIdSystem(contexts)); module.AddSystem(new GlobalEffectManagerInitSystem(contexts, sessionState)); return(module); }
public HttpContext(IServerVariables serverVariables, ICookies requestCookies, ICookies responseCookies, ISessionState sessionState) { ServerVariables = serverVariables; RequestCookies = requestCookies; ResponseCookies = responseCookies; SessionState = sessionState; }
public FakeUsersService(ISessionState sessionState) { _sessionState = sessionState; _actualUsers = _sessionState.Get<IList<UserTasksModel>>(); if (_actualUsers == null) { _actualUsers = CreateUsers().ToList(); Update(null); } }
/// <summary> /// Default Constructor. /// Creates a new instance of <see cref="IState"/> class. /// </summary> /// <param name="applicationState">An instance of <see cref="IApplicationState"/> that is used to store /// application state data.</param> /// <param name="localState">An instance of <see cref="ILocalState"/> that is used to store local /// state data.</param> /// <param name="sessionState">An instance of <see cref="ISessionState"/> that is used to store session /// state data.</param> /// <param name="cacheState">An instance of <see cref="ICacheState"/> that is used to store cache /// state data.</param> public State( IApplicationState applicationState, ILocalState localState, ISessionState sessionState, ICacheState cacheState) { _applicationState = applicationState; _localState = localState; _sessionState = sessionState; _cacheState = cacheState; }
public SessionNonBlocking() { m_hRecvBuffer = new byte[1024]; m_hMs = new MemoryStream(m_hRecvBuffer); m_hReader = new BinaryReader(m_hMs); m_hToSend = new Queue<Packet>(); m_hDisconnected = new SessionStateDisconnected(this); m_hConnecting = new SessionStateConnecting(this); m_hJustConnected = new SessionStateJustConnected(this); m_hActive = new SessionStateActive(this); m_hJustDisconnected = new SessionStateJustDisconnected(this); m_hDisconnected.Next = m_hConnecting; m_hConnecting.Success = m_hJustConnected; m_hConnecting.Fail = m_hJustDisconnected; m_hJustConnected.Next = m_hActive; m_hJustDisconnected.Next = m_hDisconnected; m_hActive.Fail = m_hJustDisconnected; m_hCurrentState = m_hDisconnected; }
public DeleteItemEndPoint(ISessionState ss) { _ss = ss; }
public Session(bool caseInsensitive) { m_caseInsensitive = caseInsensitive; m_waitLockTimeOut = 10; m_currentState = new SessionDisconnected(this, m_caseInsensitive); }
async void ProcessPendingSubscriptionChanges(IChannelHandlerContext context) { try { do { ISessionState newState = this.sessionState.Copy(); Queue<Packet> queue = this.SubscriptionChangeQueue; var acks = new List<Packet>(queue.Count); foreach (Packet packet in queue) // todo: if can queue be null here, don't force creation { switch (packet.PacketType) { case PacketType.SUBSCRIBE: acks.Add(Util.AddSubscriptions(newState, (SubscribePacket)packet, this.maxSupportedQosToClient)); break; case PacketType.UNSUBSCRIBE: acks.Add(Util.RemoveSubscriptions(newState, (UnsubscribePacket)packet)); break; default: throw new ArgumentOutOfRangeException(); } } queue.Clear(); if (!this.sessionState.IsTransient) { // save updated session state, make it current once successfully set await this.sessionStateManager.SetAsync(this.deviceId, newState); } this.sessionState = newState; // release ACKs var tasks = new List<Task>(acks.Count); foreach (Packet ack in acks) { tasks.Add(context.WriteAsync(ack)); } context.Flush(); await Task.WhenAll(tasks); PerformanceCounters.PacketsSentPerSecond.IncrementBy(acks.Count); } while (this.subscriptionChangeQueue.Count > 0); this.ResetState(StateFlags.ChangingSubscriptions); } catch (Exception ex) { ShutdownOnError(context, "-> UN/SUBSCRIBE", ex); } }
/// <summary> /// Loads and updates (as necessary) session state. /// </summary> /// <param name="clientId">Client identificator to load the session state for.</param> /// <param name="cleanSession">Determines whether session has to be deleted if it already exists.</param> /// <returns></returns> async Task<bool> EstablishSessionStateAsync(string clientId, bool cleanSession) { ISessionState existingSessionState = await this.sessionStateManager.GetAsync(clientId); if (cleanSession) { if (existingSessionState != null) { await this.sessionStateManager.DeleteAsync(clientId, existingSessionState); // todo: loop in case of concurrent access? how will we resolve conflict with concurrent connections? } this.sessionState = this.sessionStateManager.Create(true); return false; } else { if (existingSessionState == null) { this.sessionState = this.sessionStateManager.Create(false); return false; } else { this.sessionState = existingSessionState; return true; } } }
public HomeEndpoint(ISessionState state) { _ss = state; _ss.Set<TODOList>("_theList",_theList); }
public UserTaskListController(IUsersService usersService, ISessionState session, IUserTasksService userTasksService) { _userTasksService = userTasksService; _usersService = usersService; _session = session; }
public PlayerSession(ISessionState<PlayerDto> session) { _session = session; }
public void Kick() { client.Kick(); State = new InvalidState(); }
public void Setup() { _session = Substitute.For<ISessionState<PlayerDto>>(); _target = new PlayerSession(_session); }
public static SubAckPacket AddSubscriptions(ISessionState session, SubscribePacket packet, QualityOfService maxSupportedQos) { List<Subscription> subscriptions = session.Subscriptions; var returnCodes = new List<QualityOfService>(subscriptions.Count); foreach (SubscriptionRequest request in packet.Requests) { Subscription existingSubscription = null; for (int i = subscriptions.Count - 1; i >= 0; i--) { Subscription subscription = subscriptions[i]; if (subscription.TopicFilter.Equals(request.TopicFilter, StringComparison.Ordinal)) { subscriptions.RemoveAt(i); existingSubscription = subscription; break; } } QualityOfService finalQos = request.QualityOfService < maxSupportedQos ? request.QualityOfService : maxSupportedQos; subscriptions.Add(existingSubscription == null ? new Subscription(request.TopicFilter, request.QualityOfService) : existingSubscription.CreateUpdated(finalQos)); returnCodes.Add(finalQos); } var ack = new SubAckPacket { PacketId = packet.PacketId, ReturnCodes = returnCodes }; return ack; }
public static UnsubAckPacket RemoveSubscriptions(ISessionState session, UnsubscribePacket packet) { foreach (string topicToRemove in packet.TopicFilters) { session.RemoveSubscription(topicToRemove); } var ack = new UnsubAckPacket { PacketId = packet.PacketId }; return ack; }
public async Task DeleteAsync(string id, ISessionState sessionState) { var state = sessionState as BlobSessionState; if (state == null) { throw new ArgumentException("Cannot set Session State object that hasn't been acquired from provider.", "sessionState"); } CloudBlockBlob blob = this.container.GetBlockBlobReference(id); await blob.DeleteAsync( DeleteSnapshotsOption.None, new AccessCondition { IfMatchETag = state.ETag }, null, null); }
public async Task SetAsync(string id, ISessionState sessionState) { var state = sessionState as BlobSessionState; if (state == null) { throw new ArgumentException("Cannot set Session State object that hasn't been acquired from provider.", "sessionState"); } if (state.IsTransient) { throw new ArgumentException("Cannot persist transient Session State object.", "sessionState"); } CloudBlockBlob blob = this.container.GetBlockBlobReference(id); using (var memoryStream = new MemoryStream()) using (var streamWriter = new StreamWriter(memoryStream)) { JsonSerializer serializer = JsonSerializer.Create(); serializer.Serialize(streamWriter, state); streamWriter.Flush(); memoryStream.Position = 0; AccessCondition accessCondition = state.ETag == null ? AccessCondition.GenerateIfNoneMatchCondition("*") // create : AccessCondition.GenerateIfMatchCondition(state.ETag); // update await blob.UploadFromStreamAsync(memoryStream, accessCondition, null, null); } }
public static UnsubAckPacket RemoveSubscriptions(ISessionState session, UnsubscribePacket packet) { List<Subscription> subscriptions = session.Subscriptions; foreach (string topicToRemove in packet.TopicFilters) { for (int i = subscriptions.Count - 1; i >= 0; i--) { if (subscriptions[i].TopicFilter.Equals(topicToRemove, StringComparison.Ordinal)) { subscriptions.RemoveAt(i); break; } } } var ack = new UnsubAckPacket { PacketId = packet.PacketId }; return ack; }
public static SubAckPacket AddSubscriptions(ISessionState session, SubscribePacket packet, QualityOfService maxSupportedQos) { IReadOnlyList<ISubscription> subscriptions = session.Subscriptions; var returnCodes = new List<QualityOfService>(subscriptions.Count); foreach (SubscriptionRequest request in packet.Requests) { QualityOfService finalQos = request.QualityOfService < maxSupportedQos ? request.QualityOfService : maxSupportedQos; session.AddOrUpdateSubscription(request.TopicFilter, finalQos); returnCodes.Add(finalQos); } var ack = new SubAckPacket { PacketId = packet.PacketId, ReturnCodes = returnCodes }; return ack; }
public static void Define(ISessionState session) { Session = session; }
public UserLoginController(IUsersService usersService, ISessionState sessionState) { _usersService = usersService; _sessionState = sessionState; }
public Task DeleteAsync(IDeviceIdentity identity, ISessionState sessionState) { return TaskEx.Completed; }
public FacebookClientProvider(ISessionState<string> storage) { _storage = storage; }
public HomeController(ISessionState sessionState) { _sessionState = sessionState; }
public Task DeleteAsync(string id, ISessionState sessionState) { return TaskEx.Completed; }
public PSCurrentWorkingDirectory(ISessionState sessionState) { _sessionState = sessionState; }
public EditItemEndPoint(ISessionState ss) { _ss = ss; }