IndexOfString() 공개 메소드

public IndexOfString ( string s ) : int
s string
리턴 int
예제 #1
0
        private bool TryGetBracketedLongValue(ImapList list, string name, out long retVal)
        {
            bool isOk = false;
            retVal = default(long);

            var pos = list.IndexOfString(name);
            if (pos >= 0)
            {
                isOk = long.TryParse(list.GetStringAt(pos + 1).TrimEnd(']'), out retVal);
            }

            return isOk;
        }
예제 #2
0
        internal ImapMessage(long number, ImapList list, IEnumerable<string> extensionParameterNames)
        {
            Number = number;

            int uidIndex = list.IndexOfString("UID");
            int bodyIndex = list.IndexOfString("BODYSTRUCTURE");
            int envelopeIndex = list.IndexOfString("ENVELOPE");

            if (uidIndex != -1)
            {
                Uid = long.Parse(list.GetStringAt(uidIndex + 1));
            }

            if (envelopeIndex != -1)
            {
                ImapList envelopeList = list.GetListAt(envelopeIndex + 1);

                string timestampString = envelopeList.GetStringAt(0);
                DateTime timestamp;

                if (TryParseTimestamp(timestampString, out timestamp))
                {
                    Timestamp = timestamp;
                }

                Subject = RFC2047Decoder.Parse(envelopeList.GetStringAt(1));
                Sender = ParseAddresses(envelopeList.GetListAt(2)).FirstOrDefault();
                From = ParseAddresses(envelopeList.GetListAt(3)).FirstOrDefault();
                ReplyTo = ParseAddresses(envelopeList.GetListAt(4)).FirstOrDefault();
                To = ParseAddresses(envelopeList.GetListAt(5)).ToArray();
                Cc = ParseAddresses(envelopeList.GetListAt(6)).ToArray();
                Bcc = ParseAddresses(envelopeList.GetListAt(7)).ToArray();
                ID = envelopeList.GetStringAt(8);
            }

            if (bodyIndex != -1)
            {
                ImapList bodyList = list.GetListAt(bodyIndex + 1);

                if (bodyList.Count != 0)
                {
                    BodyParts = ParseBodyParts(string.Empty, bodyList).ToArray();
                }
            }

            if (null != extensionParameterNames)
            {
                var extensionParams = new Dictionary<string, object>();

                foreach (var paramName in extensionParameterNames)
                {
                    int index = list.IndexOfString(paramName);
                    if (index != -1)
                    {
                        int valueIndex = index + 1;
                        object value = null;

                        if (list.IsStringAt(valueIndex))
                        {
                            value = list.GetStringAt(valueIndex);
                        }
                        else if (list.IsListAt(valueIndex))
                        {
                            value = list.GetListAt(valueIndex).ToBasicTypesList();
                        }

                        if (null != value)
                        {
                            extensionParams[paramName] = value;
                        }
                    }
                }

                if (extensionParams.Count > 0)
                {
                    ExtensionParameters = extensionParams;
                }
            }
        }