public string this [string key] { get { return this.headers.NotNull() ? this.headers[key] : null; } set { if (key.NotEmpty()) { if (this.headers.IsNull()) this.headers = new Collection.Dictionary<string, string>(); this.headers[key] = value; switch (key) { case "Link": this.link = null; break; case "Location": this.location = null; break; case "Content-Length": this.contentLength = null; break; } } } }
public string this [string key] { get { return this.headers.NotNull() ? this.headers[key] ?? key == "Host" ? this.Host : null : null; } set { if (key.NotEmpty()) { if (this.headers.IsNull()) this.headers = new Collection.Dictionary<string, string>(); this.headers[key] = value; if (key == "Host") this.Url.Authority = value; } } }
public Table( Action <byte[]> SaveKeys, Func <byte[]> LoadKeys, Collection.IDictionary <KeyType, (ValueType Value, ulong UpdateCode)> Data,
public Resolver() { this.targets = new Collection.Dictionary<Uri.Locator, object>(); this.reverse = new Collection.Dictionary<object, Uri.Locator>(); this.looseEnds = new Collection.Dictionary<Uri.Locator, Action<object>>(); }
public Table( Action <byte[]> SaveKeys, Func <byte[]> LoadKeys, Collection.IDictionary <KeyType, ValueType> Data, Func <ValueType, KeyType> GetKey, bool IsUpdateAble) : base(new DynamicArray <ValueType>(), GetKey, false) { var OldData = LoadKeys(); if (OldData != null) { var OldTable = OldData.Deserialize(this); this.KeysInfo.Keys = OldTable.KeysInfo.Keys; if (IsUpdateAble) { ReadyForUpdateAble(); } this.UpdateAble = OldTable.UpdateAble; } else { if (IsUpdateAble) { ReadyForUpdateAble(); this.UpdateAble = new UpdateAbles <KeyType>(); } } var Ar = (DynamicArray <ValueType>) this.BasicActions.Items; Ar._GetItem = (Pos) => { return(Data[this.KeysInfo.Keys[Pos]]); }; Ar._SetItem = (Pos, Value) => Data[this.KeysInfo.Keys[Pos]] = Value; Ar._DeleteByPosition = (c) => { Data.Remove(this.KeysInfo.Keys[c]); Ar.Length -= 1; }; Ar._AddLength = (count) => Ar.Length += count; Ar.Length = KeysInfo.Keys.Length; Save = () => { SaveKeys(this.Serialize()); }; if (true == true) //is fast Save { ((Action)(async() => { save: try { await Task.Delay(1000); } catch { goto save; } if (this.NeedToSave == true) { Save(); NeedToSave = false; } goto save; }))(); this.Events.Inserted += (info) => { lock (this) { if (this.NeedToSave == false) { this.NeedToSave = true; } } }; this.Events.Deleted += (info) => { lock (this) { if (this.NeedToSave == false) { this.NeedToSave = true; } } }; this.KeyChanged += (info) => { lock (this) { if (this.NeedToSave == false) { this.NeedToSave = true; } } }; this.Events.Updated += (info) => { lock (this) { if (this.NeedToSave == false) { this.NeedToSave = true; } } }; } else { Runer.Run.OnEndBlocks += () => Save(); } }