Ejemplo n.º 1
0
        public ObjectKey(DataFile file, string name = null, object obj = null)
        {
            Name     = name;
            this.obj = obj;

            if (file != null)
            {
                CompressionMethod = file.CompressionMethod;
                CompressionLevel  = file.CompressionLevel;
                Init(file);
            }
        }
Ejemplo n.º 2
0
 public DataFile GetFile(string name, FileMode mode = FileMode.OpenOrCreate)
 {
     lock (this)
     {
         var dataFile = GetFromCache(name);
         if (dataFile == null)
         {
             Console.WriteLine($"{DateTime.Now} Opening file : {name}");
             dataFile = new DataFile(Path.Combine(this.path, name), this.smanager);
             dataFile.Open(mode);
             this.dataFiles.Add(name, dataFile);
         }
         return(dataFile);
     }
 }
Ejemplo n.º 3
0
        internal void Init(DataFile file, ObjectKey key)
        {
            lock (Sync)
            {
                this.file             = file;
                this.key              = key;
                key.CompressionLevel  = 0;
                key.CompressionMethod = 0;

                // Init dataKey list
                if (this.cachePosition == -1)
                {
                    this.cache    = new IdArray <DataKey>(Math.Max(4096, this.bufferCount));
                    this.cacheKey = new ObjectKey(file, "", new DataKeyIdArray(this.cache));
                }
            }
        }
Ejemplo n.º 4
0
 public void Init(DataFile file)
 {
     this.file = file;
     if (this.obj != null)
     {
         ObjectStreamer streamer;
         file.StreamerManager.Get(this.obj.GetType(), out streamer);
         if (streamer != null)
         {
             TypeId = streamer.TypeId;
         }
         else
         {
             Console.WriteLine($"ObjectKey::Init Can not find streamer for object of type {this.obj.GetType()}");
         }
     }
 }
Ejemplo n.º 5
0
 public FilePortfolioServer(Framework framework, string fileName, string host = null, int port = -1) : base(framework)
 {
     this.host     = host;
     this.port     = port;
     this.dataFile = host == null? new DataFile(fileName, framework.StreamerManager): new NetDataFile(fileName, host, port, framework.StreamerManager);
 }
Ejemplo n.º 6
0
 public FileDataServer(Framework framework, string fileName, string host = null, int port = -1) : base(framework)
 {
     this.host     = host;
     this.dataFile = new DataFile(fileName, framework.StreamerManager);
 }
Ejemplo n.º 7
0
 public FreeKey(DataFile dataFile, long position = -1, int size = -1)
 {
     this.file     = dataFile;
     this.position = position;
     this.length   = size;
 }