public static DataTableManifest Create(string csv, int version)
    {
        Dictionary <int, MD5Hash> dictionary = new Dictionary <int, MD5Hash>();
        List <string>             list       = new List <string>();

        using (StringReader stringReader = new StringReader(csv))
        {
            string text;
            while ((text = stringReader.ReadLine()) != null)
            {
                if (!string.IsNullOrEmpty(text))
                {
                    string[] array = text.Split(',');
                    if (array.Length >= 2)
                    {
                        string  text2      = array[0].ToLower();
                        string  hashString = array[1];
                        int     hashCode   = text2.GetHashCode();
                        MD5Hash value      = MD5Hash.Parse(hashString);
                        dictionary.Add(hashCode, value);
                        list.Add(text2);
                    }
                }
            }
        }
        DataTableManifest dataTableManifest = new DataTableManifest();

        dataTableManifest.version   = version;
        dataTableManifest.dict      = dictionary;
        dataTableManifest.fileNames = list;
        return(dataTableManifest);
    }
Ejemplo n.º 2
0
 public void SetupLoadBinary(DataTableManifest manifest, Action <byte[]> processBinary)
 {
     enableLoadBinary            = true;
     processCompressedBinaryData = processBinary;
     hashBinary = manifest.GetTableHash(GetName());
     if (hashBinary == null)
     {
         enableLoadBinary = false;
     }
 }
Ejemplo n.º 3
0
    public void UpdateManifest(Action onComplete)
    {
        int             version         = lastReceiveManifestVersion;
        DataLoadRequest dataLoadRequest = CreateRequest(MANIFEST_NAME, new ManifestVersion(version), DATA_TABLE_DIRECTORY, false);

        dataLoadRequest.processCompressedTextData = delegate(byte[] bytes)
        {
            try
            {
                string csv = DecompressToString(bytes);
                manifest = DataTableManifest.Create(csv, version);
            }
            catch (Exception ex)
            {
                Log.Error(LOG.DATA_TABLE, "manifest load error: {0}", ex.ToString());
                throw;
                IL_0040 :;
            }
        };
        dataLoadRequest.onComplete += onComplete;
        dataLoader.RequestManifest(dataLoadRequest);
    }