コード例 #1
0
ファイル: ResultParser.cs プロジェクト: eimslab/Shove.Net.Fx2
 public static ParsedResult parseResult(Result theResult)
 {
     // Simplification of original if - if else logic using Null Coalescing operator ??
     //
     // ?? Simply checks from left to right for a non null object
     // when an object evaluates to null the next object after the ?? is evaluated
     // This continues until a non null value is found or the last object is evaluated
     return
         (BookmarkDoCoMoResultParser.parse(theResult) as ParsedResult ??
          AddressBookDoCoMoResultParser.parse(theResult) as ParsedResult ??
          EmailDoCoMoResultParser.parse(theResult) as ParsedResult ??
          AddressBookAUResultParser.parse(theResult) as ParsedResult ??
          VCardResultParser.parse(theResult) as ParsedResult ??
          BizcardResultParser.parse(theResult) as ParsedResult ??
          VEventResultParser.parse(theResult) as ParsedResult ??
          EmailAddressResultParser.parse(theResult) as ParsedResult ??
          TelResultParser.parse(theResult) as ParsedResult ??
          SMSMMSResultParser.parse(theResult) as ParsedResult ??
          GeoResultParser.parse(theResult) as ParsedResult ??
          URLTOResultParser.parse(theResult) as ParsedResult ??
          URIResultParser.parse(theResult) as ParsedResult ??
          ISBNResultParser.parse(theResult) as ParsedResult ??
          ProductResultParser.parse(theResult) as ParsedResult ??
          new TextParsedResult(theResult.Text, null) as ParsedResult);
 }
コード例 #2
0
 public static EmailAddressParsedResult parse(Result result)
 {
     System.String rawText = result.Text;
     if (rawText == null)
     {
         return(null);
     }
     System.String emailAddress;
     if (rawText.StartsWith("mailto:") || rawText.StartsWith("MAILTO:"))
     {
         // If it starts with mailto:, assume it is definitely trying to be an email address
         emailAddress = rawText.Substring(7);
         int queryStart = emailAddress.IndexOf('?');
         if (queryStart >= 0)
         {
             emailAddress = emailAddress.Substring(0, (queryStart) - (0));
         }
         // System.Collections.Hashtable nameValues = parseNameValuePairs(rawText); // commented by .net follower (http://dotnetfollower.com)
         System.Collections.Generic.Dictionary <Object, Object> nameValues = parseNameValuePairs(rawText); // added by .net follower (http://dotnetfollower.com)
         System.String subject = null;
         System.String body    = null;
         if (nameValues != null)
         {
             if (emailAddress.Length == 0)
             {
                 emailAddress = ((System.String)nameValues["to"]);
             }
             subject = ((System.String)nameValues["subject"]);
             body    = ((System.String)nameValues["body"]);
         }
         return(new EmailAddressParsedResult(emailAddress, subject, body, rawText));
     }
     else
     {
         if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(rawText))
         {
             return(null);
         }
         emailAddress = rawText;
         return(new EmailAddressParsedResult(emailAddress, null, null, "mailto:" + emailAddress));
     }
 }
コード例 #3
0
        public static EmailAddressParsedResult parse(Result result)
        {
            string text = result.Text;

            if (text == null)
            {
                return(null);
            }
            string text2;

            if (text.StartsWith("mailto:") || text.StartsWith("MAILTO:"))
            {
                text2 = text.Substring(7);
                int num = text2.IndexOf('?');
                if (num >= 0)
                {
                    text2 = text2.Substring(0, num);
                }
                Hashtable hashtable = ResultParser.parseNameValuePairs(text);
                string    subject   = null;
                string    body      = null;
                if (hashtable != null)
                {
                    if (text2.Length == 0)
                    {
                        text2 = (string)hashtable["to"];
                    }
                    subject = (string)hashtable["subject"];
                    body    = (string)hashtable["body"];
                }
                return(new EmailAddressParsedResult(text2, subject, body, text));
            }
            if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(text))
            {
                return(null);
            }
            text2 = text;
            return(new EmailAddressParsedResult(text2, null, null, "mailto:" + text2));
        }
コード例 #4
0
        public override ParsedResult parse(Result result)
        {
            string rawText = getMassagedText(result);
            string emailAddress;

            if (rawText.StartsWith("mailto:") || rawText.StartsWith("MAILTO:"))
            {
                // If it starts with mailto:, assume it is definitely trying to be an email address
                emailAddress = rawText.Substring(7);
                int queryStart = emailAddress.IndexOf('?');
                if (queryStart >= 0)
                {
                    emailAddress = emailAddress.Substring(0, queryStart);
                }
                IDictionary <string, string> nameValues = parseNameValuePairs(rawText);
                string subject = null;
                string body    = null;
                if (nameValues != null)
                {
                    if (emailAddress.Length == 0)
                    {
                        emailAddress = nameValues["to"];
                    }
                    subject = nameValues["subject"];
                    body    = nameValues["body"];
                }
                return(new EmailAddressParsedResult(emailAddress, subject, body, rawText));
            }
            else
            {
                if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(rawText))
                {
                    return(null);
                }
                emailAddress = rawText;
                return(new EmailAddressParsedResult(emailAddress, null, null, "mailto:" + emailAddress));
            }
        }
コード例 #5
0
        public static EmailAddressParsedResult parse(Result result)
        {
            string text = result.Text;

            if (text == null || !text.StartsWith("MATMSG:"))
            {
                return(null);
            }
            string[] array = AbstractDoCoMoResultParser.matchDoCoMoPrefixedField("TO:", text, true);
            if (array == null)
            {
                return(null);
            }
            string text2 = array[0];

            if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(text2))
            {
                return(null);
            }
            string subject = AbstractDoCoMoResultParser.matchSingleDoCoMoPrefixedField("SUB:", text, false);
            string body    = AbstractDoCoMoResultParser.matchSingleDoCoMoPrefixedField("BODY:", text, false);

            return(new EmailAddressParsedResult(text2, subject, body, "mailto:" + text2));
        }
コード例 #6
0
        public static ParsedResult parseResult(Result theResult)
        {
            ParsedResult result;

            if ((result = BookmarkDoCoMoResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = AddressBookDoCoMoResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = EmailDoCoMoResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = EmailAddressResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = AddressBookAUResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = VCardResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = BizcardResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = VEventResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = TelResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = SMSMMSResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = GeoResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = URLTOResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = URIResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = ISBNResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            if ((result = ProductResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            return(new TextParsedResult(theResult.Text, null));
        }
コード例 #7
0
        public static ParsedResult parseResult(Result theResult)
        {
            // This is a bit messy, but given limited options in MIDP / CLDC, this may well be the simplest
            // way to go about this. For example, we have no reflection available, really.
            // Order is important here.
            ParsedResult result;

            if ((result = BookmarkDoCoMoResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = AddressBookDoCoMoResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = EmailDoCoMoResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = AddressBookAUResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = VCardResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = BizcardResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = VEventResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = EmailAddressResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = TelResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = SMSMMSResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = GeoResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = URLTOResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = URIResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            else if ((result = ISBNResultParser.parse(theResult)) != null)
            {
                // We depend on ISBN parsing coming before UPC, as it is a subset.
                return(result);
            }
            else if ((result = ProductResultParser.parse(theResult)) != null)
            {
                return(result);
            }
            return(new TextParsedResult(theResult.Text, null));
        }
コード例 #8
0
        internal static bool isBasicallyValidEmailAddress(string email)
        {
            if (email == null)
            {
                return(false);
            }
            bool flag = false;

            for (int i = 0; i < email.Length; i++)
            {
                char c = email[i];
                if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') && !EmailDoCoMoResultParser.isAtextSymbol(c))
                {
                    return(false);
                }
                if (c == '@')
                {
                    if (flag)
                    {
                        return(false);
                    }
                    flag = true;
                }
            }
            return(flag);
        }