示例#1
0
        private void _addRelationships(DocumentData data, ContextEntity contextEntity, IIdentifiable entity)
        {
            var linkBuilder = new LinkBuilder(_jsonApiContext);

            contextEntity.Relationships.ForEach(r =>
            {
                var relationshipData = new RelationshipData
                {
                    Links = new Links
                    {
                        Self    = linkBuilder.GetSelfRelationLink(contextEntity.EntityName, entity.Id.ToString(), r.RelationshipName),
                        Related = linkBuilder.GetRelatedRelationLink(contextEntity.EntityName, entity.Id.ToString(), r.RelationshipName)
                    }
                };

                if (_hasRelationship(r.RelationshipName))
                {
                    var navigationEntity = _jsonApiContext.ContextGraph
                                           .GetRelationship(entity, r.RelationshipName);

                    if (navigationEntity is IEnumerable)
                    {
                        relationshipData.ManyData = _getRelationships((IEnumerable <object>)navigationEntity, r.RelationshipName);
                    }
                    else
                    {
                        relationshipData.SingleData = _getRelationship(navigationEntity, r.RelationshipName);
                    }
                }

                data.Relationships.Add(r.RelationshipName.Dasherize(), relationshipData);
            });
        }
        /// <summary>
        ///     Gets the control visibility calculations.
        /// </summary>
        /// <param name="formEntityData">The form entity data.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        private IDictionary <long, string> GetControlVisibilityCalculations(EntityData formEntityData)
        {
            ISet <long> controlTypes =
                PerTenantEntityTypeCache.Instance.GetDescendantsAndSelf(WellKnownAliases.CurrentTenant.ControlOnForm);

            var controlVisibilityCalculations = new Dictionary <long, string>();

            // Enumerate form controls and find visibilityCalculations
            EntityData.WalkRelationshipTree(formEntityData, node =>
            {
                RelationshipData isOfType = node.GetRelationship(WellKnownAliases.CurrentTenant.IsOfType);
                if (isOfType?.Entities == null)
                {
                    return;
                }

                if (!controlTypes.Overlaps(isOfType.Entities.Select(e => e.Id.Id)))
                {
                    return;
                }

                FieldData visibilityCalculationField = node.GetField(WellKnownAliases.CurrentTenant.VisibilityCalculation);

                var visibilityCalculation = visibilityCalculationField?.Value?.Value as string;

                if (string.IsNullOrWhiteSpace(visibilityCalculation))
                {
                    return;
                }

                controlVisibilityCalculations[node.Id.Id] = visibilityCalculation;
            }, null, null);

            return(controlVisibilityCalculations);
        }
示例#3
0
            public override void RemoveRelationship(long entityId, long startNode, long endNode)
            {
                RelationshipData entity = new RelationshipData(entityId, startNode, endNode);

                Transaction.remove(this, entity);
                AddRemoveCommand(entityId, null, null);
            }
示例#4
0
        /// <summary>
        /// Remove entities that lack a "core:allowDisplay" relationship to any of the
        /// given <paramref name="subjectIds"/>.
        /// </summary>
        /// <param name="entityData">
        /// The <see cref="EntityData"/> to check. This cannot be null.
        /// </param>
        /// <param name="subjectIds">
        /// The subject IDs to check for. This cannot be null.
        /// </param>
        /// <param name="userId">The ID of the user.</param>
        /// <param name="userIsAdmin">True if the user is an admin</param>
        /// <exception cref="ArgumentNullException">
        /// No argument can be null.
        /// </exception>
        public bool CanSeeElement(EntityData entityData, ISet <long> subjectIds, long userId, bool userIsAdmin)
        {
            if (entityData == null)
            {
                throw new ArgumentNullException("entityData");
            }
            if (subjectIds == null)
            {
                throw new ArgumentNullException("subjectIds");
            }

            // Check for feature switches
            string navFeatureSwitch = entityData.GetField(NavFeatureSwitchId)?.Value?.ValueString;

            if (navFeatureSwitch != null)
            {
                if (!FeatureSwitch.Get(navFeatureSwitch))
                {
                    return(false);
                }
            }

            if (userIsAdmin)
            {
                FieldData isPrivatelyOwnedFieldData = entityData.GetField(WellKnownAliases.CurrentTenant.IsPrivatelyOwned);

                bool isPrivatelyOwned = isPrivatelyOwnedFieldData != null && (bool?)isPrivatelyOwnedFieldData.Value.Value == true;

                if (!isPrivatelyOwned)
                {
                    return(true); // admin can see all public elements
                }
            }
            else
            {
                RelationshipData allowDisplayRelationshipData;

                allowDisplayRelationshipData = entityData.GetRelationship(WellKnownAliases.CurrentTenant.AllowDisplay, Direction.Reverse);

                bool allowDisplay = allowDisplayRelationshipData != null && allowDisplayRelationshipData.Entities.Any(e => subjectIds.Contains(e.Id.Id));
                if (allowDisplay)
                {
                    return(true);
                }
            }

            // Finally, in both cases check if the nav item is owned by the user

            RelationshipData securityOwnerRelationshipData = entityData.GetRelationship(WellKnownAliases.CurrentTenant.SecurityOwner, Direction.Forward);

            bool securityOwner = securityOwnerRelationshipData != null && securityOwnerRelationshipData.Entities.Any(e => userId == e.Id.Id);

            if (securityOwner)
            {
                return(true);
            }

            return(false);
        }
示例#5
0
            public override void RemoveRelationship(long entityId, string key, long startNode, long endNode)
            {
                AssertValidKey(key);
                RelationshipData entity = new RelationshipData(entityId, startNode, endNode);

                Transaction.remove(this, entity, key);
                AddRemoveCommand(entityId, key, null);
            }
示例#6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public <EXCEPTION extends Exception> void relationshipVisit(long relationshipId, RelationshipVisitor<EXCEPTION> relationshipVisitor) throws org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException, EXCEPTION
        public override void RelationshipVisit <EXCEPTION>(long relationshipId, RelationshipVisitor <EXCEPTION> relationshipVisitor) where EXCEPTION : Exception
        {
            RelationshipData data = this._relationshipData[relationshipId];

            if (data == null)
            {
                throw new EntityNotFoundException(EntityType.Relationship, relationshipId);
            }
            relationshipVisitor.Visit(relationshipId, data.Type, data.StartNode, data.EndNode);
        }
        /// <summary>
        ///     Gets the type to edit with form.
        /// </summary>
        /// <param name="formEntityData">The form entity data.</param>
        /// <returns></returns>
        private long GetTypeToEditWithForm(EntityData formEntityData)
        {
            RelationshipData entityTypeRelData = formEntityData?.GetRelationship(WellKnownAliases.CurrentTenant.TypeToEditWithForm);

            if ((entityTypeRelData?.Entities == null) || !entityTypeRelData.Entities.Any())
            {
                return(-1);
            }

            return(entityTypeRelData.Entities.Select(e => e.Id.Id).FirstOrDefault());
        }
示例#8
0
        /// <summary>
        /// Determine if two relationship data refer to the same relationship in the same direction.
        /// </summary>
        private static bool SameRelationship(RelationshipData rel1, RelationshipData rel2)
        {
            if (rel1.RelationshipTypeId.Id != rel2.RelationshipTypeId.Id)
            {
                return(false);
            }

            var dir1 = GetDirection(rel1.RelationshipTypeId, rel1.IsReverse);
            var dir2 = GetDirection(rel2.RelationshipTypeId, rel2.IsReverse);

            return(dir1 == dir2);
        }
示例#9
0
            public override void RemoveRelationship(long entityId, string key, object value, long startNode, long endNode)
            {
                AssertValidKey(key);
                RelationshipData entity = new RelationshipData(entityId, startNode, endNode);

                foreach (object oneValue in IoPrimitiveUtils.asArray(value))
                {
                    oneValue = GetCorrectValue(oneValue);
                    Transaction.remove(this, entity, key, oneValue);
                    AddRemoveCommand(entityId, key, oneValue);
                }
            }
示例#10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void addRelationship(long entityId, String key, Object value, long startNode, long endNode) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException
            public override void AddRelationship(long entityId, string key, object value, long startNode, long endNode)
            {
                AssertValidKey(key);
                AssertValidValue(value);
                RelationshipData entity = new RelationshipData(entityId, startNode, endNode);

                foreach (object oneValue in IoPrimitiveUtils.asArray(value))
                {
                    oneValue = GetCorrectValue(oneValue);
                    DataSource.assertValidType(key, oneValue, IdentifierConflict);
                    Transaction.add(this, entity, key, oneValue);
                    CommandFactory.addRelationship(IdentifierConflict.indexName, entityId, key, oneValue, startNode, endNode);
                }
            }
示例#11
0
    public static void AddRelationship(Pathea.PeEntity player, Pathea.PeEntity mounts)
    {
        if (mRelationship.Count >= 1 || player == null || mounts == null)
        {
            return;
        }
        RelationshipData _data = new RelationshipData();

        _data._playerId      = player.Id;
        _data._mountsProtoId = mounts.ProtoID;
        _data.AddData(mounts);

        mRelationship.Add(_data);
    }
        public int Calculate(IRelationshipInputData data)
        {
            var relationshipData = new RelationshipData(data);
            var relationships    = relationshipData.Data
                                   .Select(r => new Relationship <string>(r.Key, r.Value))
                                   .ToList();

            var root = new TreeNode <string>("COM");

            var tree = new Tree <string>(root, relationships);

            var count = tree.CountNodes();

            return(count);
        }
        public int Calculate(IRelationshipInputData data)
        {
            var relationshipData = new RelationshipData(data);
            var relationships    = relationshipData.Data
                                   .Select(r => new Relationship <string>(r.Key, r.Value))
                                   .ToList();

            var root = new TreeNode <string>("COM");

            var tree = new Tree <string>(root, relationships);

            var distance = tree.DistanceBetweenNodes("YOU", "SAN");

            return(distance);
        }
        private RelationshipData CreateRelationshipData(string alias, params long [] entities)
        {
            Direction        direction = Entity.GetDirection(new EntityRef(alias));
            RelationshipData relationshipData;

            relationshipData = new RelationshipData
            {
                RelationshipTypeId = new EntityRef(alias),
                Instances          = entities.Select(id => new RelationshipInstanceData {
                    Entity = CreateEntityData(id)
                }).ToList( ),
                IsReverseActual = direction == Direction.Reverse
            };

            return(relationshipData);
        }
        private bool FoundResource(EntityData entity)
        {
            if ("Resource" == entity.Fields[0].Value.Value.ToString())
            {
                return(true);
            }

            RelationshipData rel = entity.GetRelationship("core:inherits");

            if (rel != null)
            {
                return(rel.Instances.Any(inst => FoundResource(inst.Entity)));
            }

            return(false);
        }
示例#16
0
        private void AddRelationships(DocumentData data, ContextEntity contextEntity, IIdentifiable entity)
        {
            data.Relationships = new Dictionary <string, RelationshipData>();
            var linkBuilder = new LinkBuilder(_jsonApiContext);

            contextEntity.Relationships.ForEach(r =>
            {
                var relationshipData = new RelationshipData();

                if (r.DocumentLinks.HasFlag(Link.None) == false)
                {
                    relationshipData.Links = new Links();
                    if (r.DocumentLinks.HasFlag(Link.Self))
                    {
                        relationshipData.Links.Self = linkBuilder.GetSelfRelationLink(contextEntity.EntityName, entity.StringId, r.PublicRelationshipName);
                    }

                    if (r.DocumentLinks.HasFlag(Link.Related))
                    {
                        relationshipData.Links.Related = linkBuilder.GetRelatedRelationLink(contextEntity.EntityName, entity.StringId, r.PublicRelationshipName);
                    }
                }

                if (RelationshipIsIncluded(r.PublicRelationshipName))
                {
                    var navigationEntity = _jsonApiContext.ContextGraph
                                           .GetRelationship(entity, r.InternalRelationshipName);

                    if (navigationEntity == null)
                    {
                        relationshipData.SingleData = null;
                    }
                    else if (navigationEntity is IEnumerable)
                    {
                        relationshipData.ManyData = GetRelationships((IEnumerable <object>)navigationEntity);
                    }
                    else
                    {
                        relationshipData.SingleData = GetRelationship(navigationEntity);
                    }
                }

                data.Relationships.Add(r.PublicRelationshipName, relationshipData);
            });
        }
        public void Setting_ExposedData_To_RIO_Sets_SingleData()
        {
            // arrange
            var relationshipData = new RelationshipData();
            var relationship     = new ResourceIdentifierObject {
                Id   = "9",
                Type = "authors"
            };

            // act
            relationshipData.ExposedData = relationship;

            // assert
            Assert.NotNull(relationshipData.SingleData);
            Assert.Equal("authors", relationshipData.SingleData.Type);
            Assert.Equal("9", relationshipData.SingleData.Id);
            Assert.False(relationshipData.IsHasMany);
        }
        public void Setting_ExposedData_To_List_Sets_ManyData()
        {
            // arrange
            var relationshipData = new RelationshipData();
            var relationships    = new List <ResourceIdentifierObject> {
                new ResourceIdentifierObject {
                    Id   = "9",
                    Type = "authors"
                }
            };

            // act
            relationshipData.ExposedData = relationships;

            // assert
            Assert.NotEmpty(relationshipData.ManyData);
            Assert.Equal("authors", relationshipData.ManyData[0].Type);
            Assert.Equal("9", relationshipData.ManyData[0].Id);
            Assert.True(relationshipData.IsHasMany);
        }
        public void Setting_ExposedData_To_JObject_Sets_SingleData()
        {
            // arrange
            var relationshipData = new RelationshipData();
            var relationshipJson = @"{
                    ""id"": ""9"",
                    ""type"": ""authors""
                }";

            var relationship = JObject.Parse(relationshipJson);

            // act
            relationshipData.ExposedData = relationship;

            // assert
            Assert.NotNull(relationshipData.SingleData);
            Assert.Equal("authors", relationshipData.SingleData.Type);
            Assert.Equal("9", relationshipData.SingleData.Id);
            Assert.False(relationshipData.IsHasMany);
        }
示例#20
0
            public override bool Next()
            {
                if (Iterator != null)
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    if (!Iterator.hasNext())
                    {
                        return(false);
                    }
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    NextConflict = Iterator.next();
                }

                if (NextConflict != NO_ID)
                {
                    Current      = outerInstance.relationshipData[NextConflict];
                    NextConflict = NO_ID;
                    return(true);
                }
                return(false);
            }
        private RelationshipData GetRelationshipData(RelationshipAttribute attr, ContextEntity contextEntity, IIdentifiable entity)
        {
            var linkBuilder = new LinkBuilder(_jsonApiContext);

            var relationshipData = new RelationshipData();

            if (attr.DocumentLinks.HasFlag(Link.None) == false)
            {
                relationshipData.Links = new Links();
                if (attr.DocumentLinks.HasFlag(Link.Self))
                {
                    relationshipData.Links.Self = linkBuilder.GetSelfRelationLink(contextEntity.EntityName, entity.StringId, attr.PublicRelationshipName);
                }

                if (attr.DocumentLinks.HasFlag(Link.Related))
                {
                    relationshipData.Links.Related = linkBuilder.GetRelatedRelationLink(contextEntity.EntityName, entity.StringId, attr.PublicRelationshipName);
                }
            }

            // this only includes the navigation property, we need to actually check the navigation property Id
            var navigationEntity = _jsonApiContext.ResourceGraph.GetRelationshipValue(entity, attr);

            if (navigationEntity == null)
            {
                relationshipData.SingleData = attr.IsHasOne
                    ? GetIndependentRelationshipIdentifier((HasOneAttribute)attr, entity)
                    : null;
            }
            else if (navigationEntity is IEnumerable)
            {
                relationshipData.ManyData = GetRelationships((IEnumerable <object>)navigationEntity);
            }
            else
            {
                relationshipData.SingleData = GetRelationship(navigationEntity);
            }

            return(relationshipData);
        }
        public void Setting_ExposedData_To_JArray_Sets_ManyData()
        {
            // arrange
            var relationshipData  = new RelationshipData();
            var relationshipsJson = @"[
                {
                    ""type"": ""authors"",
                    ""id"": ""9""
                }
            ]";

            var relationships = JArray.Parse(relationshipsJson);

            // act
            relationshipData.ExposedData = relationships;

            // assert
            Assert.NotEmpty(relationshipData.ManyData);
            Assert.Equal("authors", relationshipData.ManyData[0].Type);
            Assert.Equal("9", relationshipData.ManyData[0].Id);
            Assert.True(relationshipData.IsHasMany);
        }
示例#23
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="JsonRelationshipData" /> class.
 /// </summary>
 /// <param name="relationshipData">The relationship data.</param>
 /// <param name="context">The context.</param>
 public JsonRelationshipData(RelationshipData relationshipData, JsonEntityQueryResult context)
 {
     RelTypeId = new JsonEntityRef
     {
         Id        = relationshipData.RelationshipTypeId.Id,
         NameSpace = relationshipData.RelationshipTypeId.Namespace,
         Alias     = relationshipData.RelationshipTypeId.Alias
     };
     IsReverse       = relationshipData.IsReverse;
     IsLookup        = relationshipData.IsLookup;
     RemoveExisting  = relationshipData.RemoveExisting;
     DeleteExisting  = relationshipData.DeleteExisting;
     AutoCardinality = relationshipData.AutoCardinality;
     Instances       = new List <JsonRelationshipInstanceData>( );
     if (context != null)
     {
         foreach (RelationshipInstanceData instance in relationshipData.Instances)
         {
             Instances.Add(new JsonRelationshipInstanceData(instance, context));
         }
     }
 }
        private void UpdateResourceObject(ResourceObject resourceObj)
        {
            if (resourceObj == null || resourceObj.Relationships == null)
            {
                return;
            }

            ContextEntity contextEntity = _resourceGraph.GetContextEntity(resourceObj.Type);

            foreach (RelationshipAttribute relationship in contextEntity.Relationships)
            {
                RelationshipData oldData = resourceObj.Relationships[relationship.PublicRelationshipName];
                var newData = new XFRelationshipData
                {
                    IsHasOne   = relationship.IsHasOne,
                    Links      = oldData.Links,
                    SingleData = oldData.SingleData,
                    ManyData   = oldData.ManyData
                };
                resourceObj.Relationships[relationship.PublicRelationshipName] = newData;
            }
        }
示例#25
0
        /// <summary>
        ///     Registers a 'member' entry for the relationship.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="rel">The relative.</param>
        private void RegisterRelationshipMember(JsonQueryResult result, RelationshipData rel)
        {
            Dictionary <long, JsonMember> members = result.Members;
            long relId = rel.RelationshipTypeId.Id;

            // Determine if there is an existing member registered for this relationship.
            // And create one if necessary.
            JsonMember member;

            if (!members.TryGetValue(relId, out member))
            {
                member = new JsonMember( );
                members.Add(relId, member);
            }

            // Then we ensure there is information for the member in the particular direction that we're interested in.
            JsonRelationshipMember relMember = rel.IsReverseActual ? member.Reverse : member.Forward;

            if (relMember == null)
            {
                relMember = new JsonRelationshipMember
                {
                    Alias = GetAliasString(rel.RelationshipTypeId), IsLookup = rel.IsLookup
                };
                if (rel.IsReverseActual)
                {
                    member.Reverse = relMember;
                }
                else
                {
                    member.Forward = relMember;
                }
            }
            else if (relMember.Alias == null && rel.RelationshipTypeId.Alias != null)
            {
                relMember.Alias = GetAliasString(rel.RelationshipTypeId);
            }
        }
示例#26
0
    public static void Import(byte[] buffer)
    {
        Clear();
        MemoryStream ms      = new MemoryStream(buffer);
        BinaryReader r       = new BinaryReader(ms);
        int          version = r.ReadInt32();

        if (CUR_VERSION != version)
        {
            Debug.LogWarning("The version of ColonyrecordMgr is newer than the record.");
        }

        int cnt0 = r.ReadInt32();

        if (version >= VERSION0)
        {
            for (int i = 0; i < cnt0; i++)
            {
                RelationshipData data1 = new RelationshipData();
                data1.Import(r);
                mRelationship.Add(data1);
            }
        }
    }
示例#27
0
        //-------------------------------------------------------------------------------
        //
        private void SetRelationshipData(RelationshipData relation)
        {
            // TODO:friendships_showのblockingが正しい値を返したら有効に
            //lblBlocking.Visible = relation.Blocking;
            //tsmiOperation_Block.Visible = !relation.Blocking;
            //tsmiOperation_UnBlock.Visible = relation.Blocking;

            lblFollowing.Text = GetFollowingOrNotText(relation.Following);
            lblFollowed.Text = GetFollowingOrNotText(relation.Followed);
        }
示例#28
0
 public override void Reset()
 {
     Current      = null;
     NextConflict = NO_ID;
 }
示例#29
0
 public virtual void WithRelationship(long id, long startNode, int type, long endNode, IDictionary <string, Value> properties)
 {
     _relationshipData[id] = new RelationshipData(id, startNode, type, endNode, PropertyIdOf(properties));
 }
示例#30
0
        /******************************************************** POSTERS *********************************************************/

        /// <summary>
        ///     <post>pushes the new relationship data to the api</post>
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="Type"></param>
        /// <returns></returns>
        public UserRelationship PostUserRelationship(String UserId, RelationshipTypes Type)
        {
            UserRelationship Relationship = null;

            try
            {
                // SET UP REQUEST URI
                UriBuilder BaseUri = new UriBuilder();

                BaseUri.Scheme = Config.GetUriScheme();
                BaseUri.Host   = Config.GetApiUriString();
                BaseUri.Path   = "users/" + UserId + "/relationship";

                // SET UP QUERY String
                NameValueCollection PostStrings = System.Web.HttpUtility.ParseQueryString(String.Empty);
                PostStrings.Add("access_token", AuthorisedUser.AccessToken);
                PostStrings.Add("action", Type.ToString());

                // CREATE NEW USER FOLLOWS OBJECT
                Relationship = new UserRelationship();

                // SEND REQUEST
                WebClient Client       = new WebClient();
                byte[]    ResponseData = Client.UploadValues(BaseUri.Uri, PostStrings);
                String    Response     = Encoding.UTF8.GetString(ResponseData);

                // PARSE JSON
                dynamic ParsedJson = JsonConvert.DeserializeObject(Response);

                // CREATE META OBJECT
                MetaData Meta = new MetaData();
                Meta.Code         = ParsedJson.meta.code;
                Relationship.Meta = Meta;

                // CREATE DATA OBJECT
                RelationshipData Data = new RelationshipData();
                Data.OutgoingStatus      = ParsedJson.data.outgoing_status;
                Data.IncomingStatus      = String.Empty;
                Data.TargetUserIsPrivate = ParsedJson.data.target_user_is_private;
                Relationship.Data        = Data;
            }
            catch (WebException WEx)
            {
                // FETCHES ANY ERROR THROWN BY INSTAGRAM API
                Stream ResponseStream = WEx.Response.GetResponseStream();
                if (ResponseStream != null)
                {
                    StreamReader ResponseReader = new StreamReader(ResponseStream);
                    if (ResponseReader != null)
                    {
                        // PARSE JSON
                        dynamic ParsedJson = JsonConvert.DeserializeObject(ResponseReader.ReadToEnd());

                        // CREATE NEW META OBJECT AND FILL IN DATA
                        MetaData Meta = new MetaData();
                        Meta.Code         = ParsedJson.meta.code;
                        Meta.ErrorType    = ParsedJson.meta.error_type;
                        Meta.ErrorMessage = ParsedJson.meta.error_message;
                        Relationship.Meta = Meta;
                    }
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.StackTrace);
            }

            return(Relationship);
        }
示例#31
0
        //-------------------------------------------------------------------------------
        //
        private void GetData()
        {
            try {
                if (!_gotProfile) {
                    this.Invoke((Action)(() => tsslabel.Text = "プロフィール取得中..."));
                    _profile = FrmMain.Twitter.users_show(screen_name: ScreenName);
                    this.Invoke((Action)(() => SetProfile(_profile)));
                    _gotProfile = true;
                }

                if (!FrmMain.Twitter.ScreenName.Equals(ScreenName)) {
                    this.Invoke((Action)(() => tsslabel.Text = "関係データ取得中..."));
                    _relation = FrmMain.Twitter.friendships_show(FrmMain.Twitter.ID, target_screen_name: ScreenName);
                    this.Invoke((Action)(() => SetRelationshipData(_relation)));
                }
                this.Invoke((Action)(() =>
                    {
                        btnRetry.Enabled = false;
                        btnImageChange.Enabled = btnRenew.Enabled = true;
                        tsslabel.Text = "取得完了しました。";
                    }));
            }
            catch (TwitterAPIException ex) {
                this.Invoke((Action)(() =>
                {
                    tsslabel.Text = Twitter.MakeTwitterAPIExceptionStr(ex);
                    btnRetry.Enabled = true;
                }));
            }
        }
示例#32
0
        /// <summary>
        ///     Stores an array of relationship data into an entity.
        /// </summary>
        /// <param name="entityJson">Dictionary that represents the entity.</param>
        /// <param name="rel">The relationship being stored.</param>
        /// <param name="relResult">The data being stored for that relationship.</param>
        private static void StoreRelationshipData(Dictionary <string, object> entityJson, RelationshipData rel,
                                                  List <object> relResult)
        {
            long relId = rel.RelationshipTypeId.Id;

            // Look up whether there is already data stored for this relationship.
            // (As it may already be stored for the opposite direction).
            object data;
            JsonRelationshipData relPair;
            string relKey = relId.ToString(CultureInfo.InvariantCulture);

            if (entityJson.TryGetValue(relKey, out data))
            {
                relPair = ( JsonRelationshipData )data;
            }
            else
            {
                // Create if necessary
                relPair            = new JsonRelationshipData( );
                entityJson[relKey] = relPair;
            }

            // Store the data on the appropriate direction.
            if (rel.IsReverseActual)
            {
                relPair.Reverse = relResult;
            }
            else
            {
                relPair.Forward = relResult;
            }
        }