// GET api/default1/5 public PurviewGroup Get(int id) { PurviewGroup v = new PurviewGroup { GroupName = "gm", PurviewKeyValues = new List<KeyValuePair<string, string>> { new KeyValuePair <string, string>( "1,", "2"), new KeyValuePair <string, string>( "1,", "2") } }; return v; }
private static string _filepath;//= System.Configuration.ConfigurationManager.AppSettings[""];// HttpContext.Current.Server.MapPath("~/App_Data/grouplist.txt"); public static List<PurviewGroup> GetPurviews() { var listpg = new List<PurviewGroup>(); //Server.MapPath("~/App_Data/grouplist.txt") var fileline = File.ReadAllLines(_filepath); var index = 0; PurviewGroup pg = null; foreach (var iline in fileline) { var line = iline.Trim(); if (string.IsNullOrWhiteSpace(line)) { continue; } if (Dev.Comm.RegexHelper.Preg_match(@"^>>", line)) { pg = new PurviewGroup { GroupName = line.Replace(">>", ""), PurviewKeyValues = new List<KeyValuePair<string, string>>() }; listpg.Add(pg); } else if (Dev.Comm.RegexHelper.Preg_match(@"^>", line)) { var kvs = line.Split(new char[] { '>' }); Debug.Assert(pg != null, "pg != null"); pg.PurviewKeyValues.Add(new KeyValuePair<string, string>(kvs[1], kvs[2])); } } return listpg; }