Example #1
0
        public EFRegion marshallRegion(string json)
        {
            EFRegion result = null;

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Converters.Add(new RegionConverter());

            result = JsonConvert.DeserializeObject <EFRegion>(json, settings);

            return(result);
        }
Example #2
0
        public async System.Threading.Tasks.Task <EFRegion> requestRegion(String regionName)
        {
            EFRegion region = null;
            IDictionary <string, string> body = new Dictionary <string, string>();

            body["province"] = regionName;

            string jsonResponse = await this.POSTAsync(APIEndPoint.Regions, body);

            region = this._marshaller.marshallRegion(jsonResponse);

            return(region);
        }
 internal RegionFileStream(EFRegion region, string filepath, FileMode mode, 
     FileAccess access, FileShare share)
     : base(filepath,mode,access,share)
 {
     this.region = region;
 }
        EFRegion INTERNAL_readRegionAddrNonExcl(long region_addr)
        {
            lock (region_cache) {
                if (region_cache.ContainsKey(region_addr)) {
                    EFRegion region = region_cache[region_addr].Target;
                    if (region != null) {
                        return region;
                    }

                }

                System.Console.WriteLine(RangemapManager.altdebug_pad + "zz uncached region");
                String filepath = makeFilepath(region_addr);
                if (File.Exists(filepath)) {
                    // open non-exclusive

                    // TODO: FIX THIS HACK, where we figure out the length by opening the file.. it should be passed
                    // in when the region is opened...
                    FileStream reader = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    long length = reader.Length;
                    reader.Close();
                    reader.Dispose();

                    EFRegion newregion = new EFRegion(region_addr, length, filepath, EFRegionMode.READ_ONLY_SHARED);
                    region_cache[region_addr] = new WeakReference<EFRegion>(newregion);

                    return newregion;
                } else {
                    throw new RegionMissingException("no such region address: " + region_addr);
                }
            }
        }