Exemplo n.º 1
0
        private void _LoadMetadataTemplate <T>(string path) where T : Template, new()
        {
            TemplateTable table = new TemplateTable();

            _mTemplateTables.Add(typeof(T).Name, table);

            var argument = new WebArgument()
            {
                localPath = path,
                flags     = WebFlags.NewWWW
            };

            WebManager.Instance.LoadWebItem(argument, item => {
                using (MemoryStream ms = new MemoryStream(item.bytes))
                    using (OctetsReader br = new OctetsReader(ms))
                    {
                        var count = br.ReadInt32();
                        for (int i = 0; i < count; ++i)
                        {
                            var template = new T();
                            template.Load(br);
                            table.Add(template.id, template);
                        }
                    }
            });
        }
Exemplo n.º 2
0
        public T GetTemplate <T>(int id) where T : Template
        {
            TemplateTable table = GetTemplateTable <T>();
            Template      template;

            if (!table.TryGetValue(id, out template))
            {
                Console.Error.WriteLine("No has id = {0} in {1} Template.", id, typeof(T).Name);
            }

            return(template as T);
        }