Smrf.SocialNetworkLib.Twitter.TwitterStatusTextParser.GetScreenNames C# (CSharp) Method

GetScreenNames() public method

public GetScreenNames ( String statusText, String &repliedToScreenName, String &uniqueMentionedScreenNames ) : void
statusText String
repliedToScreenName String
uniqueMentionedScreenNames String
return void
    GetScreenNames
    (
        String statusText,
        out String repliedToScreenName,
        out String [] uniqueMentionedScreenNames
    )
    {
        Debug.Assert(statusText != null);
        AssertValid();

        statusText = ReplacePunctuationWithSpaces(statusText);

        repliedToScreenName = null;
        Match oRepliedToMatch = m_oRepliedToRegex.Match(statusText);

        if (oRepliedToMatch.Success)
        {
            repliedToScreenName =
                oRepliedToMatch.Groups["ScreenName"].Value.ToLower();
        }

        HashSet<String> oUniqueMentionedScreenNames = new HashSet<String>();
        Match oMentionedMatch = m_oMentionedRegex.Match(statusText);

        while (oMentionedMatch.Success)
        {
            String sMentionedScreenName =
                oMentionedMatch.Groups["ScreenName"].Value.ToLower();

            // A "reply-to is not also a "mentions."

            if (sMentionedScreenName != repliedToScreenName)
            {
                oUniqueMentionedScreenNames.Add(sMentionedScreenName);
            }

            oMentionedMatch = oMentionedMatch.NextMatch();
        }

        uniqueMentionedScreenNames = oUniqueMentionedScreenNames.ToArray();
    }

Usage Example

    AppendRepliesToAndMentionsEdgeXmlNodes
    (
        GraphMLXmlDocument graphMLXmlDocument,
        TwitterStatusTextParser twitterStatusTextParser,
        HashSet<String> uniqueScreenNames,
        Boolean includeRepliesToEdges,
        Boolean includeMentionsEdges,
        Boolean includeNonRepliesToNonMentionsEdges,
        String screenName,
        TwitterStatus twitterStatus,
        Boolean includeStatus
    )
    {
        Debug.Assert(graphMLXmlDocument != null);
        Debug.Assert(twitterStatusTextParser != null);
        Debug.Assert(uniqueScreenNames != null);
        Debug.Assert( !String.IsNullOrEmpty(screenName) );
        Debug.Assert(twitterStatus != null);

        String statusText = twitterStatus.Text;
        Boolean isReplyTo = false;
        Boolean isMentions = false;

        Debug.Assert( !String.IsNullOrEmpty(statusText) );

        String repliedToScreenName;
        String [] uniqueMentionedScreenNames;

        twitterStatusTextParser.GetScreenNames(statusText,
            out repliedToScreenName, out uniqueMentionedScreenNames);

        if (repliedToScreenName != null)
        {
            if (
                repliedToScreenName != screenName
                &&
                uniqueScreenNames.Contains(repliedToScreenName)
                )
            {
                isReplyTo = true;

                if (includeRepliesToEdges)
                {
                    AppendRepliesToAndMentionsEdgeXmlNode(
                        graphMLXmlDocument, screenName, repliedToScreenName,
                        RepliesToRelationship, twitterStatus, includeStatus);
                }
            }
        }

        foreach (String mentionedScreenName in uniqueMentionedScreenNames)
        {
            if (
                mentionedScreenName != screenName
                &&
                uniqueScreenNames.Contains(mentionedScreenName)
                )
            {
                isMentions = true;

                if (includeMentionsEdges)
                {
                    AppendRepliesToAndMentionsEdgeXmlNode(
                        graphMLXmlDocument, screenName, mentionedScreenName,
                        MentionsRelationship, twitterStatus, includeStatus);
                }
            }
        }

        if (includeNonRepliesToNonMentionsEdges && !isReplyTo && !isMentions)
        {
            // Append a self-loop edge to represent the tweet.

            AppendRepliesToAndMentionsEdgeXmlNode(
                graphMLXmlDocument, screenName, screenName,
                NonRepliesToNonMentionsRelationship, twitterStatus,
                includeStatus);
        }
    }
All Usage Examples Of Smrf.SocialNetworkLib.Twitter.TwitterStatusTextParser::GetScreenNames