Exemplo n.º 1
0
        public static void PreloadWrap <K, V>(Dictionary <K, List <V> > maps, byte[] buffer,
                                              MonoBehaviour mono,
                                              Action <IDictionary> onEnd, Action <float> onProcess = null) where V : ConfigBase <K>, new()
        {
            if (maps == null || buffer == null || buffer.Length <= 0 || mono == null)
            {
                if (onEnd != null)
                {
                    onEnd(null);
                }
                return;
            }

            maps.Clear();

            MemoryStream stream = new MemoryStream(buffer);


            Coroutine cor = ConfigWrap.ToObjectListAsync <K, V>(stream, maps, mono, true, onEnd, onProcess);

            if (cor == null)
            {
                stream.Close();
                stream.Dispose();

                if (onEnd != null)
                {
                    onEnd(null);
                }
            }
        }
Exemplo n.º 2
0
        public static void PreloadWrap <K, V>(Dictionary <K, List <V> > maps, byte[] buffer,
                                              MonoBehaviour mono, out bool isJson,
                                              Action <IDictionary> onEnd, Action <float> onProcess = null) where V : ConfigBase <K>, new()
        {
            isJson = false;
            if (maps == null || buffer == null || buffer.Length <= 0 || mono == null)
            {
                if (onEnd != null)
                {
                    onEnd(null);
                }
                return;
            }

            maps.Clear();

            MemoryStream stream = new MemoryStream(buffer);


            Coroutine cor = ConfigWrap.ToObjectListAsync <K, V>(stream, maps, mono, true, onEnd, onProcess);

            if (cor == null)
            {
                stream.Close();
                stream.Dispose();

                Dictionary <K, List <V> > ret;
                try {
                    string text = System.Text.Encoding.UTF8.GetString(buffer);
                    maps   = JsonMapper.ToObject <Dictionary <K, List <V> > >(text);
                    ret    = maps;
                    isJson = true;
                } catch {
                    ret = null;
                }

                if (onEnd != null)
                {
                    onEnd(ret);
                }
            }
        }