Esempio n. 1
0
        public static CacheHeaderInfo DecodeCacheHeader(byte[] cacheHeader)
        {
            int                offset       = 0;
            string             identityCode = ReadString(cacheHeader, ref offset);
            Guid               cacheId      = ReadGuid(cacheHeader, ref offset);
            CacheTypeOption    cacheType    = ReadEnum <CacheTypeOption>(cacheHeader, ref offset);
            string             subSection   = ReadString(cacheHeader, ref offset);
            int                columnCount  = ReadInt32(cacheHeader, ref offset);
            List <CacheColumn> cacheColumns = new List <CacheColumn>();

            for (int index = 0; index < columnCount; index++)
            {
                string name                  = ReadString(cacheHeader, ref offset);
                int    size                  = ReadInt32(cacheHeader, ref offset);
                int    columnIndex           = ReadInt32(cacheHeader, ref offset);
                CacheDataTypeOption dataType = ReadEnum <CacheDataTypeOption>(cacheHeader, ref offset);
                int extendPropertiesCount    = ReadInt32(cacheHeader, ref offset);
                Dictionary <string, string> extendedProperties = ReadExtendedProperties(cacheHeader, extendPropertiesCount, ref offset);

                cacheColumns.Add(new CacheColumn(columnIndex, name, dataType, size, extendedProperties));
            }

            int headerExtPropCount = ReadInt32(cacheHeader, ref offset);
            Dictionary <string, string> headerExtProperties = ReadExtendedProperties(cacheHeader, headerExtPropCount, ref offset);

            return(new CacheHeaderInfo(identityCode, subSection, cacheId, cacheType, cacheColumns.ToArray(), headerExtProperties));
        }
Esempio n. 2
0
        public CacheHeaderInfo(string identityCode, string subSection, Guid cacheId, CacheTypeOption cacheType, CacheColumn[] columns, Dictionary <string, string> extendedProperties = null)
        {
            this.identityCode = identityCode;
            this.subSection   = subSection;
            this.cacheId      = cacheId;
            this.cacheType    = cacheType;

            this.columns = new Dictionary <string, CacheColumn>();
            foreach (CacheColumn column in columns)
            {
                this.columns.Add(column.Name, column);
            }

            this.extendedProperties = extendedProperties;
        }
Esempio n. 3
0
        public SequenceKeyedCaching LoadSequenceKeyedCache(string identityCode, BarItemType barType, Guid cacheId, CacheTypeOption cacheType)
        {
            CacheHeaderInfo header = cacheReader.RequestHeader(identityCode, barType, cacheId, cacheType);

            cacheReader.RegisterHeader(header);
            return(new SequenceKeyedCaching(header, cacheWriter, cacheReader));
        }
Esempio n. 4
0
 public void Initialize(string identityCode, BarItemType barType, Guid cacheId, CacheTypeOption cacheType)
 {
     if (cacheMode == CacheModeOption.Read || cacheMode == CacheModeOption.ReadWrite)
     {
         cache = SharedCacheFactory.Instance.LoadTimeKeyedCache(identityCode, barType, cacheId, cacheType);
     }
 }
Esempio n. 5
0
        public static string CreateCacheFileName(string cacheFolder, string identityCode, string subSection, Guid cacheId, CacheTypeOption cacheType)
        {
            var cacheFileExtension = AttributeHelper.GetAttribute <CacheFileExtension>(cacheType);

            return(Path.Combine(cacheFolder, cacheId == Guid.Empty? string.Empty: cacheId.ToString(), subSection == null? string.Empty: subSection, string.Concat(RemoveInvalidFilePathCharacters(identityCode, "_"), ".", cacheFileExtension.Extension)));
        }
Esempio n. 6
0
        public CacheHeaderInfo RequestHeader(string identityCode, BarItemType barType, Guid cacheId, CacheTypeOption cacheType)
        {
            string       fileName = FileHelper.CreateCacheFileName(cacheFolder, identityCode, barType.Code, cacheId, cacheType);
            BinaryReader reader   = new BinaryReader(File.Open(fileName, FileMode.Open));

            int             dataPosition = 0;
            CacheHeaderInfo headerInfo   = FileHelper.ReadBinaryFileHeader(reader, ref dataPosition);

            reader.Close();
            return(headerInfo);
        }