Exemple #1
0
        internal static BuildRoot Parse(string file, string projectDir)
        {
            Wax.Util.JsonParser          parser   = new Wax.Util.JsonParser(file);
            IDictionary <string, object> rootDict = parser.ParseAsDictionary();

            Wax.Util.JsonLookup rootData = new Wax.Util.JsonLookup(rootDict);

            BuildRoot rootOut = new BuildRoot();

            ParseBuildItem(rootOut, rootDict, projectDir);
            List <Target> targets = new List <Target>();

            foreach (IDictionary <string, object> targetRoot in rootData.GetAsList("targets").OfType <IDictionary <string, object> >())
            {
                Target target = new Target();
                ParseBuildItem(target, targetRoot, projectDir);
                targets.Add(target);
            }
            rootOut.Targets = targets.ToArray();
            return(rootOut);
        }
Exemple #2
0
        public static InternalAssemblyMetadata CreateLibrary(string directory, string id)
        {
            Wax.Util.JsonLookup manifest;
            string manifestText = FileUtil.ReadFileText(FileUtil.JoinPath(directory, "manifest.json"));

            try
            {
                manifest = new Wax.Util.JsonLookup(new Wax.Util.JsonParser(manifestText)
                                                   .AddOption(Wax.Util.JsonOption.ALLOW_TRAILING_COMMA)
                                                   .AddOption(Wax.Util.JsonOption.ALLOW_COMMENTS)
                                                   .ParseAsDictionary());
            }
            catch (Wax.Util.JsonParser.JsonParserException jpe)
            {
                throw new System.InvalidOperationException("Syntax error while parsing the library manifest for '" + id + "'.", jpe);
            }

            Locale internalLocale      = Locale.Get(manifest.GetAsString("localization.default", "en"));
            InternalAssemblyMetadata m = new InternalAssemblyMetadata(id, internalLocale, directory);

            IDictionary <string, object> namesByLocale = manifest.GetAsDictionary("localization.names");

            foreach (string localeId in namesByLocale.Keys)
            {
                string name = namesByLocale[localeId] as string;
                m.NameByLocale[localeId] = name ?? m.ID;
            }

            HashSet <Locale> supportedLocales = new HashSet <Locale>(manifest.GetAsDictionary("localization.names").Keys.Select(localeName => Locale.Get(localeName)));

            supportedLocales.Add(m.InternalLocale);
            m.SupportedLocales = supportedLocales.OrderBy(loc => loc.ID).ToArray();

            m.OnlyImportableFrom = new HashSet <string>(manifest.GetAsList("onlyAllowImportFrom").Cast <string>()).ToArray();

            return(m);
        }