Beispiel #1
0
 public Aheui()
 {
     this.codeSpace = null;
     this.storage = new Storage();
     this._cursor = new Cursor(0, 0);
     this.init();
 }
Beispiel #2
0
 public Aheui(int MinStackSize, int MaxStackSize)
 {
     this.codeSpace = null;
     this.storage = new Storage(MinStackSize, MaxStackSize);
     this._cursor = new Cursor(0, 0);
     this.init();
 }
		public async Task CanOpenAndCloseWithUpdate()
		{
			var storage = await NewStorageAsync();
			var name = storage.Name;

			var str1 = "test1";
			var str2 = "test2";

			var s1 = new MemoryStream(Encoding.UTF8.GetBytes(str1));
			var s2 = new MemoryStream(Encoding.UTF8.GetBytes(str2));

			var writeBatch = new WriteBatch();
			writeBatch.Put("A", s1);
			await storage.Writer.WriteAsync(writeBatch);

			writeBatch = new WriteBatch();
			writeBatch.Put("A", s2);
			await storage.Writer.WriteAsync(writeBatch);

			var fileSystem = storage.StorageState.FileSystem;

			storage.Dispose();


			using (var newStorage = new Storage(new StorageState(name, new StorageOptions())
			{
				FileSystem = fileSystem
			}))
			{
				await newStorage.InitAsync();
				AssertEqual(str2, newStorage.Reader.Read("A"));
			}
		}
Beispiel #4
0
        //new record to be stored
        public Log(Storage.Database db, ILogData data)
            : base(null)
        {
            _id = data.ID;
            using (MemoryStream ms = new MemoryStream(_buffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;
                //todo: add string length checks!!!

                ms.Position = 150;
                bw.Write(data.LogType.ID); //150
                bw.Write(data.Date.ToFileTime()); //154
                bw.Write(data.DataFromDate.ToFileTime()); //162
                bw.Write(data.Encoded); //170
                ms.Position = 180;
                bw.Write(data.GeocacheCode??"");
                ms.Position = 220;
                bw.Write(data.Finder??"");
                ms.Position = 320;
                bw.Write(data.FinderId??"");
                ms.Position = 350;
                bw.Write(data.TBCode??"");
                ms.Position = 380;
                bw.Write(data.Text??"");

                RecordInfo = db.RequestLogRecord(data.ID, _buffer, ms.Position, 100);
            }
            db.LogCollection.Add(this);
        }
		public async Task ShouldRecoverDataFromLogFile()
		{
			var storage = await NewStorageAsync();

			var name = storage.Name;

			var writeBatch = new WriteBatch();
			writeBatch.Put("A", new MemoryStream(Encoding.UTF8.GetBytes("123")));
			writeBatch.Put("B", new MemoryStream(Encoding.UTF8.GetBytes("123")));
			writeBatch.Put("D", new MemoryStream(Encoding.UTF8.GetBytes("123")));
			storage.Writer.WriteAsync(writeBatch).Wait();

			var fileSystem = storage.StorageState.FileSystem;

			storage.Dispose();

			using (var newStorage = new Storage(new StorageState(name, new StorageOptions())
			{
				FileSystem = fileSystem
			}))
			{
				await newStorage.InitAsync();
				
				using(var it = newStorage.Reader.NewIterator(new ReadOptions()))
				{
					it.Seek("C");
					Assert.True(it.IsValid);
					it.Prev();
					Assert.True(it.IsValid);
					Assert.Equal("B", it.Key);
				}
			}
		} 
Beispiel #6
0
        private void createRecord(Storage.Database db, IGeocacheImageData data)
        {
            using (MemoryStream ms = new MemoryStream(DataBuffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;

                ms.Position = 150;
                bw.Write(Utils.Conversion.DateTimeToLong(data.DataFromDate)); //150
                ms.Position = 180;
                bw.Write(data.GeocacheCode ?? "");
                ms.Position = 220;
                bw.Write(data.Url);
                ms.Position = 420;
                bw.Write(data.MobileUrl ?? "");
                ms.Position = 520;
                bw.Write(data.ThumbUrl ?? "");
                ms.Position = 620;
                bw.Write(GetSafeString(620, 800, data.Name) ?? "");
                ms.Position = 800;
                bw.Write(data.Description ?? "");

                RecordInfo = db.RequestGeocacheImageRecord(data.ID, data.GeocacheCode ?? "", DataBuffer, ms.Position, 10);
            }
        }
Beispiel #7
0
        private void createRecord(Storage.Database db, IWaypointData data)
        {
            using (MemoryStream ms = new MemoryStream(DataBuffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;

                ms.Position = 150;
                bw.Write(Utils.Conversion.DateTimeToLong(data.DataFromDate)); //150
                bw.Write((bool)(data.Lat != null)); //158
                bw.Write(data.Lat == null ? (double)0.0 : (double)data.Lat); //159
                bw.Write((bool)(data.Lon != null)); //167
                bw.Write(data.Lon == null ? (double)0.0 : (double)data.Lon); //168
                bw.Write(Utils.Conversion.DateTimeToLong(data.Time)); //176
                bw.Write(data.WPType.ID); //184
                //spare
                ms.Position = 200;
                bw.Write(data.GeocacheCode);
                ms.Position = 240;
                bw.Write(data.Code ?? "");
                ms.Position = 280;
                bw.Write(GetSafeString(280, 500, data.Description) ?? "");
                ms.Position = 500;
                bw.Write(GetSafeString(500, 600, data.Name) ?? "");
                ms.Position = 600;
                bw.Write(data.Url ?? "");
                ms.Position = 700;
                bw.Write(data.UrlName ?? "");
                ms.Position = 800;
                bw.Write(data.Comment ?? "");

                RecordInfo = db.RequestWaypointRecord(data.ID, data.GeocacheCode, DataBuffer, ms.Position, 100);
            }
        }
Beispiel #8
0
		public void Load (string uri)
		{
			string txt = null;

			System.Uri u = new System.Uri (uri);
			Util.Debug ("Fetching file from " + uri);
			if (u.IsFile) {
				txt = Util.LoadFile (u.LocalPath);
			} else if (u.Scheme == System.Uri.UriSchemeHttp) {
				txt = Util.FetchUrl (uri);
			} else {
				throw new Exception
					("Unsupported URI scheme. Only file: and http: " +
					 "URIs understood.");
			}

			if (txt == null)
				throw new Exception ("No content found.");

			storage = new Storage ("memory", "data", null);
			model = new Model (storage);
			if (uri == null)
				uri = "file:///tmp/stdin";
			Redland.Uri baseuri = new Redland.Uri (uri);
			
			parser.ParseStringIntoModel (txt, baseuri, model);
		}
Beispiel #9
0
        private void createRecord(Storage.Database db, ILogData data)
        {
            using (MemoryStream ms = new MemoryStream(DataBuffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;

                ms.Position = 150;
                bw.Write(data.LogType.ID); //150
                bw.Write(Utils.Conversion.DateTimeToLong(data.Date)); //154
                bw.Write(Utils.Conversion.DateTimeToLong(data.DataFromDate)); //162
                bw.Write(data.Encoded); //170
                ms.Position = 180;
                bw.Write(data.GeocacheCode ?? "");
                ms.Position = 220;
                bw.Write(data.Finder ?? "");
                ms.Position = 320;
                bw.Write(data.FinderId ?? "");
                ms.Position = 350;
                bw.Write(data.TBCode ?? "");
                ms.Position = 380;
                bw.Write(data.Text ?? "");

                RecordInfo = db.RequestLogRecord(data.ID, data.GeocacheCode ?? "", DataBuffer, ms.Position, 100);
            }

        }
        public ProjectsController(IHostingEnvironment environment, IConfiguration configuration)
        {
            _storage = new Storage(configuration);

            _environment = environment;
            _configuration = configuration;
        }
        public void Second_pass_should_use_recorded_values_from_previous_pass()
        {
            var storage = new Storage();

            using (var recorder = new RecordingManager(storage))
            {
                var memoryStream = new MemoryStream();

                using (var stream = A.Fake<Stream>(x => x.Wrapping(memoryStream).RecordedBy(recorder)))
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write("Hello world!");
                }

                Assert.That(memoryStream.GetBuffer().Length, Is.Not.LessThanOrEqualTo(0));
            }

            using (var recorder = new RecordingManager(storage))
            {
                var memoryStream = new MemoryStream();
                using (var stream = A.Fake<Stream>(x => x.Wrapping(memoryStream).RecordedBy(recorder)))
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write("Hello world!");
                }

                Assert.That(memoryStream.Length, Is.EqualTo(0));
            }

            foreach (var call in storage.RecordedCalls)
            {
                Console.WriteLine(call.Method.ToString() + " returns: " + call.ReturnValue);
            }
        }
		public async Task CanGetLatestVersion()
		{
			var storage = await NewStorageAsync();
			var name = storage.Name;

			for (int j = 0; j < 3; j++)
			{
				for (int i = 0; i < 65; i++)
				{
					for (int k = 0; k < 4; k++)
					{
						var writeBatch = new WriteBatch();
						writeBatch.Put("A" + k, new MemoryStream(new[] { (byte)i, (byte)k }));
						await storage.Writer.WriteAsync(writeBatch);
					}
				}
			}

			var fileSystem = storage.StorageState.FileSystem;

			storage.Dispose();

			using (var newStorage = new Storage(new StorageState(name, new StorageOptions())
			{
				FileSystem = fileSystem
			}))
			{
				await newStorage.InitAsync();
				var stream = newStorage.Reader.Read("A2");
				Assert.Equal(64, stream.ReadByte());
			}
		}
Beispiel #13
0
        //new record to be stored
        public GeocacheImage(Storage.Database db, IGeocacheImageData data)
            : base(null)
        {
            _id = data.ID;
            using (MemoryStream ms = new MemoryStream(_buffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;
                //todo: add string length checks!!!

                ms.Position = 150;
                bw.Write(data.DataFromDate.ToFileTime()); //150
                ms.Position = 180;
                bw.Write(data.GeocacheCode??"");
                ms.Position = 220;
                bw.Write(data.Url);
                ms.Position = 420;
                bw.Write(data.MobileUrl??"");
                ms.Position = 520;
                bw.Write(data.ThumbUrl??"");
                ms.Position = 620;
                bw.Write(data.Name??"");
                ms.Position = 800;
                bw.Write(data.Description??"");

                RecordInfo = db.RequestGeocacheImageRecord(data.ID, _buffer, ms.Position, 10);
            }
            db.GeocacheImageCollection.Add(this);
        }
Beispiel #14
0
 protected bool IsDataPersisted(String fileName, Storage storageType)
 {
     switch(storageType){
         case Storage.CACHE:
             return File.Exists(Path.Combine(CACHE_DIR, fileName));
         default:
             return File.Exists(Path.Combine(FILES_DIR, fileName));
     }
 }
        public override void Init(int flowCount, long flowRecordCount)
        {
            fileName = Path.Combine(DataDirectory, string.Format("{0}.perst", CollectionName));

            perst = StorageFactory.Instance.CreateStorage();
            perst.SetProperty("perst.multiclient.support", true);
            perst.Open(fileName);

            index = perst.CreateIndex(typeof(long), false);
        }
		public void Login(KZApplication.OnEventHandler onAuthFinish) {
			#if __ANDROID__
			this.kidozenApplication.Authenticate (App.AndroidContext, onAuthFinish);
			#else
			this.kidozenApplication.Authenticate (onAuthFinish);
			#endif
			database = kidozenApplication.Storage["todo"];
			queryDataSource = kidozenApplication.DataSource["QueryTodo"];
			saveDataSource = kidozenApplication.DataSource["AddTodo"];

		}
Beispiel #17
0
 public static void DoDialog(Form parent, Storage storage, string filename)
 {
     var vprogram = new VProgram(filename);
     using (var dlg = new FProject())
     {
         dlg.Text = vprogram.VAssemblies.First().Name;
         foreach (var vass in vprogram.VAssemblies)
             dlg.lstAssemblies.Items.Add(new ProjectAssembly {Name = vass.Name, FullFilename = vass.Filename});
         if (dlg.ShowDialog(parent) == DialogResult.OK)
             dlg.save(storage.ProjectFolder);
     }
 }
     void CreateStorage()
     {
         storage = StorageFactory.Instance.CreateStorage();
     	// create in-memory storage
     	storage.Open(databasePath, 0);
         db = new Database(storage, true);
         db.BeginTransaction();
     	if (db.CreateTable(typeof(EmployeeTable))){
 			Results.Text = "Table Created";
 		} else {
 			Results.Text = "Table Already Exits";
 		}
     	db.CommitTransaction();        	
     }
Beispiel #19
0
 public static void DoDialog(Form parent, Storage storage, VqProgram vqProgram)
 {
     var project = vqProgram.Project;
     using (var dlg = new FProject())
     {
         dlg.Text = project.Name;
         foreach (var vass in project.Assemblies)
             dlg.lstAssemblies.Items.Add(vass);
         foreach (var vass in project.IgnoredAssemblies)
             dlg.lstIgnored.Items.Add(vass);
         foreach (var vass in project.ThirdPartyAssemblies)
             dlg.lst3dParty.Items.Add(vass);
         if (dlg.ShowDialog(parent) == DialogResult.OK)
             dlg.save(storage.ProjectFolder);
     }
 }
 public AdditonalSmartsSettingsProvider()
 {
     _csvFileDescription = new CsvFileDescription
                               {
                                   SeparatorChar = ',',
                                   FirstLineHasColumnNames = true,
                                   EnforceCsvColumnAttribute = true
                               };
     _csvContext = new CsvContext();
     _writequeued = false;
     _storage = new Storage();
     _filename = _storage.CombineDocumentsFullPath(SettingsFileName);
     Read(); // do initial read
     _watcher = new FileSystemWatcher {Path=Path.GetDirectoryName(_filename), Filter  = Path.GetFileName(_filename), NotifyFilter = NotifyFilters.LastWrite};
     _watcher.Changed += OnChanged;
     _watcher.EnableRaisingEvents = true;
 }
Beispiel #21
0
		private void loadSchemas ()
		{
			Assembly ass = Assembly.GetExecutingAssembly ();			
			if (schemaModel == null) {
				System.IO.Stream s = ass.GetManifestResourceStream ("doap.rdf");
				schemaStorage = new Storage ("memory", "schema", null);
				schemaModel = new Model (schemaStorage);
				Encoding e = Encoding.GetEncoding ("utf-8");
				StreamReader r = new StreamReader (s, e);
				string txt = r.ReadToEnd ();
				parser.ParseStringIntoModel (txt, DoapSchemaUri, schemaModel);
			}
			if (style == null) {
				style = new XslTransform ();
				style.Load (new XmlTextReader (ass.GetManifestResourceStream ("style.xsl")),
							new XmlUrlResolver (), 
							ass.Evidence);
			}
		}
Beispiel #22
0
        private void createRecord(Storage.Database db, ILogImageData data)
        {
            using (MemoryStream ms = new MemoryStream(DataBuffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;

                ms.Position = 150;
                bw.Write(Utils.Conversion.DateTimeToLong(data.DataFromDate)); //150
                ms.Position = 180;
                bw.Write(data.LogId ?? "");
                ms.Position = 220;
                bw.Write(data.Url ?? "");
                ms.Position = 420;
                bw.Write(data.Name ?? "");

                RecordInfo = db.RequestLogImageRecord(data.ID, data.LogId ?? "", DataBuffer, ms.Position, 10);
            }
        }
Beispiel #23
0
        private void createRecord(Storage.Database db, IUserWaypointData data)
        {
            using (MemoryStream ms = new MemoryStream(DataBuffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;

                ms.Position = 150;
                bw.Write(Utils.Conversion.DateTimeToLong(data.Date)); //150
                bw.Write(data.Lat); //158
                bw.Write(data.Lon); //166
                ms.Position = 200;
                bw.Write(data.GeocacheCode);
                ms.Position = 220;
                bw.Write(data.Description);

                RecordInfo = db.RequestUserWaypointRecord(data.ID, data.GeocacheCode ?? "", DataBuffer, ms.Position, 50);
            }
        }
Beispiel #24
0
        //new record to be stored
        public Waypoint(Storage.Database db, IWaypointData data)
            : base(null)
        {
            _id = data.ID;
            using (MemoryStream ms = new MemoryStream(_buffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;
                //todo: add string length checks!!!

                ms.Position = 150;
                bw.Write(data.DataFromDate.ToFileTime()); //150
                bw.Write((bool)(data.Lat!=null)); //158
                bw.Write(data.Lat==null ? (double)0.0: (double)data.Lat); //159
                bw.Write((bool)(data.Lon != null)); //167
                bw.Write(data.Lon == null ? (double)0.0 : (double)data.Lon); //168
                bw.Write(data.Time.ToFileTime()); //176
                bw.Write(data.WPType.ID); //188
                //spare
                ms.Position = 200;
                bw.Write(data.GeocacheCode);
                ms.Position = 240;
                bw.Write(data.Code);
                ms.Position = 280;
                bw.Write(data.Description);
                ms.Position = 500;
                bw.Write(data.Name);
                ms.Position = 600;
                bw.Write(data.Url);
                ms.Position = 700;
                bw.Write(data.UrlName);
                ms.Position = 800;
                bw.Write(data.Comment);

                RecordInfo = db.RequestWaypointRecord(data.ID, _buffer, ms.Position, 100);
            }
            db.WaypointCollection.Add(this);
        }
Beispiel #25
0
        //new record to be stored
        public UserWaypoint(Storage.Database db, IUserWaypointData data)
            : base(null)
        {
            _id = data.ID;
            using (MemoryStream ms = new MemoryStream(_buffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;
                //todo: add string length checks!!!

                ms.Position = 150;
                bw.Write(data.Date.ToFileTime()); //150
                bw.Write(data.Lat); //158
                bw.Write(data.Lon); //166
                ms.Position = 200;
                bw.Write(data.GeocacheCode); 
                ms.Position = 220;
                bw.Write(data.Description);

                RecordInfo = db.RequestUserWaypointRecord(data.ID, _buffer, ms.Position, 50);
            }
            db.UserWaypointCollection.Add(this);
        }
Beispiel #26
0
        //new record to be stored
        public LogImage(Storage.Database db, ILogImageData data)
            : base(null)
        {
            _id = data.ID;
            using (MemoryStream ms = new MemoryStream(_buffer))
            using (BinaryWriter bw = new BinaryWriter(ms))
            {
                ms.Position = 0;
                //todo: add string length checks!!!

                ms.Position = 150;
                bw.Write(data.DataFromDate.ToFileTime()); //150
                ms.Position = 180;
                bw.Write(data.LogId??"");
                ms.Position = 220;
                bw.Write(data.Url??"");
                ms.Position = 420;
                bw.Write(data.Name??"");

                RecordInfo = db.RequestLogRecord(data.ID, _buffer, ms.Position, 10);
            }
            db.LogImageCollection.Add(this);
        }
		private void Close()
		{
			if (storage == null)
				return;

			storage.Dispose();
			ClearDatabaseDirectory(storage.Name);
			storage = null;
		}
		private async Task OpenAsync()
		{
			if (!options.UseExistingDatabase)
				Close();

			Debug.Assert(!string.IsNullOrEmpty(options.DatabaseName));
			Debug.Assert(storage == null);

			var filterPolicy = options.BloomBits >= 0 ? new BloomFilterPolicy(options.BloomBits) : null;

			var storageOptions = new StorageOptions
									 {
										 CreateIfMissing = !options.UseExistingDatabase,
										 WriteBatchSize = options.WriteBatchSize,
										 FilterPolicy = filterPolicy,
										 //Comparator = new ByteWiseComparator()
									 };

			if (options.CacheSize > 0)
			{
				storageOptions.CacheSizeInMegabytes = options.CacheSize;
			}

			storage = new Storage(options.DatabaseName, storageOptions);
			await storage.InitAsync();
		}
Beispiel #29
0
        private void AllocServices(JObject config)
        {
#if !NET45
			Notification = new Notification(this, config.ValueUri("notification"));
			PubSubChannel = new PubSubChannel(this, config.ValueUri("pubsub"), config.ValueUri("ws"));
#endif
			Marketplace = new Marketplace(this, marketPlaceUri);
            Queue = new Queue(this, config.ValueUri("queue"));
            Configuration = new Configuration(this, config.ValueUri("config"));
            SmsSender = new SmsSender(this, config.ValueUri("sms"));
            MailSender = new MailSender(this, config.ValueUri("email"));
            Logger = new Logging(this, config.ValueUri("logging"));
            Storage = new Storage(this, config.ValueUri("storage"));
            Files = new Files(this, config.ValueUri("files"));
            Authentication = new Authentication(marketPlaceUri.Host, config.Value<JObject>("authConfig"), this.Name);
            Service = new Service(this, config.ValueUri("service"));
			DataSource = new DataSource(this, config.ValueUri("datasource"));
        }
 private string TrashToString(Storage o)
 {
     RegisterStorage rst = o as RegisterStorage;
     if (rst != null)
         return rst.Name;
     return o.ToString();
 }