示例#1
0
        public static ProtocolInfo Parse(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            var tokens = text.Split(':');

            if (tokens.Length != 4)
            {
                throw new ArgumentException("text",
                                            @"The string must be of the form ""protocol:network:contentFormat:additionalInfo"".");
            }

            var result = new ProtocolInfo(tokens [0]);

            if (!string.IsNullOrEmpty(tokens [1]) && tokens [1] != "*")
            {
                result.Network = tokens [1];
            }
            if (!string.IsNullOrEmpty(tokens [2]) && tokens [2] != "*")
            {
                result.ContentFormat = tokens [2];
            }
            if (!string.IsNullOrEmpty(tokens [3]) && tokens [3] != "*")
            {
                result.AdditionalInfo = tokens [3];
            }

            return(result);
        }
示例#2
0
        public static ProtocolInfo Parse (string text)
        {
            if (text == null) {
                throw new ArgumentNullException ("text");
            }

            var tokens = text.Split (':');
            if (tokens.Length != 4) {
                throw new ArgumentException ("text",
                    @"The string must be of the form ""protocol:network:contentFormat:additionalInfo"".");
            }

            var result = new ProtocolInfo (tokens [0]);

            if (!string.IsNullOrEmpty (tokens [1]) && tokens [1] != "*") {
                result.Network = tokens [1];
            }
            if (!string.IsNullOrEmpty (tokens [2]) && tokens [2] != "*") {
                result.ContentFormat = tokens [2];
            }
            if (!string.IsNullOrEmpty (tokens [3]) && tokens [3] != "*") {
                result.AdditionalInfo = tokens [3];
            }

            return result;
        }