Ejemplo n.º 1
0
 public void Initialize()
 {
     collection = new FamilySearchCollectionState(new Uri("https://sandbox.familysearch.org/platform/collections/sources"));
     collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     subcollections = (CollectionsState)collection.ReadSubcollections().Get();
     cleanup        = new List <GedcomxApplicationState>();
 }
Ejemplo n.º 2
0
 public void Initialize()
 {
     collection = new CollectionState(new Uri(SANDBOX_URI));
     collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     Assert.DoesNotThrow(() => collection.IfSuccessful());
     Assert.IsNotNullOrEmpty(collection.CurrentAccessToken);
 }
Ejemplo n.º 3
0
        public void TestReadOrdinancesAccessForbidden()
        {
            var collection = new CollectionState(ordinanceUri);
            var state = collection.AuthenticateViaOAuth2Password(Resources.PublicUserName, Resources.PublicPassword, Resources.TestClientId).Get();

            Assert.AreEqual(HttpStatusCode.Forbidden, state.Response.StatusCode);
        }
    public void SetItemValue(object obj)
    {
        collectionData = obj as LvCollection;


        if (collectionData != null)
        {
            levelNum      = collectionData.level;
            curLvColState = collectionData.CollectionState;
            for (int i = 0; i < colItemList.Count; i++)
            {
                CollectionItem tItem = new CollectionItem(collectionData.reward [i][0], collectionData.reward [i][1], curLvColState);
                colItemList[i].SetItemValue((object)tItem);
            }
        }
        else
        {
            levelNum = 5;
            for (int i = 0; i < colItemList.Count; i++)
            {
                colItemList[i].SetItemValue(null);
                colItemList[i].curItemState = CollectionState.LockReward;
                colItemList[i].Refresh();
            }
        }

        Refresh();
    }
Ejemplo n.º 5
0
 public void Reset()
 {
     UploadTokenHistory.Write("Deleting token");
     UploadToken = string.Empty;
     CollectionState.Clear();
     Update(0, null);
 }
 public void TestObtainAccessTokenWithUsernameAndPassword()
 {
     var collection = new CollectionState(new Uri(SANDBOX_URI));
     var state = collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode);
     Assert.IsNotNullOrEmpty(state.CurrentAccessToken);
 }
Ejemplo n.º 7
0
        public void TestReadOrdinancesAccessForbidden()
        {
            var collection = new CollectionState(ordinanceUri);
            var state      = collection.AuthenticateViaOAuth2Password(Resources.PublicUserName, Resources.PublicPassword, Resources.TestClientId).Get();

            Assert.AreEqual(HttpStatusCode.Forbidden, state.Response.StatusCode);
        }
Ejemplo n.º 8
0
        public void SaveCollectionStateTest()
        {
            var stateManager = new StateManager(ServiceResolver.GetService <IStateMachine>());

            stateManager.UserDevice = new UserDevice()
            {
                DeviceId = "100"
            };


            var syncKey   = stateManager.GetNewSyncKey("0");
            var collState = new CollectionState()
            {
                FolderId    = "12321",
                Collections = new List <SyncItemState>()
                {
                    new SyncItemState()
                    {
                        ServerId = "12334",
                        HashKey  = "3242342342"
                    },
                    new SyncItemState()
                    {
                        ServerId = "12334",
                        HashKey  = "3242342342"
                    }
                }
            };

            stateManager.SaveCollectionState(syncKey, collState);
            var savedCollState = stateManager.LoadCollectionState(syncKey, collState.FolderId);
        }
Ejemplo n.º 9
0
 public void Initialize()
 {
     collection = new FamilySearchCollectionState(new Uri("https://sandbox.familysearch.org/platform/collections/sources"));
     collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     subcollections = (CollectionsState)collection.ReadSubcollections().Get();
     cleanup = new List<GedcomxApplicationState>();
 }
Ejemplo n.º 10
0
        public void InsertCollectionState()
        {
            var db = new ApplicationDbContext();
            var collectionState = new CollectionState();

            TryUpdateModel(collectionState);
            if (ModelState.IsValid)
            {
                try
                {
                    db.CollectionStates.Add(collectionState);
                    db.SaveChanges();
                    ErrorLabel.Text = String.Empty;
                }
                catch (DbEntityValidationException ex)
                {
                    ErrorLabel.Visible = true;
                    ErrorLabel.Text    = EventLogManager.LogError(ex);
                }
                catch (Exception exp)
                {
                    ErrorLabel.Text    = exp.Message;
                    ErrorLabel.Visible = true;
                }
            }
            else
            {
                ErrorLabel.Text    = "Complete todos los campos.";
                ErrorLabel.Visible = true;
            }
        }
        //TODO: Create FamilysearchSourceReferencesQueryState class, add it to FamilySearchStateFactory when link is created

        /*
         * public FamilySearchSourceReferencesQueryState ReadSourceReferencesQuery()
         * {
         *  Link link = GetLink( //TODO: Put Rel here when added );
         *  if (link == null || link.Href = null)
         *  {
         *      return null;
         *  }
         *
         *  IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.GET);
         *  return ((FamilySearchStateFactory)this.stateFactory).NewFamilySearchSourceReferencesQueryState(request, Invoke(request), this.Client, this.CurrentAccessToken);
         * }
         */

        /// <summary>
        /// Moves the current source description to the specified collection.
        /// </summary>
        /// <param name="collection">The target collection to contain this source description.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="FamilySearchSourceDescriptionState"/> instance containing the REST API response.
        /// </returns>
        public FamilySearchSourceDescriptionState MoveToCollection(CollectionState collection, params IStateTransitionOption[] options)
        {
            Link link = collection.GetLink(Rel.SOURCE_DESCRIPTIONS);

            if (link == null || link.Href == null)
            {
                return(null);
            }

            SourceDescription me = SourceDescription;

            if (me == null || me.Id == null)
            {
                return(null);
            }

            Gx.Gedcomx gx = new Gx.Gedcomx();
            gx.AddSourceDescription(new SourceDescription()
            {
                Id = me.Id
            });
            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).SetEntity(gx).Build(link.Href, Method.POST);

            return((FamilySearchSourceDescriptionState)((FamilySearchStateFactory)this.stateFactory).NewSourceDescriptionStateInt(request, Invoke(request, options), this.Client, this.CurrentAccessToken));
        }
Ejemplo n.º 12
0
        public NavigationState(string pageAlias, UsageType usageType)
        {
            PageType         = PageType.Page;
            UsageType        = usageType;
            _collectionAlias = pageAlias;

            CollectionState = new CollectionState();
        }
Ejemplo n.º 13
0
 private void OnTriggerEnter(Collider collision)
 {
     if (state == CollectionState.Uncollected)
     {
         helipad.informLoopCollected(gameObject);
         state = CollectionState.Collected;
     }
 }
Ejemplo n.º 14
0
        public void TestObtainAccessTokenWithUsernameAndPassword()
        {
            var collection = new CollectionState(new Uri(SANDBOX_URI));
            var state      = collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);

            Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode);
            Assert.IsNotNullOrEmpty(state.CurrentAccessToken);
        }
Ejemplo n.º 15
0
        public static ILiveList<int> Range(ILiveValue<int> startValue, ILiveValue<int> countValue)
        {
            LiveObserver<IValueState<int>> startObserver = null;
            LiveObserver<IValueState<int>> countObserver = null;

            return LiveListObservable<int>.Create(
                innerChanged =>
                {
                    countValue.Subscribe(countObserver = countValue.CreateObserver(innerChanged));
                    startValue.Subscribe(startObserver = startValue.CreateObserver(innerChanged));
                    return Lockers.Empty;
                },
                (innerChanged, notified, stateLock, oldState) =>
                {
                    // get state
                    var count = countObserver.GetState();
                    var start = startObserver.GetState();
                    var newStatus = count.Status.And(start.Status);

                    // work out delta
                    ListDelta<int> delta = null;
                    if (newStatus.IsDeltaRelevant() && (count.HasChange || start.HasChange))
                    {
                        delta = new ListDelta<int>();

                        // adjust head
                        var head = Math.Min(Math.Max(start.OldValue - start.NewValue, -count.OldValue), count.NewValue);
                        if (head < 0)
                            delta.Delete(0, Enumerable.Range(start.OldValue, -head));
                        else if (head > 0)
                            delta.Insert(0, Enumerable.Range(start.NewValue, head));
                        var currentCount = count.OldValue + head;
                        var leftoverCount = count.OldValue + Math.Min(0, head);

                        // adjust tail
                        var tail = count.NewValue - currentCount;
                        if (tail > 0)
                            delta.Insert(currentCount, Enumerable.Range(start.NewValue + currentCount, tail));
                        else if (tail < 0)
                            delta.Delete(count.NewValue, Enumerable.Range(start.OldValue + count.OldValue + tail, -tail));
                    }

                    // work out new state
                    var result = new CollectionState<int, IListDelta<int>, IList<int>>();
                    result.SetState(
                        oldState.GetStatus().Add(newStatus),
                        delta,
                        Enumerable.Range(start.NewValue, count.NewValue),
                        Math.Max(count.LastUpdated, start.LastUpdated),
                        stateLock);
                    return result;
                },
                () =>
                {
                    startObserver.Dispose();
                    countObserver.Dispose();
                });
        }
Ejemplo n.º 16
0
        private List <string> GetNewDeleteDataItems(CollectionState collectionState, AppData[] allAppData)
        {
            var clientIds = collectionState.Collections.Select(x => x.ServerId).ToList();
            var serverIds = allAppData.Select(x => x.ServerId).ToList();

            var newDeletedIds = clientIds.Except(serverIds).ToList();

            return(newDeletedIds);
        }
Ejemplo n.º 17
0
        public NavigationState(string collectionAlias, IRelated?related, UsageType usageType)
        {
            PageType         = PageType.Collection;
            UsageType        = usageType;
            _collectionAlias = collectionAlias;
            Related          = related;

            CollectionState = new CollectionState();
        }
        // helpers

        private bool Is(CollectionState actualState, CollectionState expectedState)
        {
            if (expectedState == CollectionState.Unknown && actualState != CollectionState.Unknown)
            {
                return(false);
            }

            return((actualState & expectedState) == expectedState);
        }
Ejemplo n.º 19
0
        public NavigationState(string collectionAlias, ParentPath?parentPath, UsageType usageType)
        {
            PageType         = PageType.Collection;
            UsageType        = usageType;
            _collectionAlias = collectionAlias;
            ParentPath       = parentPath;

            CollectionState = new CollectionState();
        }
Ejemplo n.º 20
0
 public void TestObtainAccessTokenWithoutAuthenticating()
 {
     var collection = new CollectionState(new Uri(SANDBOX_URI));
     var response = new WebClient().DownloadString("http://checkip.dyndns.com/");
     var ip = new CQ(response).Select("body").Text().Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
     var state = collection.UnauthenticatedAccess(ip, "WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK");
     Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode);
     Assert.IsNotNullOrEmpty(state.CurrentAccessToken);
 }
Ejemplo n.º 21
0
        public void TestObtainAccessTokenWithoutAuthenticating()
        {
            var collection = new CollectionState(new Uri(SANDBOX_URI));
            var response   = new WebClient().DownloadString("http://checkip.dyndns.com/");
            var ip         = new CQ(response).Select("body").Text().Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries)[1].Trim();
            var state      = collection.UnauthenticatedAccess(ip, "WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK");

            Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode);
            Assert.IsNotNullOrEmpty(state.CurrentAccessToken);
        }
Ejemplo n.º 22
0
        public NavigationState(string collectionAlias, ParentPath?parentPath, IRelated?related, UsageType usageType, PageType pageType)
        {
            PageType         = pageType;
            UsageType        = usageType;
            _collectionAlias = collectionAlias;
            ParentPath       = parentPath;
            Related          = related;

            CollectionState = new CollectionState();
        }
Ejemplo n.º 23
0
 public void Initialize()
 {
     collection = new CollectionState(new Uri(SANDBOX_URI));
     collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     tree = new FamilySearchFamilyTree(true);
     tree.AuthenticateWithAccessToken(collection.CurrentAccessToken);
     cleanup = new List<GedcomxApplicationState>();
     Assert.DoesNotThrow(() => collection.IfSuccessful());
     Assert.IsNotNullOrEmpty(collection.CurrentAccessToken);
 }
Ejemplo n.º 24
0
        public void Initialize()
        {
            collection = new CollectionState(new Uri(SANDBOX_URI));
            collection.AuthenticateViaOAuth2Password("sdktester", "1234sdkpass", "WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK");
            Assert.DoesNotThrow(() => collection.IfSuccessful());
            Assert.IsNotNullOrEmpty(collection.CurrentAccessToken);

            tree = new FamilySearchFamilyTree(true);
            tree.AuthenticateWithAccessToken(collection.CurrentAccessToken);
        }
Ejemplo n.º 25
0
 public void Initialize()
 {
     collection = new CollectionState(new Uri(SANDBOX_URI));
     collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     tree = new FamilySearchFamilyTree(true);
     tree.AuthenticateWithAccessToken(collection.CurrentAccessToken);
     cleanup = new List <GedcomxApplicationState>();
     Assert.DoesNotThrow(() => collection.IfSuccessful());
     Assert.IsNotNullOrEmpty(collection.CurrentAccessToken);
 }
Ejemplo n.º 26
0
        public NavigationState(string collectionAlias, ParentPath?parentPath, string variantAlias, string?id, UsageType usageType)
        {
            PageType         = PageType.Node;
            UsageType        = usageType;
            _collectionAlias = collectionAlias;
            VariantAlias     = variantAlias;
            ParentPath       = parentPath;
            Id = id;

            CollectionState = new CollectionState();
        }
Ejemplo n.º 27
0
        public void TestReadFamilyTreeCollection()
        {
            var state = new CollectionState(new Uri(collection.GetLink("family-tree").Href));

            Assert.DoesNotThrow(() => state.IfSuccessful());
            Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode);
            Assert.IsNotNull(state.Links);
            Assert.Greater(state.Links.Count, 0);
            Assert.IsNotNull(state.Entity);
            Assert.IsNotNull(state.Entity.Collections);
            Assert.Greater(state.Entity.Collections.Count, 0);
        }
Ejemplo n.º 28
0
 public void TestDeleteAccessToken()
 {
     var collection = new CollectionState(new Uri(SANDBOX_URI));
     collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
     Assert.IsTrue(collection.IsAuthenticated);
     Link link = collection.GetLink(Rel.OAUTH2_TOKEN);
     IRestRequest request = new RedirectableRestRequest()
         .Accept(MediaTypes.APPLICATION_JSON_TYPE)
         .Build(link.Href + "?access_token=" + collection.CurrentAccessToken, Method.DELETE);
     IRestResponse response = collection.Client.Handle(request);
     Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode);
 }
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         state = CollectionState.Held;
         transform.SetParent(collision.gameObject.transform);
         transform.localPosition              = new Vector3(0f, 2f, 0f);
         transform.localEulerAngles           = Vector3.zero;
         GetComponent <BoxCollider>().enabled = false;
         anim.SetBool("isHeld", true);
     }
 }
Ejemplo n.º 30
0
        public void TestReadFamilyTreeCollection()
        {
            var state = new CollectionState(new Uri(collection.GetLink("family-tree").Href));

            Assert.DoesNotThrow(() => state.IfSuccessful());
            Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode);
            Assert.IsNotNull(state.Links);
            Assert.Greater(state.Links.Count, 0);
            Assert.IsNotNull(state.Entity);
            Assert.IsNotNull(state.Entity.Collections);
            Assert.Greater(state.Entity.Collections.Count, 0);
        }
Ejemplo n.º 31
0
        private NavigationState(string?collectionAlias, PageType pageType, UsageType usageType, string?variantAlias, ParentPath?parentPath, IRelated?related, string?id)
        {
            _collectionAlias = collectionAlias;
            PageType         = pageType;
            UsageType        = usageType;
            VariantAlias     = variantAlias;
            ParentPath       = parentPath;
            Related          = related;
            Id = id;

            CollectionState = new CollectionState();
        }
Ejemplo n.º 32
0
        private List <AppData> GetNewDataItems(CollectionState collectionState, AppData[] allAppData)
        {
            var clientIds = collectionState.Collections.Select(x => x.ServerId).ToList();
            var serverIds = allAppData.Select(x => x.ServerId).ToList();

            var newAddedIds = serverIds.Except(clientIds).ToList();
            var newItems    = (from appData in allAppData
                               let newIds = newAddedIds
                                            where newIds.Contains(appData.ServerId)
                                            select appData).ToList();

            return(newItems);
        }
Ejemplo n.º 33
0
        public static void TestSort(Algorithm algorithm, CollectionState state)
        {
            Console.WriteLine("**{0}; Collection state: {1}", algorithm, state);

            int[] workIntArray = GetCollection <int>(state, Type.Integer);
            TestSort(workIntArray, algorithm, Type.Integer);

            double[] workDoubleArray = GetCollection <double>(state, Type.Double);
            TestSort(workDoubleArray, algorithm, Type.Double);

            string[] workStringArray = GetCollection <string>(state, Type.String);
            TestSort(workStringArray, algorithm, Type.String);
        }
Ejemplo n.º 34
0
        public void TestDeleteAccessToken()
        {
            var collection = new CollectionState(new Uri(SANDBOX_URI));

            collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
            Assert.IsTrue(collection.IsAuthenticated);
            Link         link    = collection.GetLink(Rel.OAUTH2_TOKEN);
            IRestRequest request = new RedirectableRestRequest()
                                   .Accept(MediaTypes.APPLICATION_JSON_TYPE)
                                   .Build(link.Href + "?access_token=" + collection.CurrentAccessToken, Method.DELETE);
            IRestResponse response = collection.Client.Handle(request);

            Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode);
        }
Ejemplo n.º 35
0
        public NavigationState(string url, string queryString)
        {
            var urlItems = url.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);

            if (urlItems.Length == 0)
            {
                PageType = PageType.Dashboard;
            }
            else
            {
                PageType = Enum.TryParse <PageType>(urlItems[0], true, out var pageType) ? pageType : PageType.Dashboard;

                if (urlItems.Length > 1)
                {
                    switch (PageType)
                    {
                    case PageType.Collection:

                        UsageType        = Enum.TryParse <UsageType>(urlItems.ElementAtOrDefault(1), true, out var usageType1) ? usageType1 : UsageType.View;
                        _collectionAlias = urlItems.ElementAtOrDefault(2);
                        ParentPath       = ParentPath.TryParse(urlItems.ElementAtOrDefault(3));
                        break;

                    case PageType.Node:

                        UsageType        = Enum.TryParse <UsageType>(urlItems.ElementAtOrDefault(1), true, out var usageType2) ? usageType2 : UsageType.View;
                        _collectionAlias = urlItems.ElementAtOrDefault(2);
                        VariantAlias     = urlItems.ElementAtOrDefault(3);
                        ParentPath       = ParentPath.TryParse(urlItems.ElementAtOrDefault(4));
                        Id = urlItems.ElementAtOrDefault(5);
                        break;

                    case PageType.Page:

                        _collectionAlias = urlItems.ElementAtOrDefault(1);

                        break;
                    }
                }
            }

            var qs          = HttpUtility.ParseQueryString(queryString);
            var tab         = int.TryParse(qs.Get("tab"), out var t) ? t : default(int?);
            var searchTerm  = qs.Get("q");
            var currentPage = int.TryParse(qs.Get("p"), out var p) ? p : 1;

            CollectionState = new CollectionState(tab, searchTerm, currentPage);
        }
Ejemplo n.º 36
0
        public void TestObtainAccessTokenBadParameters()
        {
            var collection = new CollectionState(new Uri(SANDBOX_URI));
            Link tokenLink = collection.GetLink(Rel.OAUTH2_TOKEN);
            IDictionary<String, String> formData = new Dictionary<String, String>();
            formData.Add("grant_type", "authorization_code");
            formData.Add("code", "tGzv3JOkF0XG5Qx2TlKWIA");
            formData.Add("client_id", "WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK");
            IRestRequest request = new RedirectableRestRequest()
                .Accept(MediaTypes.APPLICATION_JSON_TYPE)
                .ContentType(MediaTypes.APPLICATION_FORM_URLENCODED_TYPE)
                .SetEntity(formData)
                .Build(tokenLink.Href, Method.POST);
            IRestResponse response = collection.Client.Handle(request);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
Ejemplo n.º 37
0
        public void TestObtainAccessTokenBadParameters()
        {
            var  collection = new CollectionState(new Uri(SANDBOX_URI));
            Link tokenLink  = collection.GetLink(Rel.OAUTH2_TOKEN);
            IDictionary <String, String> formData = new Dictionary <String, String>();

            formData.Add("grant_type", "authorization_code");
            formData.Add("code", "tGzv3JOkF0XG5Qx2TlKWIA");
            formData.Add("client_id", "WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK");
            IRestRequest request = new RedirectableRestRequest()
                                   .Accept(MediaTypes.APPLICATION_JSON_TYPE)
                                   .ContentType(MediaTypes.APPLICATION_FORM_URLENCODED_TYPE)
                                   .SetEntity(formData)
                                   .Build(tokenLink.Href, Method.POST);
            IRestResponse response = collection.Client.Handle(request);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
Ejemplo n.º 38
0
        public void TestInitiateAuthorizationGet()
        {
            var collection = new CollectionState(new Uri(SANDBOX_URI));
            Link tokenLink = collection.GetLink(Rel.OAUTH2_AUTHORIZE);
            IDictionary<String, String> formData = new Dictionary<String, String>();
            formData.Add("response_type", "code");
            formData.Add("client_id", "ABCD-EFGH-JKLM-NOPQ-RSTU-VWXY-0123-4567");
            formData.Add("redirect_uri", "https://familysearch.org/developers/sandbox-oauth2-redirect");
            IRestRequest request = new RedirectableRestRequest()
                .SetEntity(formData)
                .Build(tokenLink.Href, Method.GET);
            IRestResponse response = collection.Client.Handle(request);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            var cq = new CQ(response.Content);
            Assert.AreEqual(1, cq.Select("input#userName").Length);
            Assert.AreEqual(1, cq.Select("input#password").Length);
        }
        //TODO: Create FamilysearchSourceReferencesQueryState class, add it to FamilySearchStateFactory when link is created
        /*
        public FamilySearchSourceReferencesQueryState ReadSourceReferencesQuery()
        {
            Link link = GetLink( //TODO: Put Rel here when added );
            if (link == null || link.Href = null)
            {
                return null;
            }

            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).Build(link.Href, Method.GET);
            return ((FamilySearchStateFactory)this.stateFactory).NewFamilySearchSourceReferencesQueryState(request, Invoke(request), this.Client, this.CurrentAccessToken);
        }
        */

        /// <summary>
        /// Moves the current source description to the specified collection.
        /// </summary>
        /// <param name="collection">The target collection to contain this source description.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="FamilySearchSourceDescriptionState"/> instance containing the REST API response.
        /// </returns>
        public FamilySearchSourceDescriptionState MoveToCollection(CollectionState collection, params IStateTransitionOption[] options)
        {
            Link link = collection.GetLink(Rel.SOURCE_DESCRIPTIONS);
            if (link == null || link.Href == null)
            {
                return null;
            }

            SourceDescription me = SourceDescription;
            if (me == null || me.Id == null)
            {
                return null;
            }

            Gx.Gedcomx gx = new Gx.Gedcomx();
            gx.AddSourceDescription(new SourceDescription() { Id = me.Id });
            IRestRequest request = RequestUtil.ApplyFamilySearchConneg(CreateAuthenticatedRequest()).SetEntity(gx).Build(link.Href, Method.POST);
            return (FamilySearchSourceDescriptionState)((FamilySearchStateFactory)this.stateFactory).NewSourceDescriptionStateInt(request, Invoke(request, options), this.Client, this.CurrentAccessToken);
        }
Ejemplo n.º 40
0
        public Collection(Vector2 ScreenRes, Color FontColor, bool[] IsSovietCardInCollection, bool[] IsGermanCardInCollection, int CardTextureWidth, float Layer = BasicSprite.DefaultLayer)
        {
            Cards      = new Card[3];
            DeckChange = new Button[8];

            this.CardTextureWidth = CardTextureWidth;
            CardTextureHeight     = GameContent.CardTexture.Height;
            this.Layer            = Layer;

            Pages        = (GameContent.UnitCards.Count - 1) / Cards.Length + 1;
            GermanyPages = (GameContent.GermanyUnitCards.Count - 1) / Cards.Length + 1;
            SovietPages  = (GameContent.SovietUnitCards.Count - 1) / Cards.Length + 1;
            Page         = 1;

            var TmpVect = new Vector2((ScreenRes.X - 300 - CardTextureWidth * Cards.Length) / (Cards.Length + 1), ScreenRes.Y - CardTextureHeight * 1.5f);

            for (var i = 0; i < Cards.Length; i++)
            {
                Cards[i] = new Card(new Vector2(TmpVect.X * (i + 1) + CardTextureWidth * i, TmpVect.Y), GameContent.CardTexture, GameContent.UnitCards[0].Card_Decoration, new Vector2(16, 9), 200, 10, 0, 13, new Animation(14, 16, true), new Animation(2, 6, false), new Animation(7, 12, false), new Animation(1, 1, true), 0, GameContent.UI_InfoFont, Color.White, GameContent.UnitCards[0].Name, GameContent.UnitCards[0].Damage.ToString(), GameContent.UnitCards[0].Armor.ToString(), GameContent.UnitCards[0].AttackRadius.ToString(), GameContent.UnitCards[0].Speed.ToString(), GameContent.UnitCards[0].HP.ToString(), GameContent.UnitCards[0].Cost.ToString(), 141, 315, 4, 4, 37, true, MapZones.ALL, Layer: Layer);
            }

            PageText = new BasicText(new Vector2((ScreenRes.X - 300 - GameContent.UI_MainMenu_Collection_PageTextFont.MeasureString("10").X) / 2, ScreenRes.Y - GameContent.UI_MainMenu_Collection_Prev.Height - 20), "10", GameContent.UI_MainMenu_Collection_PageTextFont, FontColor, Layer - 0.001f);
            Prev     = new Button(new Vector2(PageText.Position.X - GameContent.UI_MainMenu_Collection_Prev.Width / 4 - 10, PageText.Position.Y - (GameContent.UI_MainMenu_Collection_Prev.Height - GameContent.UI_MainMenu_Collection_PageTextFont.MeasureString("10").Y) / 2), GameContent.UI_MainMenu_Collection_Prev, GameContent.UI_MainMenu_Collection_Prev.Width / 4, 60, 0, new Animation(1, 1, true), 2, 3, Layer - 0.001f);
            Next     = new Button(new Vector2(PageText.Position.X + 10 + GameContent.UI_MainMenu_Collection_PageTextFont.MeasureString("10").X + 3, PageText.Position.Y - (GameContent.UI_MainMenu_Collection_Prev.Height - GameContent.UI_MainMenu_Collection_PageTextFont.MeasureString("10").Y) / 2), GameContent.UI_MainMenu_Collection_Next, GameContent.UI_MainMenu_Collection_Next.Width / 4, 60, 0, new Animation(1, 1, true), 2, 3, Layer - 0.001f);

            BackGround_Bottom = new BasicSprite(new Vector2(0, ScreenRes.Y - GameContent.UI_MainMenu_Collection_Bottom.Height), GameContent.UI_MainMenu_Collection_Bottom, Layer - 0.0002f);
            BackGround_Right  = new BasicSprite(new Vector2(ScreenRes.X - GameContent.UI_MainMenu_Collection_Right.Width, 102), GameContent.UI_MainMenu_Collection_Right, Layer - 0.0001f);
            for (var i = 0; i < DeckChange.Length / 2; i++)
            {
                DeckChange[i] = new Button(new Vector2(BackGround_Right.Position.X, BackGround_Right.Position.Y + i * GameContent.UI_MainMenu_SovietDeck.Height), GameContent.UI_MainMenu_SovietDeck, "Колода " + i, GameContent.UI_ButtonFont, Color.White, GameContent.UI_MainMenu_SovietDeck.Width / 4, 60, 0, new Animation(1, 1, true), 2, 3, Layer - 0.002f);
            }
            for (var i = DeckChange.Length / 2; i < DeckChange.Length; i++)
            {
                DeckChange[i] = new Button(new Vector2(BackGround_Right.Position.X, BackGround_Right.Position.Y + i * GameContent.UI_MainMenu_GermanDeck.Height), GameContent.UI_MainMenu_GermanDeck, "Колода " + i, GameContent.UI_ButtonFont, Color.White, GameContent.UI_MainMenu_GermanDeck.Width / 4, 60, 0, new Animation(1, 1, true), 2, 3, Layer - 0.002f);
            }

            Hide();

            State = CollectionState.ALL_CARDS;

            this.ScreenRes = ScreenRes;
        }
        private void Set(SessionId session, int index, CollectionState state)
        {
            if (GloballyCollect)
            {
                session = SessionId.Invalid;
            }
            bool enabled = state != CollectionState.None;

            try
            {
                if (state != CollectionState.None)
                {
                    Collectors[InteractionObjectives[index].ComponentId][session] = state;
                }
                else
                {
                    Collectors[InteractionObjectives[index].ComponentId].Remove(session);
                }

                if (GloballyCollect)
                {
                    Interactions[index].SetEnabled(enabled);
                }
                else
                {
                    Interactions[index].SetEnabled(session, enabled);
                }

                if (HideCollected && InteractionObjectives[index].IsScriptable)
                {
                    if (GloballyCollect)
                    {
                        InteractionObjectives[index].SetIsVisible(enabled);
                    }
                    else
                    {
                        InteractionObjectives[index].SetIsVisible(session, enabled);
                    }
                }
            }
            catch { }
        }
Ejemplo n.º 42
0
        public void TestInitiateAuthorizationGet()
        {
            var  collection = new CollectionState(new Uri(SANDBOX_URI));
            Link tokenLink  = collection.GetLink(Rel.OAUTH2_AUTHORIZE);
            IDictionary <String, String> formData = new Dictionary <String, String>();

            formData.Add("response_type", "code");
            formData.Add("client_id", "ABCD-EFGH-JKLM-NOPQ-RSTU-VWXY-0123-4567");
            formData.Add("redirect_uri", "https://familysearch.org/developers/sandbox-oauth2-redirect");
            IRestRequest request = new RedirectableRestRequest()
                                   .SetEntity(formData)
                                   .Build(tokenLink.Href, Method.GET);
            IRestResponse response = collection.Client.Handle(request);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            var cq = new CQ(response.Content);

            Assert.AreEqual(1, cq.Select("input#userName").Length);
            Assert.AreEqual(1, cq.Select("input#password").Length);
        }
Ejemplo n.º 43
0
        public void TestInitiateAuthorizationInvalidParameter()
        {
            var collection = new CollectionState(new Uri(SANDBOX_URI));
            Link tokenLink = collection.GetLink(Rel.OAUTH2_AUTHORIZE);
            IDictionary<String, String> formData = new Dictionary<String, String>();
            formData.Add("response_type", "authorize_me");
            formData.Add("client_id", "ABCD-EFGH-JKLM-NOPQ-RSTU-VWXY-0123-4567");
            formData.Add("redirect_uri", "https://familysearch.org/developers/sandbox-oauth2-redirect");
            IRestRequest request = new RedirectableRestRequest()
                .ContentType(MediaTypes.APPLICATION_FORM_URLENCODED_TYPE)
                .SetEntity(formData)
                .Build(tokenLink.Href, Method.POST);
            IRestResponse response = collection.Client.Handle(request);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            var cq = new CQ(response.Content);
            Assert.AreEqual(1, cq.Select("p#error").Length);
        }
Ejemplo n.º 44
0
 public void Initialize()
 {
     factory = new FamilySearchStateFactory();
     collection = factory.NewCollectionState(new Uri("https://sandbox.familysearch.org/platform/collection"));
     collection.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId);
 }
Ejemplo n.º 45
0
 /// <summary>
 /// Invalidates the current graphics and blocks for them to be finished redrawing
 /// </summary>
 public void SaveState(List<int> activeItems, CollectionState.ActionType action)
 {
     States.Enqueue(new CollectionState(collection, activeItems, action));
 }
        private static CollectionState ReduceExistingStates(ContentItem child, ContentItem parent, CollectionState requiredState)
        {
            var remainingState = requiredState;
            foreach (var sibling in parent.Children)
            {
                if (sibling == child)
                    continue;

                // hoops indented to avoid looping over the whole collection if not necessary
                remainingState ^= sibling.GetCollectionState() & remainingState;

                if (remainingState == CollectionExtensions.None)
                    break;
            }

            return remainingState;
        }
        // helpers
        private bool Is(CollectionState actualState, CollectionState expectedState)
        {
            if (expectedState == CollectionState.Unknown && actualState != CollectionState.Unknown)
                return false;

            return (actualState & expectedState) == expectedState;
        }