public IEnumerable <Person> GetBrothersInLaw() { var bil = new List <Person>(); var spouseMaleSiblings = Spouse?.First().Relationships.GetSiblings() ?.Where(x => x.Gender == Gender.Male); if (spouseMaleSiblings?.Any() == true) { bil.AddRange(spouseMaleSiblings); } var femaleSiblings = Siblings?.Where(x => x.Gender == Gender.Female) ?? Enumerable.Empty <Person>(); foreach (var motherFemaleChild in femaleSiblings) { var spouse = motherFemaleChild.Relationships.GetSpouse(); if (spouse?.Any() == true) { bil.Add(spouse.First()); } } return(bil); }
public void SearchSiblings(string query) { Siblings.Clear(); QueryResultRows <TreeItem> result; //if (GhostParent != null) { if (query.Length > 0) { result = Db.SQL <TreeItem>("SELECT i FROM TreeItem i WHERE Parent = ? AND Name LIKE ? FETCH ?", ParentItem, query + "%", 5); } else { result = Db.SQL <TreeItem>("SELECT i FROM TreeItem i WHERE Parent = ? FETCH ?", ParentItem, 5); } /*} * else { * if (query.Length > 0) { * result = Db.SQL<TreeItem>("SELECT i FROM TreeItem i WHERE Parent = ? AND NOT i = ? AND Name LIKE ? FETCH ?", ParentItem, Data, query + "%", 5); * } * else { * result = Db.SQL<TreeItem>("SELECT i FROM TreeItem i WHERE Parent = ? AND NOT i = ? FETCH ?", ParentItem, Data, 5); * } * }*/ Siblings.Data = result; }
public void MaxDot_should_return_zero_for_empty_set() { var clocks = new Siblings(); long counter = clocks.MaxDot("x"); counter.Should().Be(0); }
public void AddSibling(Node n) { Siblings.Add(n); isLonely = false; n.Level = this.Level; addOwnerTree(n); }
public void AddSibling(Cell cell) { if (cell != null) { Siblings.Add(cell); cell.Siblings.Add(this); } }
/// <summary> /// Detaches this node from it's parent. /// Postcondition: this is a root node. /// </summary> /// <returns></returns> public T Detach() { if (_parent != null) { Siblings.Remove((T)this); } return((T)this); }
/// <summary> /// Detaches this node from it's parent. /// Postcondition: this is a root node. /// </summary> /// <returns></returns> public DTreeNode <T> Detach() { if (mParent != null) { Siblings.Remove(this); } return(this); }
private void SortData() { Siblings.Sort(DateComparer); foreach (var fam in Marriages) { fam.Children.Sort(DateComparer); } }
public PlayMenuNode GetPreviousSibling() { int loc = Siblings.IndexOf(this) - 1; if (loc < 0) { loc = Siblings.Count - 1; } return(Siblings[loc]); }
public void siblingAnalyseTest() { // Arrange string input = "213"; long expectedOutput = 321; // Act var actualOutput = Siblings.siblingAnalyse(input); // Assert Assert.AreEqual(expectedOutput, actualOutput); }
public IHttpActionResult GetReplica(HttpRequestMessage req, string key) { try { Siblings siblings = _node.GetReplicaAsync(key); return(Ok(siblings)); } catch (KeyNotFoundException e) { return(NotFound()); } }
public void AddSibling(Person person) { Siblings ??= new List <Person>(); if (!Siblings.Contains(person)) { Siblings.Add(person); } else { throw new Exception("Sibling already present"); } }
public void MaxDot_should_return_the_max_counter_for_a_server_id_not_found() { var clocks = new Siblings { { new JObject(new JProperty("v", 1)), DottedVersionVector.Parse("((r,1),{})") }, { new JObject(new JProperty("v", 2)), DottedVersionVector.Parse("((r,2),{})") }, { new JObject(new JProperty("v", 1)), DottedVersionVector.Parse("((s,5),{(t,4)})") }, }; long counter = clocks.MaxDot("x"); counter.Should().Be(0); }
public static void Test(){ Node root = new Node(1); root.Left = new Node(2); root.Right = new Node(3); root.Left.Left = new Node(4); root.Left.Right = new Node(5); root.Right.Left = new Node(6); root.Right.Right = new Node(7); Siblings sb = new Siblings(); sb.AttachSiblings(root); Console.Write(root.Right.Right.Prev.Data+" == 6"); Console.Write("\n"+root.Right.Left.Prev.Data+" == 5"); Console.Write("\n"+(root.Left.Left.Prev==null?"null":"exists")+" == null"); }
public void Sync_should_return_s1_when_input_s1_and_s1() { var kernel = new DvvKernel(); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" } }; var siblings = kernel.Sync(s1, s1); // Assert siblings.Should().HaveCount(1); siblings.Should().Contain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,1),{})"))); }
public void Ids_should_return_set_of_identifiers() { var clocks = new Siblings { { new JObject(new JProperty("v", 1)), DottedVersionVector.Parse("((r,1),{})") }, { new JObject(new JProperty("v", 2)), DottedVersionVector.Parse("((r,2),{})") }, { new JObject(new JProperty("v", 1)), DottedVersionVector.Parse("((s,1),{(t,4)})") }, }; var ids = clocks.Ids(); ids.Should().Contain(new[] { "r", "s", "t" }); ids.Should().HaveCount(3); ids.Should().OnlyHaveUniqueItems(); }
private Node Search(int number, Node exclude = null) { if (Number == number) { return(this); } foreach (var sibling in Siblings.Except(new[] { exclude })) { Node result = sibling.Search(number, this); if (result != null) { return(result); } } return(null); }
private void Initialize(string path) { if (IsDir) { var files = Directory.GetFileSystemEntries(path); foreach (var file in files) { var newSibling = new FilesystemElement(file, _treeRoot); Siblings.Add(newSibling); } } else { VirtualPath = ToVirtualPath(path); } }
/// <summary> /// Deserializes and returns the object's value, using the provided deserializer. /// </summary> /// <typeparam name="T">The value's target type.</typeparam> /// <param name="deserializeObject">A delegate to handle deserialization of an byte[] serialized object to it's original type.</param> /// <param name="resolveConflict"> /// A delegate to handle resolution of sibling objects. /// Takes all the sibling objects as input and returns one "resolved" object. /// </param> /// <returns>The deserialized value.</returns> public T GetObject <T>(DeserializeObject <T> deserializeObject, ResolveConflict <T> resolveConflict = null) { if (deserializeObject == null) { throw new ArgumentException("deserializeObject must not be null"); } if (Siblings.Count > 1 && resolveConflict != null) { var conflictedObjects = Siblings.Select(s => deserializeObject(s.Value, ContentType)).ToList(); return(resolveConflict(conflictedObjects)); } return(deserializeObject(Value, ContentType)); }
public void Dispose() { if (_decorator != null) { _decorator.Dispose(); _decorator = null; } if (_hightLightDecorator != null) { _hightLightDecorator.Dispose(); _hightLightDecorator = null; } if (_cellDecorator != null) { _cellDecorator.Dispose(); _cellDecorator = null; } if (_cellHightLightDecorator != null) { _cellHightLightDecorator.Dispose(); _cellHightLightDecorator = null; } Table = null; if (Siblings != null) { Siblings.Clear(); Siblings = null; } if (Cells != null) { foreach (var cell in Cells.ToArray()) { cell.Dispose(); } Cells.Clear(); Cells = null; } TextAlign = null; TextFunc = null; HighlightFunc = null; Hud = null; }
public Schema() : base() { InstanceType = typeof(__Breadcru1__); ClassName = "BreadcrumbPageBreadcrumbsElement"; Properties.ClearExposed(); Name = Add <__TString__>("Name", bind: "FormattedName"); Name.DefaultValue = ""; Name.SetCustomAccessors((_p_) => { return(((__Breadcru1__)_p_).__bf__Name__); }, (_p_, _v_) => { ((__Breadcru1__)_p_).__bf__Name__ = (System.String)_v_; }, false); SearchQuery = Add <__TString__>("SearchQuery$"); SearchQuery.DefaultValue = ""; SearchQuery.Editable = true; SearchQuery.SetCustomAccessors((_p_) => { return(((__Breadcru1__)_p_).__bf__SearchQuery__); }, (_p_, _v_) => { ((__Breadcru1__)_p_).__bf__SearchQuery__ = (System.String)_v_; }, false); SearchQuery.AddHandler((Json pup, Property <String> prop, String value) => { return(new Input.SearchQuery() { App = (BreadcrumbPageBreadcrumbsElement)pup, Template = (TString)prop, Value = value }); }, (Json pup, Starcounter.Input <String> input) => { ((BreadcrumbPageBreadcrumbsElement)pup).Handle((Input.SearchQuery)input); }); IsActive = Add <__TBool__>("IsActive"); IsActive.DefaultValue = false; IsActive.SetCustomAccessors((_p_) => { return(((__Breadcru1__)_p_).__bf__IsActive__); }, (_p_, _v_) => { ((__Breadcru1__)_p_).__bf__IsActive__ = (System.Boolean)_v_; }, false); IsGhost = Add <__TBool__>("IsGhost", bind: "IsGhostParentSet"); IsGhost.DefaultValue = false; IsGhost.SetCustomAccessors((_p_) => { return(((__Breadcru1__)_p_).__bf__IsGhost__); }, (_p_, _v_) => { ((__Breadcru1__)_p_).__bf__IsGhost__ = (System.Boolean)_v_; }, false); IsAdd = Add <__TBool__>("IsAdd"); IsAdd.DefaultValue = false; IsAdd.SetCustomAccessors((_p_) => { return(((__Breadcru1__)_p_).__bf__IsAdd__); }, (_p_, _v_) => { ((__Breadcru1__)_p_).__bf__IsAdd__ = (System.Boolean)_v_; }, false); Select = Add <__TLong__>("Select$"); Select.DefaultValue = 0L; Select.Editable = true; Select.SetCustomAccessors((_p_) => { return(((__Breadcru1__)_p_).__bf__Select__); }, (_p_, _v_) => { ((__Breadcru1__)_p_).__bf__Select__ = (System.Int64)_v_; }, false); Select.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.Select() { App = (BreadcrumbPageBreadcrumbsElement)pup, Template = (TLong)prop, Value = value }); }, (Json pup, Starcounter.Input <Int64> input) => { ((BreadcrumbPageBreadcrumbsElement)pup).Handle((Input.Select)input); }); Siblings = Add <__TArray__>("Siblings"); Siblings.SetCustomGetElementType((arr) => { return(__Breadcru2__.DefaultTemplate); }); Siblings.SetCustomAccessors((_p_) => { return(((__Breadcru1__)_p_).__bf__Siblings__); }, (_p_, _v_) => { ((__Breadcru1__)_p_).__bf__Siblings__ = (__Arr__)_v_; }, false); AddSibling = Add <__TLong__>("AddSibling$"); AddSibling.DefaultValue = 0L; AddSibling.Editable = true; AddSibling.SetCustomAccessors((_p_) => { return(((__Breadcru1__)_p_).__bf__AddSibling__); }, (_p_, _v_) => { ((__Breadcru1__)_p_).__bf__AddSibling__ = (System.Int64)_v_; }, false); AddSibling.AddHandler((Json pup, Property <Int64> prop, Int64 value) => { return(new Input.AddSibling() { App = (BreadcrumbPageBreadcrumbsElement)pup, Template = (TLong)prop, Value = value }); }, (Json pup, Starcounter.Input <Int64> input) => { ((BreadcrumbPageBreadcrumbsElement)pup).Handle((Input.AddSibling)input); }); }
public async Task Put_should_store_value_for_key_when_node_owns_partition() { var node = new Node("A", new[] { "A", "B", "C" }); var remote = Substitute.For <IRemoteNodeClient>(); node.UseRemoteNodeClient(remote); await node.PutAsync("foo", JObject.Parse("{'value':'bar'}")); Siblings result = await node.GetAsync("foo"); dynamic document = (result.ToArray()[0].Value); string value = document.value; value.Should().Be("bar"); }
public void SearchSiblings(string query) { Siblings.Clear(); IEnumerable <TreeItem> result; if (query.Length > 0) { result = Db.SQL <TreeItem>("SELECT i FROM UniformDocs.Database.TreeItem i WHERE Parent = ? AND Name LIKE ? FETCH ?", ParentItem, query + "%", 5); } else { result = Db.SQL <TreeItem>("SELECT i FROM UniformDocs.Database.TreeItem i WHERE Parent = ? FETCH ?", ParentItem, 5); } Siblings.Data = result; }
public void Join_should_return_a_clock_that_describes_the_collective_causal_past() { var kernel = new DvvKernel(); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" }, { new JObject(new JProperty("v", 2)), "((r,2),{(s,2)})" } }; VersionVector vv = kernel.Join(s1); vv.Events.Should().Contain(new[] { new KeyValuePair <string, long>("r", 2), new KeyValuePair <string, long>("s", 2) }); }
public async Task <IHttpActionResult> Get(HttpRequestMessage req, string key) { try { Siblings siblings = await _node.GetAsync(key); // Only return the values (strip-off the clocks) List <JToken> values = siblings.Select(s => s.Value).ToList(); HttpResponseMessage res = req.CreateResponse(values); VersionVector context = _node.Kernel.Join(siblings); res.Headers.Add("X-Context", context.ToContextString()); return(ResponseMessage(res)); } catch (KeyNotFoundException e) { return(NotFound()); } }
public void Event_should_generate_a_new_clock_to_represent_a_new_version() { var kernel = new DvvKernel(); var context = new VersionVector(new[] { new CausalEvent("s", 2), new CausalEvent("r", 2), }); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" }, { new JObject(new JProperty("v", 2)), "((r,2),{(s,2)})" } }; DottedVersionVector dvv = kernel.Event(context, s1, "r"); dvv.ToString().Should().Be("((r,3),{(r,2),(s,2)})"); }
public void UpdatePatientSiblings() { if (Siblings == null) { Siblings = new List <Sibling>(); } var SiblingsNew = new List <Sibling>(); if (Sisters != null && Sisters.Count != 0) { SiblingsNew.AddRange(Sisters); } if (Brothers != null && Brothers.Count != 0) { SiblingsNew.AddRange(Brothers); } // Insert foreach (Sibling siblingNew in SiblingsNew) { if (!Siblings.Any(row => row.Id == siblingNew.Id && row.Id != 0)) { siblingNew.Patient = this; Siblings.Add(siblingNew); } } // ToDo Delete //var siblingsToControl = new List<Sibling>(); //siblingsToControl.AddRange(Siblings); //foreach (Sibling siblingToControl in siblingsToControl) //{ // if (!SiblingsNew.Any(row => row.Id == siblingToControl.Id && row.Id != 0)) // { // Siblings.RemoveAll(row => row.Id == siblingToControl.Id); // } //} }
public void Discard_should_remove_obsolete_siblings() { var kernel = new DvvKernel(); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" }, { new JObject(new JProperty("v", 2)), "((r,2),{})" } }; // This is the context we'd receive representing ((r,3),{(r,1)}) : v3 var context = new VersionVector(new CausalEvent("r", 1)); Siblings siblings = kernel.Discard(s1, context); // Assert siblings.Should().HaveCount(1); siblings.Should().NotContain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,1),{})"))); siblings.Should().Contain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,2),{})"))); }
public void Sync_should_return_concurrent_siblings() { var kernel = new DvvKernel(); var s1 = new Siblings { { new JObject(new JProperty("v", 1)), "((r,1),{})" }, { new JObject(new JProperty("v", 2)), "((r,2),{})" } }; var s2 = new Siblings { { new JObject(new JProperty("v", 3)), "((r,3),{(r,1)})" } }; var siblings = kernel.Sync(s1, s2); // Assert siblings.Should().HaveCount(2); siblings.Should().NotContain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,1),{})"))); siblings.Should().Contain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,2),{})"))); siblings.Should().Contain(x => x.Clock.Equals(DottedVersionVector.Parse("((r,3),{(r,1)})"))); }
private void RemoveSibling(Person person) { Siblings.Remove(person); }
public PlayMenuNode GetNextSibling() { return(Siblings[(Siblings.IndexOf(this) + 1) % Siblings.Count]); }