/// <summary> /// Gets the ID used to identify this installation of the /// application to provide telemetry data. It will either be retrieved /// from local settings or generated fresh. /// </summary> /// <returns> /// An installation ID. /// </returns> private string GetApplicationInstallationId() { // Try to get the AppInstallationId from settings string installationId = null; object setting = null; IApplicationStorage applicationStorage = Platform.Instance.ApplicationStorage; if (applicationStorage.TryReadSetting(ConfigureAsyncInstallationConfigPath, out setting)) { JToken config = null; try { config = JToken.Parse(setting as string); installationId = (string)config[ConfigureAsyncApplicationIdKey]; } catch (Exception) { } } // Generate a new AppInstallationId if we failed to find one if (installationId == null) { installationId = Guid.NewGuid().ToString(); JObject jobject = new JObject(); jobject[ConfigureAsyncApplicationIdKey] = installationId; string configText = jobject.ToString(); applicationStorage.WriteSetting(ConfigureAsyncInstallationConfigPath, configText); } return(installationId); }
/// <summary> /// Due to issues on IIS7, the NHibernate initialization must occur in Init(). /// But Init() may be invoked more than once; accordingly, we introduce a thread-safe /// mechanism to ensure it's only initialized once. /// See http://msdn.microsoft.com/en-us/magazine/cc188793.aspx for explanation details. /// </summary> public override void Init() { base.Init(); _webSessionStorage = new WebSessionStorage(this); _webApplicationStorage = new WebApplicationStorage(Application); Util.InitStorage(_webApplicationStorage); }
public SettingsService(IApplicationStorage appStorage) { Logger.Info("Initializing settings service."); this.appStorage = appStorage; LoadSettingsFileCollection(); InitializeCollectionWatcher(); }
public static void PrepareCookieForCurrentPrincipal(IApplicationStorage appStorage, HttpContextBase httpContext) { FormsAuthenticationTicket tempTicket = FormsAuthentication.Decrypt(FormsAuthentication.GetAuthCookie(UserPrincipal.CurrentUser.Identity.Name, false).Value); var authTicket = new FormsAuthenticationTicket(1, // version UserPrincipal.CurrentUser.Identity.Name, // username tempTicket.IssueDate, // issue date tempTicket.Expiration, // expiration false, // persistance UserPrincipal.CurrentUser.SessionId.ToString(), // session id FormsAuthentication.FormsCookiePath); // cookie path // Encrypt the ticket string encrAuthTicket = FormsAuthentication.Encrypt(authTicket); // Build auth cookie var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrAuthTicket); appStorage[UserPrincipal.CurrentUser.SessionId.ToString()] = UserPrincipal.CurrentUser; httpContext.User = UserPrincipal.CurrentUser; httpContext.Response.Cookies.Add(authCookie); }
public ItemOrderValidator(IApplicationStorage storage) { RuleFor(order => order.Amount).Must(amount => amount > 0); RuleFor(order => order.Item).NotNull(); RuleFor(order => order.Item).Must(item => storage.ContainsLineItem(item.Id) && item.Equals(storage.GetLineItem(item.Id))); }
public BasketValidator(IApplicationStorage storage) { RuleFor(reg => reg.Owner).NotEmpty(); RuleFor(reg => reg.Orders).SetCollectionValidator(new ItemOrderValidator(storage)); }
public MetricTaskContext(IApplicationStorage storage, IMetricsResponse metricsResponse) { ApplicationStorage = storage; MetricsResponse = metricsResponse; }
public LocalStorageManager(string name) { this.storage = Platform.Instance.GetNamedApplicationStorage(name); this.InitializeRegistrationInfoFromStorage(); }
private static bool AreOrdersValid(IEnumerable <ItemOrder> orders, IApplicationStorage storage) { return(orders.All(o => storage.ContainsLineItem(o.Item.Id) && storage.GetLineItem(o.Item.Id) == o.Item && o.Amount > 0)); }
public BasketsController(IApplicationStorage storage) { _storage = storage; }
public ItemsController(IApplicationStorage storage) { _storage = storage; }
public JobBufferHandler(IApplicationStorage <Dictionary <int, JobContent> > buffer) { this.buffer = buffer; }
public static void InitStorage(IApplicationStorage appState) { _appState = appState; }
public ItemValidator(IApplicationStorage storage) { RuleFor(reg => reg.Name).NotEmpty().WithMessage("Name must be present"); RuleFor(reg => reg.Price).NotEmpty().ExclusiveBetween(0, float.MaxValue).WithMessage("Price must be positive"); }
public PluginBViewModel(IPublishMessage publisher, IApplicationStorage storage) { _publisher = publisher; _storage = storage; Value = _storage.Get<string>("PluginB.Value"); }