Exemplo n.º 1
0
        public static NetTestDescriptor ParseNetTestDescriptor(string description)
        {
            try
            {
                if (description == null || description.Trim().Length == 0)
                {
                    logger.LogError("Cannot parse NetTestDescriptor from an empty string.");
                    return(null);
                }
                else
                {
                    int    numberChannels = Convert.ToInt32(Regex.Match(description, @"channels=(?<channels>\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Result("${channels}"));
                    int    frameSize      = Convert.ToInt32(Regex.Match(description, @"frame=(?<frame>\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Result("${frame}"));
                    int    payloadSize    = Convert.ToInt32(Regex.Match(description, @"payload=(?<payload>\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Result("${payload}"));
                    string socketStr      = Regex.Match(description, @"socket=(?<socket>.+?)(\s|$)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Result("${socket}");

                    NetTestDescriptor descriptor = new NetTestDescriptor(numberChannels, frameSize, payloadSize, IPSocket.ParseSocketString(socketStr));
                    return(descriptor);
                }
            }
            catch (Exception excp)
            {
                logger.LogError("Exception ParseNetTestDescriptor. " + excp.Message);
                throw excp;
            }
        }
        public static NetTestDescriptor ParseNetTestDescriptor(string description)
        {
            try
            {
                if (description == null || description.Trim().Length == 0)
                {
                    logger.Error("Cannot parse NetTestDescriptor from an empty string.");
                    return null;
                }
                else
                {
                    int numberChannels = Convert.ToInt32(Regex.Match(description, @"channels=(?<channels>\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Result("${channels}"));
                    int frameSize = Convert.ToInt32(Regex.Match(description, @"frame=(?<frame>\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Result("${frame}"));
                    int payloadSize = Convert.ToInt32(Regex.Match(description, @"payload=(?<payload>\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Result("${payload}"));
                    string socketStr = Regex.Match(description, @"socket=(?<socket>.+?)(\s|$)", RegexOptions.IgnoreCase | RegexOptions.Singleline).Result("${socket}");

                    NetTestDescriptor descriptor = new NetTestDescriptor(numberChannels, frameSize, payloadSize, IPSocket.ParseSocketString(socketStr));
                    return descriptor;
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception ParseNetTestDescriptor. " + excp.Message);
                throw excp;
            }
        }