public void Initialize() { testFileName = Path.GetRandomFileName(); testFile = new KeyValueStore(testFileName); key = Path.GetRandomFileName(); XmlSerializer.RegisterType(typeof(SnapshotInfo), "snapshotInfo"); }
public NoteManager(KeyValueStore<NoteEntity> noteStore) { if (noteStore == null) { throw new ArgumentNullException(nameof(noteStore)); } this.noteStore = noteStore; }
public override void Build() { var sw = new Stopwatch(); sw.Start(); var sourceStream = _fileSystemService.ReadStream(_filePath); var format = _filePath.Split('.').Last(); var reader = GetReader(format); var kvUsageMemoryStream = new MemoryStream(); var kvUsage = new KeyValueUsage(kvUsageMemoryStream); var keyValueStoreFile = _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueStorePathFormat, _outputDirectory)); var index = new KeyValueIndex(Settings.Search.KvIndexCapacity, Settings.Search.PrefixLength); var keyValueStore = new KeyValueStore(index, kvUsage, keyValueStoreFile); var storeFile = _fileSystemService.WriteStream(String.Format(MapConsts.ElementStorePathFormat, _outputDirectory)); Store = new ElementStore(keyValueStore, storeFile, ObjectPool); Tree = new RTree <uint>(65); reader.Read(new ReaderContext { SourceStream = sourceStream, Builder = this, ReuseEntities = false, SkipTags = false, }); Clear(); Complete(); using (var kvFileStream = _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueUsagePathFormat, _outputDirectory))) { var buffer = kvUsageMemoryStream.GetBuffer(); kvFileStream.Write(buffer, 0, (int)kvUsageMemoryStream.Length); } KeyValueIndex.Save(index, _fileSystemService.WriteStream(String.Format(MapConsts.KeyValueIndexPathFormat, _outputDirectory))); SpatialIndex.Save(Tree, _fileSystemService.WriteStream(String.Format(MapConsts.SpatialIndexPathFormat, _outputDirectory))); Store.Dispose(); sw.Stop(); Trace.Debug(CategoryKey, Strings.IndexBuildInMs, sw.ElapsedMilliseconds.ToString()); }
public void SetMany() { var values = new Dictionary <KeyBytes, byte[]>(); foreach (int i in Enumerable.Range(0, 10)) { values[new KeyBytes(Random.NextBytes(PreStoredDataKeySize))] = Random.NextBytes(PreStoredDataValueSize); } KeyValueStore.Set(values); foreach (KeyValuePair <KeyBytes, byte[]> kv in values) { Assert.Equal(kv.Value, KeyValueStore.Get(kv.Key)); } }
public void Setup() { var boundingBox = new BoundingBox(new GeoCoordinate(52.0, 13.0), new GeoCoordinate(52.2, 13.2)); var keyValueStream = new MemoryStream(new byte[256]); keyValueStream.WriteByte(4); keyValueStream.WriteByte(7); var kvIndex = new KeyValueIndex(100, 3); var kvUsage = new KeyValueUsage(new MemoryStream(1000)); var kvStore = new KeyValueStore(kvIndex, kvUsage, keyValueStream); var elementStoreStream = new MemoryStream(new byte[10000]); var elementStore = new ElementStore(kvStore, elementStoreStream, TestHelper.GetObjectPool()); var tree = new RTree <uint>(); var node = new Node() { Id = 1, Coordinate = new GeoCoordinate(52.0, 13.0), Tags = new Dictionary <string, string>() { { "key1", "value1" }, { "key2", "value2" } }.ToTags() }; var nodeOffset = elementStore.Insert(node); tree.Insert(nodeOffset, new PointEnvelop(node.Coordinate)); var way = new Way() { Id = 2, Coordinates = new List <GeoCoordinate>() { new GeoCoordinate(52.1, 13.1), new GeoCoordinate(52.2, 13.2) }, Tags = new Dictionary <string, string>() { { "key1", "value1" }, { "key2", "value2" } }.ToTags() }; var wayOffset = elementStore.Insert(way); tree.Insert(wayOffset, new Envelop(way.Coordinates.First(), way.Coordinates.Last())); _source = new ElementSource(boundingBox, kvUsage, kvIndex, kvStore, elementStore, tree); }
private void AddMany(KeyValueStore <string, string> kvstore, int count, int threadNum, bool addThreadNum = false) { for (int x = 0; x < count; x++) { string key = ""; if (addThreadNum) { key = string.Format("{0}key{1}", x, threadNum); } else { key = string.Format("{0}key", x); } var val = string.Format("{0}val{1}", x, threadNum); kvstore.Set(key, val); } }
/// <summary> /// The constructor bootstraps the main chain and all core side chains. /// </summary> public Nexus(Logger logger = null, Func <string, IKeyValueStoreAdapter> adapterFactory = null) { this._adapterFactory = adapterFactory; this._vars = new KeyValueStore <string, byte[]>(CreateKeyStoreAdapter("nexus")); try { var temp = this.Name; Ready = !string.IsNullOrEmpty(temp); } catch { Ready = false; } _logger = logger; }
} // create public dict activate(IContext ctx, idstring userid, varchar activationkey) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; long pver; dict u = KeyValueStore.Find("user:"******"activationkey"].Equals(activationkey.str)) { u["activationkey"] = ""; status = KeyValueStore.Store("user:"******"status", status); return(Return); } // activate
public dict create(IContext ctx, idstring userid, password password, varchar realname, email email) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; string message = "unknown error"; long pver; if (userid.str.Length < 5 || !Helpers.IsValidId(userid.str)) { message = "bad user id format: non-special characters, at least length 5 required"; } else if (KeyValueStore.Find("user:"******"the user id " + userid + " already exists"; } else if (KeyValueStore.Find("email:" + email, out pver) != null) { message = "the email address " + email + " is already tied to another user id"; } else { dict user = new dict(); user.Add("userid", userid.str); user.Add("password", password.str); user.Add("realname", realname.str); user.Add("email", email.str); user.Add("activationkey", Helpers.RandomString(24)); if (KeyValueStore.Store("user:"******"user " + userid + " created"; status = true; } else { message = "database error when trying to create user " + userid; } } Return.Add("status", status); Return.Add("message", message); return(Return); } // create
/// <summary> /// Registers Marker /// </summary> /// <param name="typeMapper">Type Mapper</param> /// <param name="settings">Settings</param> private void RegisterMarker(ITypeMapper typeMapper, KeyValueStore settings) { // Marker settings.Set <MarkerItem>("MinRadius", 20f, "Minimum Radius of a Marker"); settings.Set <MarkerItem>("MaxRadius", 200f, "Maximum Radius of a Marker"); settings.Set <MarkerItem>("Volume", 2000f, "Total Volume of a Marker"); typeMapper.RegisterItem <MarkerItem, MarkerState, MarkerInfo>(this, "Marker"); // Smellable typeMapper.AttachItemProperty <MarkerItem, SmellableProperty>(this, "Marker Smellable", (i) => { SmellableProperty property = new SmellableProperty(i); // Bind Smellable Radius to the Item Radius property.SmellableRadius = i.Radius; i.RadiusChanged += (item, v) => { property.SmellableRadius = v; }; return(property); }); }
public Chain(Nexus nexus, string name, Logger log = null) { Throw.IfNull(nexus, "nexus required"); this.Name = name; this.Nexus = nexus; this.Address = Address.FromHash(this.Name); // init stores _transactions = new KeyValueStore <Hash, Transaction>(Nexus.CreateKeyStoreAdapter(this.Address, "txs")); _blocks = new KeyValueStore <Hash, Block>(Nexus.CreateKeyStoreAdapter(this.Address, "blocks")); _transactionBlockMap = new KeyValueStore <Hash, Hash>(Nexus.CreateKeyStoreAdapter(this.Address, "txbk")); _contracts = new KeyValueStore <string, bool>(Nexus.CreateKeyStoreAdapter(this.Address, "contracts")); _blockHeightMap = new KeyValueStore <BigInteger, Hash>(Nexus.CreateKeyStoreAdapter(this.Address, "heights")); this.Storage = new KeyStoreStorage(Nexus.CreateKeyStoreAdapter(this.Address, "data")); this.Log = Logger.Init(log); }
public DBController(string journalFile, IEnumerable <IDataVizFactory> vizFactories) { string path = Path.GetDirectoryName(journalFile); _db = new KeyValueStore(path); foreach (var vf in vizFactories) { var v = vf.GetVisualizer(_db); if (v != null) { _viz = v; break; } } if (_viz == null) { _viz = new ByteViz(); } }
public void Setup() { var kvUsagesream = new MemoryStream(1026); kvUsagesream.WriteByte(4); kvUsagesream.WriteByte(7); _kvUsage = new KeyValueUsage(kvUsagesream); var keyValueStream = new MemoryStream(new byte[256]); keyValueStream.WriteByte(4); keyValueStream.WriteByte(7); _index = new KeyValueIndex(100, 3); _kvStore = new KeyValueStore(_index, _kvUsage, keyValueStream); var elementStoreStream = new MemoryStream(new byte[10000]); _elementStore = new ElementStore(_kvStore, elementStoreStream, TestHelper.GetObjectPool()); }
public void CrashTestBeforeMerge() { string path = Path.GetFullPath("TestData\\CrashTestBeforeMerge"); using (var db = new KeyValueStore(path)) { db.Truncate(); } var doneSetting = new EventWaitHandle(false, EventResetMode.ManualReset, "CrashTestBeforeMerge"); doneSetting.Reset(); string testPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase), "RazorTest.exe"); var process = Process.Start(testPath, "CrashTestBeforeMerge"); doneSetting.WaitOne(30000); process.Refresh(); if (!process.HasExited) { try { process.Kill(); } catch { } process.WaitForExit(); } // Open the database created by the other program using (var db = new KeyValueStore(path)) { db.Manifest.Logger = (msg) => Console.WriteLine(msg); Console.WriteLine("Begin enumeration."); ByteArray lastKey = new ByteArray(); int ct = 0; foreach (var pair in db.Enumerate()) { ByteArray k = new ByteArray(pair.Key); Assert.True(lastKey.CompareTo(k) < 0); lastKey = k; ct++; } Assert.AreEqual(10000, ct); Console.WriteLine("Found {0} items in the crashed database.", ct); } }
/// <summary> /// Loads the ConnectionManagers settings from the specified folder /// </summary> /// <param name="settingsFolder">The folder to use for storing settings</param> public void LoadSettings(string settingsFolder) { applicationDataFolder = settingsFolder; settingsFile = new KeyValueStore(Path.Combine(settingsFolder, "Account.xml")); if (settingsFile != null) { _clusterKey = settingsFile.GetItem <string>("ClusterKey").GetBytesBase64(); //Set up XmppMessagingClient and connect var messagingClient = new XmppMessagingClient() { Username = settingsFile.GetItem <string>("XmppUsername"), Server = settingsFile.GetItem <string>("XmppServer"), Password = settingsFile.GetItem <string>("XmppPassword") }; messagingClients.Add(messagingClient); messagingClient.MessageReceived += messagingClient_MessageReceived; messagingClient.PeerDisconnected += messagingClient_PeerDisconnected; messagingClient.Connect(); var clients = settingsFile.GetItem <IEnumerable <object> >("KnownClients"); if (clients == null) { knownClientsCache = new Dictionary <string, ClientInfo>(); } else { knownClientsCache = clients .Cast <ClientInfo>() .ToDictionary(x => x.JId); } logger.Info("Sucessfully loaded settings"); } }
public void IndexClean() { string path = Path.GetFullPath("TestData\\IndexClean"); using (var db = new KeyValueStore(path)) { db.Truncate(); db.Manifest.Logger = msg => Console.WriteLine(msg); db.Set(Encoding.UTF8.GetBytes("KeyA"), Encoding.UTF8.GetBytes("ValueA:1"), new Dictionary <string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("1") } }); db.Set(Encoding.UTF8.GetBytes("KeyB"), Encoding.UTF8.GetBytes("ValueB:2"), new Dictionary <string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("2") } }); db.Set(Encoding.UTF8.GetBytes("KeyC"), Encoding.UTF8.GetBytes("ValueC:3"), new Dictionary <string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("3") } }); var lookupValue = db.Find("Idx", Encoding.UTF8.GetBytes("3")).Single(); Assert.AreEqual("ValueC:3", Encoding.UTF8.GetString(lookupValue.Value)); Assert.AreEqual("KeyC", Encoding.UTF8.GetString(lookupValue.Key)); db.Delete(Encoding.UTF8.GetBytes("KeyC")); } // Open the index directly and confirm that the lookup key is still there using (var db = new KeyValueStore(Path.Combine(path, "Idx"))) { Assert.AreEqual(3, db.Enumerate().Count()); } using (var db = new KeyValueStore(path)) { db.CleanIndex("Idx"); } // Open the index directly and confirm that the lookup key is now gone using (var db = new KeyValueStore(Path.Combine(path, "Idx"))) { Assert.AreEqual(2, db.Enumerate().Count()); } }
public void LookupOldDataFromIndex() { string path = Path.GetFullPath("TestData\\LookupOldDataFromIndex"); using (var db = new KeyValueStore(path)) { db.Truncate(); db.Manifest.Logger = msg => Console.WriteLine(msg); db.Set(Encoding.UTF8.GetBytes("KeyA"), Encoding.UTF8.GetBytes("ValueA:1"), new Dictionary <string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("1") } }); db.Set(Encoding.UTF8.GetBytes("KeyB"), Encoding.UTF8.GetBytes("ValueB:2"), new Dictionary <string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("2") } }); db.Set(Encoding.UTF8.GetBytes("KeyC"), Encoding.UTF8.GetBytes("ValueC:3"), new Dictionary <string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("3") } }); var lookupValue = db.Find("Idx", Encoding.UTF8.GetBytes("3")).Single(); Assert.AreEqual("ValueC:3", Encoding.UTF8.GetString(lookupValue.Value)); Assert.AreEqual("KeyC", Encoding.UTF8.GetString(lookupValue.Key)); db.Set(Encoding.UTF8.GetBytes("KeyC"), Encoding.UTF8.GetBytes("ValueC:4"), new Dictionary <string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("4") } }); lookupValue = db.Find("Idx", Encoding.UTF8.GetBytes("4")).Single(); Assert.AreEqual("ValueC:4", Encoding.UTF8.GetString(lookupValue.Value)); Assert.AreEqual("KeyC", Encoding.UTF8.GetString(lookupValue.Key)); Assert.True(db.Find("Idx", Encoding.UTF8.GetBytes("3")).Any()); db.RemoveFromIndex(Encoding.UTF8.GetBytes("KeyC"), new Dictionary <string, byte[]> { { "Idx", Encoding.UTF8.GetBytes("3") } }); Assert.False(db.Find("Idx", Encoding.UTF8.GetBytes("3")).Any()); } }
public Chain(Nexus nexus, string name, Logger log = null) { Throw.IfNull(nexus, "nexus required"); this.Name = name; this.Nexus = nexus; var bytes = System.Text.Encoding.UTF8.GetBytes(name.ToLower()); var hash = CryptoExtensions.SHA256(bytes); this.Address = new Address(hash); // init stores _transactions = new KeyValueStore <Hash, Transaction>(Nexus.CreateKeyStoreAdapter(this.Address, "txs")); _blocks = new KeyValueStore <Hash, Block>(Nexus.CreateKeyStoreAdapter(this.Address, "blocks")); _transactionBlockMap = new KeyValueStore <Hash, Hash>(Nexus.CreateKeyStoreAdapter(this.Address, "txbk")); _epochMap = new KeyValueStore <Hash, Epoch>(Nexus.CreateKeyStoreAdapter(this.Address, "epoch")); this.Storage = new KeyStoreStorage(Nexus.CreateKeyStoreAdapter(this.Address, "data")); this.Log = Logger.Init(log); }
public void TestLargeAndSmallOddWrites() { string path = Path.GetFullPath("TestData\\TestLargeAndSmallInterlacedWrites"); using (var db = new KeyValueStore(path)) { db.Truncate(); // Create a random set of keybytes List <byte[]> keys = new List <byte[]>(); for (int i = 0; i < 10; i++) { keys.Add(Key.Random(10).KeyBytes); } // Set Odds to large for (int i = 0; i < keys.Count; i++) { var k = keys[i]; var v = ((i & 1) == 1) ? GenerateBlock(Config.MaxLargeValueSize - 100) : GenerateBlock(10); db.Set(k, v); } // Now check the results for (int i = 0; i < keys.Count; i++) { var k = keys[i]; var v = db.Get(k); CheckBlock(v); if ((i & 1) == 0) { Assert.Less(v.Length, 100, " i = {0} should be small, but size={1}", i, v.Length); } else { Assert.Greater(v.Length, 100, " i = {0} should be large, but size={1}", i, v.Length); } } } }
public IEnumerator 基本メソッド() { yield return(KeyValueStore .Has(Key) .ToCoroutine(x => Assert.That(x, Is.False))); yield return(KeyValueStore .Get(Key, "DefaultValue") .ToCoroutine(x => Assert.That(x, Is.EqualTo("DefaultValue")))); yield return(KeyValueStore .Set(Key, "NewValue") .ToCoroutine()); yield return(KeyValueStore .Has(Key) .ToCoroutine(x => Assert.That(x, Is.True))); yield return(KeyValueStore .Get <string>(Key) .ToCoroutine(x => Assert.That(x, Is.EqualTo("NewValue")))); }
public void TruncateTest() { string path = Path.GetFullPath("TestData\\TruncateTest"); using (var db = new KeyValueStore(path)) { var indexed = new SortedDictionary <string, byte[]> (); for (int i = 0; i < 15000; i++) { indexed ["RandomIndex"] = ByteArray.Random(20).InternalBytes; var randKey = ByteArray.Random(40); var randValue = ByteArray.Random(256); db.Set(randKey.InternalBytes, randValue.InternalBytes, indexed); } } using (var db = new KeyValueStore(path)) db.Truncate(); var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); Assert.AreEqual(new string[] { Path.GetFullPath(Path.Combine(path, "0.jf")) }, files); var dirs = Directory.GetDirectories(path, "*.*", SearchOption.AllDirectories); Assert.AreEqual(new string[0], dirs); }
public void TestMergeTableTiming(int mergeMax, int size) { PerformanceCounter PC = new PerformanceCounter(); PC.CategoryName = "Process"; PC.CounterName = "Working Set - Private"; PC.InstanceName = Process.GetCurrentProcess().ProcessName; Console.WriteLine("TESTING: page max({0}) record count({1})", mergeMax, size); var basename = "RazorDbTests.IndexingTests"; var rand = new Random((int)DateTime.Now.Ticks); var indexHash = new Dictionary <ByteArray, byte[]>(); var itemKeyLen = 35; var kvsName = string.Format("MergeTableTiming_{0}_{1}", mergeMax, DateTime.Now.Ticks); var sw = new Stopwatch(); sw.Start(); using (var testKVS = new KeyValueStore(Path.Combine(basename, kvsName))) { // add a bunch of values that look like indexes for (int r = 0; r < size; r++) { var indexLen = (int)(DateTime.Now.Ticks % 60) + 50; var indexKeyBytes = dataset[r]; var valuekeyBytes = indexKeyBytes.Skip(indexKeyBytes.Length - itemKeyLen).ToArray(); testKVS.Set(indexKeyBytes, valuekeyBytes); // old style index indexHash.Add(new ByteArray(valuekeyBytes), indexKeyBytes); } TableManager.RunTableMergePass(testKVS); } sw.Stop(); var memsize = Convert.ToInt32(PC.NextValue()) / (int)(1024); Console.WriteLine("Total processing time: {0} entries {1} mergeSz {2} MEMORY: {3}", size, mergeMax, sw.Elapsed.ToString(), memsize); Console.WriteLine(); PC.Close(); PC.Dispose(); }
public void AddObjectsAndLookupWithMixedCase() { string path = Path.GetFullPath("TestData\\AddObjectsAndLookupWithMixedCase"); if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); var timer = new Stopwatch(); using (var db = new KeyValueStore(path)) { db.Truncate(); int totalSize = 0; db.Manifest.Logger = msg => Console.WriteLine(msg); var indexed = new SortedDictionary <string, byte[]>(); int num_items = 1000000; timer.Start(); for (int i = 0; i < num_items; i++) { indexed["Mod"] = BitConverter.GetBytes(i % 100); db.Set(BitConverter.GetBytes(i), BitConverter.GetBytes(i * 1000), indexed); totalSize += 8 + 4; } timer.Stop(); Console.WriteLine("Wrote data (with indexing) at a throughput of {0} MB/s", (double)totalSize / timer.Elapsed.TotalSeconds / (1024.0 * 1024.0)); timer.Reset(); timer.Start(); var ctModZeros = db.Find("mod", BitConverter.GetBytes((int)0)).Count(); timer.Stop(); Assert.AreEqual(10000, ctModZeros); Console.WriteLine("Scanned index at a throughput of {0} items/s", (double)ctModZeros / timer.Elapsed.TotalSeconds); } }
/// <summary> /// Creates a new app and a master fork /// On success sets the app id /// </summary> /// <param name="appId"></param> /// <param name="name"></param> /// <param name="description"></param> public void CreateApp(int appId, string name, string description) { var bytesAppIds = KeyValueStore.Get(KeyValueStore.DefaultType, KeyGenerator.AppsKey, null); List <int> appIds = null; if (bytesAppIds != null) { appIds = (List <int>)BinarySerializerHelper.DeserializeObject(bytesAppIds); } else { appIds = new List <int>(); KeyValueStore.Set(KeyValueStore.DefaultType, KeyGenerator.AppsKey, BinarySerializerHelper.SerializeObject(appIds), null); } if (appIds.Contains(appId)) { throw new ArgumentException(nameof(appId)); } appIds.Add(appId); KeyValueStore.Set(KeyValueStore.DefaultType, KeyGenerator.AppsKey, BinarySerializerHelper.SerializeObject(appIds), null); var res = new App { Id = appId, Name = name, Description = description }; KeyValueStore.Set(KeyValueStore.DefaultType, KeyGenerator.GenerateAppKey(appId), ProtoBufSerializerHelper.Serialize(res), null); KeyValueStore.Set(KeyValueStore.DefaultType, KeyGenerator.GenerateForksKey(appId), BinarySerializerHelper.SerializeObject(new List <int>()), null); SetApp(appId); CreateMasterFork(); }
public SpookOracle(Spook cli, Nexus nexus, Logger logger) : base(nexus) { this._cli = cli; nexus.Attach(this); platforms = new KeyValueStore <string, string>(CreateKeyStoreAdapter(StorageConst.Platform.ToString())); this.logger = logger; logger.Message("Platform count: " + platforms.Count); var nexusPlatforms = (nexus as Nexus).GetPlatforms(nexus.RootStorage); foreach (var nexusPlatform in nexusPlatforms) { if (!platforms.ContainsKey(nexusPlatform)) { platforms.Set(nexusPlatform, nexusPlatform); } _keyValueStore.Add(nexusPlatform + StorageConst.Block, new KeyValueStore <string, InteropBlock>(CreateKeyStoreAdapter(nexusPlatform + StorageConst.Block))); _keyValueStore.Add(nexusPlatform + StorageConst.Transaction, new KeyValueStore <string, InteropTransaction>(CreateKeyStoreAdapter(nexusPlatform + StorageConst.Transaction))); _keyValueStore.Add(nexusPlatform + StorageConst.CurrentHeight, new KeyValueStore <string, string>(CreateKeyStoreAdapter(nexusPlatform + StorageConst.CurrentHeight))); } }
public IEnumerator B_プリミティブ型の値を取得できる() { PlayerPrefs.SetInt(Key + "Bool", 1); PlayerPrefs.SetInt(Key + "Int", 2); PlayerPrefs.SetFloat(Key + "Float", 100.0f); PlayerPrefs.SetString(Key + "String", "string value"); yield return(KeyValueStore .Get <bool>(Key + "Bool") .ToCoroutine(x => Assert.That(x, Is.True))); yield return(KeyValueStore .Get <int>(Key + "Int") .ToCoroutine(x => Assert.That(x, Is.EqualTo(2)))); yield return(KeyValueStore .Get <float>(Key + "Float") .ToCoroutine(x => Assert.That(x, Is.EqualTo(100.0f)))); yield return(KeyValueStore .Get <string>(Key + "String") .ToCoroutine(x => Assert.That(x, Is.EqualTo("string value")))); }
public IEnumerator B_プリミティブ型の値を設定できる() { yield return(KeyValueStore .Set(Key + "Bool", true) .ToCoroutine()); yield return(KeyValueStore .Set(Key + "Int", 2) .ToCoroutine()); yield return(KeyValueStore .Set(Key + "Float", 100.0f) .ToCoroutine()); yield return(KeyValueStore .Set(Key + "String", "string value") .ToCoroutine()); Assert.That(PlayerPrefs.GetInt(Key + "Bool") == 1, Is.True); Assert.That(PlayerPrefs.GetInt(Key + "Int"), Is.EqualTo(2)); Assert.That(PlayerPrefs.GetFloat(Key + "Float"), Is.EqualTo(100.0f)); Assert.That(PlayerPrefs.GetString(Key + "String"), Is.EqualTo("string value")); }
public void SetUp(RawlerBase rawler) { if (string.IsNullOrEmpty(this.ConsumerKey) || string.IsNullOrEmpty(this.ConsumerSecret)) { if (KeyValueStore.ContainsKey(rawler, "ConsumerKey", "ConsumerSecret")) { this.ConsumerKey = KeyValueStore.GetValueByKey(rawler, "ConsumerKey"); this.ConsumerSecret = KeyValueStore.GetValueByKey(rawler, "ConsumerSecret"); ReportManage.Report(rawler, "KeyValueStoreからのAPI Keyを使います", true, true); } else if (string.IsNullOrEmpty(SetTwitterApiKeys.consumerKey) || string.IsNullOrEmpty(SetTwitterApiKeys.consumerSecret)) { this.ConsumerKey = "gHVupgapEXlTZdu7rf3oOg"; this.ConsumerSecret = "YOicLtW8utx3NJyy88wtzq8QN3ilXeQoEGCPIJNzo"; ReportManage.Report(rawler, "RawlerのAPI Keyを使います", true, true); } else { this.ConsumerKey = SetTwitterApiKeys.consumerKey; this.ConsumerSecret = SetTwitterApiKeys.consumerSecret; } } }
/// <summary> /// Registers Sugar /// </summary> /// <param name="typeMapper">Type Mapper</param> /// <param name="settings">Settings</param> private void RegisterSugar(ITypeMapper typeMapper, KeyValueStore settings) { // Sugar typeMapper.RegisterItem <SugarItem, SugarState, SugarInfo>(this, "Sugar"); // Collidable typeMapper.AttachItemProperty <SugarItem, CollidableProperty>(this, "Sugar Collidable", (i) => { CollidableProperty property = new CollidableProperty(i); // Define mass (Fixed) property.CollisionFixed = true; property.CollisionMass = 0f; // Bind Collision Radius to the Item Radius property.CollisionRadius = i.Radius; i.RadiusChanged += (item, v) => { property.CollisionRadius = v; }; return(property); }); // Visibility typeMapper.AttachItemProperty <SugarItem, VisibleProperty>(this, "Sugar Visible", (i) => { VisibleProperty property = new VisibleProperty(i); // Bind Visibility Radius to the Item Radius property.VisibilityRadius = i.Radius; i.RadiusChanged += (item, v) => { property.VisibilityRadius = v; }; return(property); }); // Collectable typeMapper.AttachItemProperty <SugarItem, SugarCollectableProperty>(this, "Sugar Collectable"); // TODO: Amounts (SugarMaxCapacity, Math.Min(SugarMaxCapacity, amount)) }
public override void Execute(KeyValueStore <T> model, Action <Event> eventHandler) { model.Remove(Key, ExpectedVersion); }
/// <summary> /// Loads the logger's settings from the config file /// </summary> public static void LoadSettings() { settingsFile = new KeyValueStore(Path.Combine(DefaultConnectionManager.SettingsFolder, "XmppLoggerSettings.xml")); Enable = settingsFile.GetItem<bool>("Enable"); LogLevel level; LogLevel = Enum.TryParse(settingsFile.GetItem<string>("LogLevel"), out level) ? level : LogLevel.Info; Recipient = settingsFile.GetItem<string>("Recipient"); EnableDebugLogging = settingsFile.GetItem<bool>("EnableDebugLogging"); loaded = true; }
public AccountsController(KeyValueStore<Account> accountStore) { this.accountStore = accountStore; }
public void TestInitialize() { _adapterFactory = _adapterFactory = (name) => { return(new DBPartition(new DebugLogger(), path + name)); }; _testStorage = new KeyValueStore <string, string>(CreateKeyStoreAdapterTest("test")); }
public override int Execute(KeyValueStore <T> model) { return(model.Set(Key, Value, ExpectedVersion)); }
/// <summary> /// Default Constructor. /// </summary> /// <param name="resolver">Reference to the Type Resolver</param> /// <param name="settings">Settings for the current Context</param> /// <param name="random">Randomizer for the current Context</param> public SimulationContext(ITypeResolver resolver, KeyValueStore settings, Random random = null) { Resolver = resolver; Settings = settings; Random = random; }
public BaseController(KeyValueStore<Session> sessionStore) { this.sessionStore = sessionStore; }
/// <summary> /// Loads the ConnectionManagers settings from the specified folder /// </summary> /// <param name="settingsFolder">The folder to use for storing settings</param> public void LoadSettings(string settingsFolder) { applicationDataFolder = settingsFolder; settingsFile = new KeyValueStore(Path.Combine(settingsFolder, "Account.xml")); if (settingsFile != null) { _clusterKey = settingsFile.GetItem<string>("ClusterKey").GetBytesBase64(); //Set up XmppMessagingClient and connect var messagingClient = new XmppMessagingClient() { Username = settingsFile.GetItem<string>("XmppUsername"), Server = settingsFile.GetItem<string>("XmppServer"), Password = settingsFile.GetItem<string>("XmppPassword") }; messagingClients.Add(messagingClient); messagingClient.MessageReceived += messagingClient_MessageReceived; messagingClient.PeerDisconnected += messagingClient_PeerDisconnected; messagingClient.Connect(); var clients = settingsFile.GetItem<IEnumerable<object>>("KnownClients"); if (clients == null) knownClientsCache = new Dictionary<string, ClientInfo>(); else knownClientsCache = clients .Cast<ClientInfo>() .ToDictionary(x => x.JId); logger.Info("Sucessfully loaded settings"); } }