コード例 #1
0
        static void Main(string[] args)
        {
            Pair <int> pair = new Pair <int>();

            pair.Add(23); pair.Add(37); pair.Add(92);
            pair.Add(123);

            for (byte index = 0; index < pair.Length; index++)
            {
                Console.WriteLine(pair.GetT(index));
            }

            //Generic List
            List <int> list = new List <int> {
                1, 2, 3, 4, 5
            };                                               //using System.Collection.Generic
        }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: tofilagman/z.Controller
        public static Pair ToPair(this IEnumerable <KeyValuePair <string, object> > keyObjects)
        {
            var p = new Pair();

            foreach (var g in keyObjects)
            {
                p.Add(g.Key, g.Value);
            }
            return(p);
        }
コード例 #3
0
        private Pair FormattedParamSet()
        {
            var pr = new Pair();

            foreach (var prs in this.ParamSet)
            {
                pr.Add(prs.Name, prs.Value);
            }
            return(pr);
        }
コード例 #4
0
        private void PlotSet(string display = null)
        {
            if (tbMain == null)
            {
                return;
            }

            switch (display ?? cbDisplay.Text)
            {
            case "Grid":
                var TabDatas = new ObservableCollection <TabData>();

                for (var i = 0; i < CurSet.Tables.Count; i++)
                {
                    TabDatas.Add(new TabData
                    {
                        Header = $"ResultSet{i} ({CurSet.Tables[i].Rows.Count})",
                        Data   = CurSet.Tables[i]
                    });
                }

                tbMain.ItemsSource   = TabDatas;
                tbMain.SelectedIndex = 0;
                hstMain.Visibility   = Visibility.Collapsed;
                tbMain.Visibility    = Visibility.Visible;
                break;

            case "Json":
                if (CurSet.Tables.Count > 1)
                {
                    Pair p = new Pair();
                    for (int i = 0; i < CurSet.Tables.Count; i++)
                    {
                        p.Add(string.Format("ResultSet{0}", i), new PairCollection(CurSet.Tables[i]));
                    }
                    trMain.Text = new {
                        ResultSets = p,
                        Parameters = this.FormattedParamSet()
                    }.ToJson(true);
                }
                else if (CurSet.Tables.Count == 1)
                {
                    trMain.Text = new {
                        ResultSet  = new PairCollection(CurSet.Tables[0]),
                        Parameters = this.FormattedParamSet()
                    }.ToJson(true);
                }
                hstMain.Visibility = Visibility.Visible;
                tbMain.Visibility  = Visibility.Collapsed;
                break;
            }
        }
コード例 #5
0
        public void SetValue(string Key, object Value)
        {
            var j = pair.Where(x => x.Key == Key);

            if (!j.Any())
            {
                pair.Add(Key, (Value.GetType().IsEnum) ? Convert.ToInt32(Value) : Value);
            }
            else
            {
                pair[Key] = (Value.GetType().IsEnum) ? Convert.ToInt32(Value) : Value;
            }
        }
コード例 #6
0
        /// <summary>
        /// Request Parameter Wrapper
        /// </summary>
        /// <param name="cntx"></param>
        /// <returns></returns>
        protected virtual Pair QueryString(HttpControllerContext cntx)
        {
            var h = new Pair(StringComparer.OrdinalIgnoreCase);

            try
            {
                if (cntx.Request.Content.IsMimeMultipartContent() || cntx.Request.Content.Headers.ContentLength > 1e+8)
                {
                    return(h);
                }

                string g = default(string);

                if (cntx.Request.Method == HttpMethod.Post)
                {
                    using (var ms = new MemoryStream())
                    {
                        cntx.Request.Content.CopyToAsync(ms).Wait();

                        ms.Seek(0, SeekOrigin.Begin);

                        using (var sr = new StreamReader(ms))
                        {
                            g = sr.ReadToEnd();
                        }
                    }
                }
                else if (cntx.Request.Method == HttpMethod.Get)
                {
                    g = cntx.Request.RequestUri.Query;
                }

                if (g == "")
                {
                    return(h);
                }
                string[] exc = { "_", "callback" };

                if (cntx.Request.Method == HttpMethod.Get)
                {
                    foreach (var j in g.Split('&').Select(i => i.Split('=')))
                    {
                        j[0] = j[0].TrimStart('?');
                        if (exc.Contains(j[0]) || j.Length == 1)
                        {
                            continue;
                        }
                        h.Add(j[0], HttpUtility.UrlDecode(j[1], Encoding.UTF8));
                    }
                }
                else
                {
                    g = g.CompressFromUriEncoded();
                    g.ToObject <Pair>().CopyTo(h);
                }

                return(h);
            }
            catch (OutOfMemoryException ex)
            {
                AppInsights.LogEx(ex);
                throw ex;
            }
            catch (Exception ex)
            {
                AppInsights.LogEx(ex);
                throw ex;
            }
        }
コード例 #7
0
 /// <summary>
 /// Adds the specified <see cref="iFactr.UI.IMenuButton"/> to the menu.
 /// </summary>
 /// <param name="menuButton">The button to add.</param>
 public void Add(IMenuButton menuButton)
 {
     Pair.Add(menuButton);
 }