Пример #1
0
 public LivecodingSession(ILoginMethod loginMethod, string username)
 {
     Followed         = new List <string> ();
     Followers        = new List <string> ();
     this.Username    = username;
     this.loginMethod = loginMethod;
     cookies          = new CookieContainer();
     this.loginMethod.LoginCompleted += LoginMethod_LoginCompleted;
 }
Пример #2
0
 public LivecodingSession(ILoginMethod loginMethod,string username)
 {
     Followed = new List<string> ();
     Followers = new List<string> ();
     this.Username = username;
     this.loginMethod = loginMethod;
     cookies = new CookieContainer ();
     this.loginMethod.LoginCompleted += LoginMethod_LoginCompleted;
 }
Пример #3
0
        public async Task <User> GetAuthenticatedUser(ILoginMethod method)
        {
            var userId = await method.GetAuthenticatedUserUniqueId();

            using (Tran.OpenTransaction()) {
                var u = Users().All.FirstOrDefault(x => x.UniqueId == userId)
                        ?? Users().Add(new User {
                    UniqueId = userId
                });
                UnitOfWork().Commit();
                return(u);
            }
        }
Пример #4
0
        public async Task <Uri> GetRedirectUrlFor(ILoginMethod method, string returnUrl)
        {
            var r = await method.GetRedirectResponse(new Uri( new Uri(HttpContext().Request.Url.GetLeftPart(UriPartial.Authority)), returnUrl ));

            var ctx = HttpContext();

            (from h in r.Headers
             where h.Key == "Set-Cookie"
             from v in h.Value
             select new { h = h.Key, v })
            .ForEach(x => ctx.Response.AppendHeader(x.h, x.v + "; path=" + ctx.Request.ApplicationPath));

            return(r.Headers.Location);
        }
Пример #5
0
        public static void Main(string[] args)
        {
            string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

            try
            {
                player = new System.Media.SoundPlayer(System.IO.Path.Combine(dir, "sound.wav"));
                player.Load();
            }
            catch (Exception) { player = null; }
            run = true;

            ILoginMethod loginMethod = ReadLoginMethod();
            string       username    = ReadUsername();

            session = new LiveCodingChat.Livecoding.LivecodingSession(loginMethod, username);
            session.PasswordRequested   += Session_PasswordRequested;
            session.SessionAutenticated += Session_SessionAutenticated;
            session.EnsureAuthenticated();
            while (run)
            {
                System.Threading.Thread.Sleep(10);
            }
        }