Exemplo n.º 1
0
        public static ZScanResponse ToZScanResponse(this ScanResponse source)
        {
            if (source == null)
            {
                return(null);
            }

            List <ZItem> data = null;

            if (source.Data != null && source.Data.Count > 0)
            {
                data = new List <ZItem>();

                for (int i = 0; i < source.Data.Count; i++)
                {
                    var zi = new ZItem();

                    zi.Value = source.Data[i];

                    if (!string.IsNullOrEmpty(zi.Value) && zi.Value.IndexOf("\r\n$") > -1)
                    {
                        var arr = zi.Value.Split("\r\n");
                        zi.Value = arr[0];
                        zi.Score = double.Parse(arr[2]);
                    }
                    else
                    {
                        var score = 0D;

                        if (i + 1 < source.Data.Count)
                        {
                            double.TryParse(source.Data[i + 1], out score);
                            i++;
                        }
                        zi.Score = score;
                    }

                    data.Add(zi);
                }
            }

            var result = new ZScanResponse()
            {
                Offset = source.Offset,
                Data   = data
            };

            return(result);
        }
Exemplo n.º 2
0
        public static ZScanResponse ToZScanResponse(this ScanResponse source)
        {
            if (source == null)
            {
                return(null);
            }

            List <ZItem> data = null;

            if (source.Data != null && source.Data.Count > 0)
            {
                data = new List <ZItem>();

                for (int i = 0; i < source.Data.Count; i++)
                {
                    var zi = new ZItem();

                    zi.Value = source.Data[i];

                    var score = 0D;

                    if (i + 1 < source.Data.Count)
                    {
                        double.TryParse(source.Data[i + 1], out score);
                        i++;
                    }
                    zi.Score = score;

                    data.Add(zi);
                }
            }

            var result = new ZScanResponse()
            {
                Offset = source.Offset,
                Data   = data
            };

            return(result);
        }