Exemple #1
0
        private Frame <string, string> CreateBestMatchFrame(SymbologySearchResponse response)
        {
            List <KeyValuePair <string, Series <string, string> > > list = new List <KeyValuePair <string, Series <string, string> > >();

            foreach (var symbol in response.mappedSymbols)
            {
                string ric = symbol.symbol;
                SeriesBuilder <string, string> sb;

                if (symbol.bestMatch != null)
                {
                    sb = new SeriesBuilder <string, string>();
                    FieldInfo[] fields = typeof(BestMatch).GetFields();
                    foreach (var field in fields)
                    {
                        var tmp = field.GetValue(symbol.bestMatch)?.ToString();

                        if (!string.IsNullOrEmpty(tmp))
                        {
                            sb.Add(field.Name, field.GetValue(symbol.bestMatch).ToString());
                        }
                    }
                    // sb.Series.Print();
                    list.Add(KeyValue.Create(ric, sb.Series));
                }
            }

            return(Frame.FromRows(list));
        }
Exemple #2
0
        private Frame <string, string> CreateFrame(SymbologySearchResponse response)
        {
            List <KeyValuePair <string, Series <string, string> > > list = new List <KeyValuePair <string, Series <string, string> > >();
            SeriesBuilder <string, string> sb;

            foreach (var symbol in response.mappedSymbols)
            {
                string ric = symbol.symbol;

                sb = new SeriesBuilder <string, string>();
                FieldInfo[] fields = typeof(MappedSymbol).GetFields();
                string      temp   = "";
                foreach (var field in fields)
                {
                    temp = "";
                    if (field.FieldType == typeof(List <string>))
                    {
                        List <string> tmpList = (List <string>)field.GetValue(symbol);
                        if (tmpList != null)
                        {
                            temp = string.Join(",", tmpList);
                        }
                    }
                    else if (field.FieldType == typeof(BestMatch))
                    {
                        if (symbol.bestMatch != null)
                        {
                            // sb = new SeriesBuilder<string, string>();
                            FieldInfo[] bestMatchFields = typeof(BestMatch).GetFields();
                            foreach (var bestMatchField in bestMatchFields)
                            {
                                var tmp = bestMatchField.GetValue(symbol.bestMatch)?.ToString();

                                if (!string.IsNullOrEmpty(tmp))
                                {
                                    sb.Add("BestMatch." + bestMatchField.Name, tmp);
                                }
                            }
                            continue;
                        }
                    }
                    else
                    {
                        temp = field.GetValue(symbol)?.ToString();
                    }

                    if (!string.IsNullOrEmpty(temp) && field.Name != "symbol")
                    {
                        sb.Add(field.Name, temp);
                    }
                }

                list.Add(KeyValue.Create(ric, sb.Series));
            }
            return(Frame.FromRows(list));
        }