private void Produce <T>(Bag <T> bag, string indent) { var id = DataBinding.GetId <T>(bag); if (!StateSet.Contains(id)) { Console.WriteLine(indent + id); bag.Accept(new Visitor <T>(this, indent + " ")); } }
/// <summary> /// Create partial data. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="bag"></param> public void Create <T>(Bag <T> bag) { var id = DataBinding.GetId(bag); if (DataStorage.Exist(id)) { return; } bag.Accept(new CreateVisitor <T>(this, id)); }
public void Set <T>(Bag <T> bag, string bagId) { if (BagToId.ContainsKey(bag)) { return; } if (IdToBag.ContainsKey(bagId)) { throw new Exception( "two bags can't have the same name: " + bagId); } IdToBag[bagId] = bag; BagToId[bag] = bagId; bag.Accept(new SetVisitor <T>(this, bagId)); }
public void TestAccept2() { Bag <string> b = new Bag <string>(); b.Add("5"); b.Add("4"); b.Add("3"); b.Add("2"); TrackingVisitor <KeyValuePair <string, int> > visitor = new TrackingVisitor <KeyValuePair <string, int> >(); b.Accept(visitor); Assert.AreEqual(visitor.TrackingList.Count, 4); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <string, int>("5", 1)), true); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <string, int>("4", 1)), true); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <string, int>("3", 1)), true); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <string, int>("2", 1)), true); }
public void TestAccept() { Bag <string> b = new Bag <string>(); b.Add("5"); b.Add("4"); b.Add("3"); b.Add("2"); TrackingVisitor <string> visitor = new TrackingVisitor <string>(); b.Accept(visitor); Assert.AreEqual(visitor.TrackingList.Count, 4); Assert.AreEqual(visitor.TrackingList.Contains("5"), true); Assert.AreEqual(visitor.TrackingList.Contains("4"), true); Assert.AreEqual(visitor.TrackingList.Contains("3"), true); Assert.AreEqual(visitor.TrackingList.Contains("2"), true); }
public IEnumerable <T> Get <T>(Bag <T> bag) => bag.Accept(new Visitor <T>(this));
public IObservable <T> Get <T>(Bag <T> bag) => Map.GetOrCreate( bag, () => bag.Accept(new CreateVisitor <T>(this)));
public void TestInvalidAccept2() { Bag <string> b = new Bag <string>(); b.Accept((IVisitor <KeyValuePair <string, int> >)null); }
public void TestInvalidAccept1() { Bag <string> b = new Bag <string>(); b.Accept((IVisitor <string>)null); }
public void TestNullVisitor1() { Bag <string> b = new Bag <string>(); b.Accept((IVisitor <string>)null); }
public Aliq.Void Visit <T>(Bag <T> bag) => bag.Accept(new CreateVisitor <T>(Node, Id));