예제 #1
0
        /// <summary>
        /// All routes in this site always return to the Index action and the control is passed to
        /// the Durandal application
        /// If the route parameters include a _escaped_fragment_ parameter, then a snapshot of the resource is returned
        /// </summary>
        /// <returns></returns>
        public async Task <ActionResult> Index()
        {
            // If the request is not from a bot or the system is not ready or taking snapshots => control to Durandal app
            if (!Snapshot.IsBot(Request))
            {
                return(View());
            }

            // Check if the service is configured
            if (!Snapshot.Configured())
            {
                return(View());
            }

            // Take snapshot for bot
            try
            {
                var result = await Snapshot.Get(Request.Url.AbsoluteUri.Replace("?_escaped_fragment_=", ""), Request.UserAgent);

                return(Content(result));
            }
            catch (HttpException ex)
            {
                return(new HttpNotFoundResult(ex.Message));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
예제 #2
0
 public override void Load(ISnapshot save)
 {
     base.Load(save);
     Name         = save.Get <string>("Name");
     PositionX    = save.GetInt("PositionX");
     PositionY    = save.GetInt("PositionY");
     PlayerNumber = save.GetInt("PlayerNumber");
     UnitType     = (UnitTypes)save.GetInt("UnitType");
 }
예제 #3
0
        public byte[] Get(ISnapshot head, byte[] key)
        {
            ISnapshot snapshot = head;

            Value result = null;

            while (IsImplement(snapshot))
            {
                result = ((Snapshot)(snapshot)).db.Get(Key.Of(key));
                if (result != null)
                {
                    return(result.Data);
                }
                snapshot = snapshot.GetPrevious();
            }
            return(snapshot?.Get(key));
        }