public static QueryStringValuesCollection FromNameValueCollection(NameValueCollection d) { var col = new QueryStringValuesCollection(); foreach (string key in d.Keys) { var values = d.GetValues(key); if (values == null) { continue; } var valuesCollection = new ValuesCollection(); if (key == null) { var value = values[0]; string _key = value; valuesCollection.AddValue(new Value(null)); col._valuesCollections[_key] = valuesCollection; } else { foreach (var value in values) { valuesCollection.AddValue(new Value(value)); } col._valuesCollections[key] = valuesCollection; } } return(col); }
public void Test_Common() { ValuesCollection valsCol = new ValuesCollection(); valsCol.Add("red", "rojo"); valsCol.Add("green", "verde"); valsCol.Add("blue", "azul", true); valsCol.Add("red", "rouge"); valsCol.Add("red", null); valsCol.Add("red", "rouge", true); Assert.AreEqual(3, valsCol.Count); valsCol.Remove("green"); Assert.AreEqual(2, valsCol.Count); string[] values = valsCol.GetValues("xxxxx"); Assert.AreEqual(null, values); values = valsCol.GetValues("red"); Assert.AreEqual("rojo", values[0]); Assert.AreEqual("rouge", values[1]); valsCol.Clear(); Assert.AreEqual(0, valsCol.Count); }
public void SaveConfig() { if (string.IsNullOrEmpty(_ConfigSection.Login)) { _ConfigSection.Login = "******"; _ConfigSection.Password = ""; } _ConfigSection.Tasks.Clear(); foreach (ITask task in m_Tasks) { string typeName = task.GetType().FullName; ConfigElement el = new ConfigElement(); ValuesCollection vc = new ValuesCollection(); task.SaveValues(vc); el.Config = vc.ToString(); el.Name = task.Name; el.TypeName = typeName; _ConfigSection.Tasks.Add(el); } _ConfigSection.Jobs.Clear(); foreach (IJob job in m_Jobs) { string typeName = job.GetType().FullName; ConfigElement el = new ConfigElement(); ValuesCollection vc = new ValuesCollection(); job.SaveValues(vc); el.Config = vc.ToString(); el.Name = job.Name; el.TypeName = typeName; _ConfigSection.Jobs.Add(el); } _ConfigSection.Triggers.Clear(); foreach (ITrigger trigger in m_Triggers) { string typeName = trigger.GetType().FullName; ValuesCollection vc = new ValuesCollection(); ConfigElement el = new ConfigElement(); trigger.SaveValues(vc); el.Name = trigger.Name; el.TypeName = typeName; el.Config = vc.ToString(); _ConfigSection.Triggers.Add(el); } _Config.Save(ConfigurationSaveMode.Full); }
public Enumerator(ValuesCollection values) { content = values.content; hashCode = values.hashCode; key = values.key; index = -1; }
internal CostItem(IIfcCostItem item, bool init) : base(item, init) { Children = new CostChildrenCollection(this, init); ClassificationItems = new ClassificationCollection(Entity, init); Quantities = new QuantityCollection(this); UnitValues = new ValuesCollection(this); AssociatedElements = new AssociatedElementsCollection(this, init); }
public override Collection <V> Values() { if (valuesCollection == null) { valuesCollection = new ValuesCollection(this); } return(valuesCollection); }
private string toCommaSeparatedString(ValuesCollection collection) { var commaSeparated = ""; foreach (string V in collection) { if (commaSeparated.Length > 0) { commaSeparated += (", " + V); } else { commaSeparated += V; } } return commaSeparated; }
private string toCommaSeparatedString(ValuesCollection collection) { var commaSeparated = ""; foreach (string V in collection) { if (commaSeparated.Length > 0) { commaSeparated += (", " + V); } else { commaSeparated += V; } } return(commaSeparated); }
private void LoadConfig() { m_Jobs.Clear(); m_Tasks.Clear(); m_Triggers.Clear(); InitConfig(); foreach (ConfigElement element in _ConfigSection.Tasks) { Type taskType = Type.GetType(element.TypeName); ConstructorInfo ci = taskType.GetConstructor(Type.EmptyTypes); ITask task = (ITask)ci.Invoke(new object[0]); ValuesCollection vc = ValuesCollection.FromString(element.Config); task.LoadValues(vc); m_Tasks.Add(task); } foreach (ConfigElement element in _ConfigSection.Jobs) { Type jobType = Type.GetType(element.TypeName); ConstructorInfo ci = jobType.GetConstructor(Type.EmptyTypes); IJob job = (IJob)ci.Invoke(new object[0]); ValuesCollection vc = ValuesCollection.FromString(element.Config); job.LoadValues(vc, this); m_Jobs.Add(job); } foreach (ConfigElement element in _ConfigSection.Triggers) { Type triggerType = Type.GetType(element.TypeName); ConstructorInfo ci = triggerType.GetConstructor(Type.EmptyTypes); ITrigger trigger = (ITrigger)ci.Invoke(new object[0]); ValuesCollection vc = ValuesCollection.FromString(element.Config); trigger.LoadValues(vc, this); m_Triggers.Add(trigger); } }
public ValuesCollectionIterator(ValuesCollection parent) : base() { this.setIterator = parent.parent.EntrySet().Iterator(); }
/// <summary> /// Requests a collection of rants sorted and selected by the arguments from the rest-api. /// </summary> /// <param name="sort">Sorting of the rant collection.</param> /// <param name="limit">Maximal rants to return.</param> /// <param name="skip">Number of rants to skip.</param> /// <inheritdoc /> public async Task <IReadOnlyCollection <Rant> > GetRantsAsync(RantSort sort = RantSort.Algo, RantRange range = RantRange.Day, int limit = 50, int skip = 0, ValuesCollection settings = null) { var sortText = sort.ToString().ToLower(); var paramz = new Parameters() { { "sort", sortText }, { "limit", limit.ToString() }, { "skip", skip.ToString() }, }; if (sort == RantSort.Top) { paramz.Add("range", range.ToString().ToLower()); } string url = owner.MakeUrl("/api/devrant/rants", paramz); var response = await client.GetAsync(url); var responseText = await response.Content.ReadAsStringAsync(); List <Rant> rants = new List <Rant>(); JObject tmp = JObject.Parse(responseText); foreach (JObject obj in tmp["rants"].Children()) { var r = ContentObject.Parse <Rant>(obj); rants.Add(r); } if (settings != null) { var num = tmp[ValuesCollection.NumNotifs]; if (tmp[ValuesCollection.NumNotifs] != null) { var notifs = Convert.ToInt32(num.ToString()); settings[ValuesCollection.NumNotifs] = notifs; } if (tmp[ValuesCollection.Set] != null) { settings[ValuesCollection.Set] = tmp[ValuesCollection.Set]; } } return(rants); }
internal Enumerator(ValuesCollection values) { this.values = values.values; this.index = -1; }
private async Task LoadFeed(FeedType type, RantSort sort = RantSort.Algo, RantRange range = RantRange.Day, bool filter = false) { currentFeedType = type; Func <int, int, Task <IReadOnlyCollection <Dtos.Rant> > > getter; ValuesCollection otherVals = new ValuesCollection(); switch (type) { case FeedType.General: getter = async(skip, limit) => await api.Feeds.GetRantsAsync(sort : sort, range : range, skip : skip, limit : limit, settings : otherVals); break; case FeedType.Stories: getter = async(skip, limit) => await api.Feeds.GetStoriesAsync(range : range, sort : sort, skip : skip, limit : limit); break; default: return; } List <Dtos.Rant> rants = new List <Dtos.Rant>(); //Used to remove duplicates List <long> ids = new List <long>(); int maxPages = ds.MaxPages; bool useOffset = true; //ds.UseOffset var lim = ds.ResultsLimit; int minScore = ds.MinScore; int page = 0; if (useOffset) { page = maxPages * offset; maxPages = (offset + 1) * maxPages; } bool shouldIncrement = true; while (rants.Count < lim && page < maxPages) { int skip = page * lim; try { var tmp = await getter.Invoke(skip, lim); if (tmp == null || tmp.Count == 0) { ResetOffset(); shouldIncrement = false; break; } foreach (var r in tmp) { if (ids.Contains(r.Id) || r.Username == LoggedInUser || VoteState.None != r.Voted || r.Score < minScore || (ds.FilterOutRead && db.IsRead(r.Id))) { continue; } rants.Add(r); ids.Add(r.Id); } } catch (Exception e) { } page++; } if (useOffset && shouldIncrement) { IncrementOffset(); } lock (feed_lock) { feeds.Clear(); foreach (var rant in rants) { ViewModels.Rant r = new ViewModels.Rant(rant); feeds.Add(r); } } if (otherVals.Count > 0 && otherVals.ContainsKey(ValuesCollection.NumNotifs)) { int count = Convert.ToInt32(otherVals[ValuesCollection.NumNotifs]); if (count > 0) { //Just refresh nchecker.Check(); } UpdateNotifications(new NotificationsChecker.UpdateArgs(count, count)); } UpdateFollowedInRants(); feedView.SortDescriptions.Clear(); string message = "Loaded {0} rants from {1} pages"; UpdateStatus(string.Format(message, rants.Count, page)); }
///<summary> ///</summary> ///<param name="capacity"> </param> public NamedCollection(int capacity) { this._dictionary = new Dictionary <string, T>(capacity); this._values = new ValuesCollection(this); this._list = new List <INamable>(capacity); }
///<summary> ///</summary> public NamedCollection() { this._dictionary = new Dictionary <string, T>(INITIAL_CAPACITY); this._values = new ValuesCollection(this); this._list = new List <INamable>(INITIAL_CAPACITY); }