public Foo <T> Read <T>() { string path = Path.Combine(this.path, this.filename); if (!DbRepo.fileSystem.FileExists(path)) { return(null); } DateTime lastWriteTime = DbRepo.fileSystem.GetLastWriteTimeUtc(path); if (!this.lastTS.HasValue || this.lastTS.Value.Ticks != lastWriteTime.Ticks) { if (this.encoding == null) { this.strDataCache = DbRepo.fileSystem.ReadAllText(path); } else { this.strDataCache = DbRepo.fileSystem.ReadAllText(path, this.encoding); } this.lastTS = new DateTime?(lastWriteTime); } Foo <T> foo = DbRepo.json.DeserializeFromString <Foo <T> >(this.strDataCache); if (foo._header == null) { foo._header = FooHelper.CreateHeader(); } if (foo.data == null) { foo.data = new List <T>(); } return(foo); }
/// /// <summary>Main for FooListener.</summary> /// <param name="args"></param> /// public static void Main1(String[] args) { string uri = "tcp://localhost:4001"; MainFooListener implFactory = new MainFooListener(); ServerFactory listener = FooHelper.NewListener(uri, null, implFactory); listener.TransportControl(TransportConsts.START_AND_WAIT_UP, 4000); }
public List <T> StartUpdate() { Foo <T> foo = this.file.Read <T>(); if (foo == null) { foo = FooHelper.Create <T>(); } return(foo.data); }
public bool Save <T>(List <T> data) { Foo <T> foo = this.Read <T>(); if (foo == null) { foo = FooHelper.Create <T>(); } foo.data = data; return(this.Save <T>(foo)); }
public bool Commit(List <T> items) { Foo <T> foo = this.file.Read <T>(); if (foo == null) { foo = FooHelper.Create <T>(); } foo.data = items; //this.file.Save<T>(foo.data); this.file.Save <T>(foo); return(true); }
/// /// <summary>Main for FooClient</summary> /// <param name="args"></param> /// public static void Main(String[] args) { string uri = "tcp://localhost:4001"; MainFooListener.Main1(null); MainFooClient implFactory = new MainFooClient(); RemoteFooServer server = FooHelper.NewServer(uri, null, implFactory); server._TransportControl(TransportConsts.START_AND_WAIT_UP, 4000); // Insert Your Code Here //--------------------------------------------------------------------- StrStrHashMap bazTable = new StrStrHashMap(); bazTable.Add("def", "baz"); StrStrHashMap barTable = new StrStrHashMap(); barTable.Add("def", "bar"); StrStrHashMap fooTable = new StrStrHashMap(); fooTable.Add("def", "foo"); BazData bazData = new BazData(1, bazTable); BarData barData = new BarData(2, barTable, bazData); FooData fooData = new FooData(3, fooTable, barData, bazData); bool?ok; ok = server.baz1(bazData); Console.WriteLine("baz1 => " + ok); ok = server.baz2(bazData); Console.WriteLine("baz2 => " + ok); ok = server.bar1(barData); Console.WriteLine("bar1 => " + ok); ok = server.bar2(barData); Console.WriteLine("bar2 => " + ok); ok = server.foo1(fooData); Console.WriteLine("foo1 => " + ok); ok = server.foo2(fooData); Console.WriteLine("foo2 => " + ok); server._TransportControl(TransportConsts.STOP_AND_WAIT_DOWN, 4000); }
public int Insert(T item) { Foo <T> foo = this.file.Read <T>(); if (foo == null) { foo = FooHelper.Create <T>(); } this.ProcessAttributes(foo._header, item); foo.data.Add(item); this.file.Save <T>(foo); return(1); }
public int Insert(List <T> list) { Foo <T> foo = this.file.Read <T>(); if (foo == null) { foo = FooHelper.Create <T>(); } foreach (T current in list) { foo.data.Add(current); } this.file.Save <T>(foo); return(1); }
public bool ChangeHeader(string version, string title, string descriptor) { Foo <T> foo = null; try { foo = this.file.Read <T>(); } catch (Exception ex) { foo = null; } if (foo == null) { foo = FooHelper.Create <T>(); foo.data = new List <T>(); } foo._header.version = version; foo._header.title = title; foo._header.descriptor = descriptor; this.file.Save <T>(foo); return(true); }
public BarHelper(FooHelper fooHelper) { this.FooHelper = fooHelper; }
public Foo() { Data = FooHelper.GetDefault <T>(); }