public static MailRuCloud Instance(IHttpContext context) { HttpListenerBasicIdentity identity = (HttpListenerBasicIdentity)context.Session.Principal.Identity; string key = identity.Name + identity.Password; MailRuCloud cloud; if (CloudCache.TryGetValue(key, out cloud)) { if (cloud.CloudApi.Account.Expires <= DateTime.Now) { CloudCache.TryRemove(key, out cloud); } else { return(cloud); } } cloud = new SplittedCloud(identity.Name, identity.Password); if (!CloudCache.TryAdd(key, cloud)) { CloudCache.TryGetValue(key, out cloud); } return(cloud); }
public static MailRuCloud Instance(IHttpContext context) { HttpListenerBasicIdentity identity = (HttpListenerBasicIdentity)context.Session.Principal.Identity; string key = identity.Name + identity.Password; MailRuCloud cloud; if (CloudCache.TryGetValue(key, out cloud)) { if (cloud.CloudApi.Account.Expires <= DateTime.Now) { CloudCache.TryRemove(key, out cloud); } else { return(cloud); } } if (!identity.Name.Contains("@mail.")) { Logger.Warn("Missing domain part (@mail.*) in login, file and folder deleting will be denied"); } cloud = new SplittedCloud(identity.Name, identity.Password); if (!CloudCache.TryAdd(key, cloud)) { CloudCache.TryGetValue(key, out cloud); } return(cloud); }