예제 #1
0
        public AseetsConfig LoadConfig(string filePath)
        {
            string[]     lines  = File.ReadAllLines(filePath);
            AseetsConfig config = new AseetsConfig();

            config.DefaultSource = new AssetSource()
            {
                Name = "Default", Location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), k_appUnityFolder)
            };

            foreach (string data in lines)
            {
                char first = data.Length > 0 ? data[0] : '#';
                switch (first)
                {
                case '#':     /// comment line
                    break;

                case '~':     /// Assets source declaration
                    IParser parser = new AssetSourceParser();
                    parser.Parse(data);
                    config.Sources.Add(new AssetSource()
                    {
                        Name = parser.Parsed[1], Location = parser.Parsed[2]
                    });
                    break;

                default:     /// Asset declaration
                    IParser assetparser = new StoredAssetParser();
                    assetparser.Parse(data);

                    config.Dependencies.Add(new StoredAsset()
                    {
                        Storage   = assetparser.Parsed[0],
                        publisher = assetparser.Parsed[1],
                        category  = assetparser.Parsed[2],
                        name      = assetparser.Parsed[3]
                    });
                    break;
                }
            }

            return(config);
        }
예제 #2
0
        public AseetsConfig LoadConfig(string filePath)
        {
            string[] lines = File.ReadAllLines(filePath);
            AseetsConfig config = new AseetsConfig();
            config.DefaultSource = new AssetSource() { Name = "Default", Location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), k_appUnityFolder) };

            foreach (string data in lines)
            {
                char first = data.Length > 0 ? data[0] : '#';
                switch (first)
                {
                    case '#': /// comment line
                        break;
                    case '~': /// Assets source declaration
                        IParser parser = new AssetSourceParser();
                        parser.Parse(data);
                        config.Sources.Add(new AssetSource() { Name = parser.Parsed[1], Location = parser.Parsed[2] });
                        break;

                    default: /// Asset declaration
                        IParser assetparser = new StoredAssetParser();
                        assetparser.Parse(data);

                        config.Dependencies.Add(new StoredAsset()
                        {
                            Storage = assetparser.Parsed[0],
                            publisher = assetparser.Parsed[1],
                            category = assetparser.Parsed[2],
                            name = assetparser.Parsed[3]
                        });
                        break;
                }
            }

            return config;
        }