/// <exception cref="System.Exception"/> public JAXBContextResolver() { // you have to specify all the dao classes here this.types = new HashSet <Type>(Arrays.AsList(cTypes)); this.context = new JSONJAXBContext(JSONConfiguration.Natural().RootUnwrapping(false ).Build(), cTypes); }
/// <exception cref="System.Exception"/> public JAXBContextResolver() { JAXBContext context; JAXBContext unWrappedRootContext; // you have to specify all the dao classes here Type[] cTypes = new Type[] { typeof(AppInfo), typeof(AppAttemptInfo), typeof(AppAttemptsInfo ), typeof(ClusterInfo), typeof(CapacitySchedulerQueueInfo), typeof(FifoSchedulerInfo ), typeof(SchedulerTypeInfo), typeof(NodeInfo), typeof(UserMetricsInfo), typeof( CapacitySchedulerInfo), typeof(ClusterMetricsInfo), typeof(SchedulerInfo), typeof( AppsInfo), typeof(NodesInfo), typeof(RemoteExceptionData), typeof(CapacitySchedulerQueueInfoList ), typeof(ResourceInfo), typeof(UsersInfo), typeof(UserInfo), typeof(ApplicationStatisticsInfo ), typeof(StatisticsItemInfo) }; // these dao classes need root unwrapping Type[] rootUnwrappedTypes = new Type[] { typeof(NewApplication), typeof(ApplicationSubmissionContextInfo ), typeof(ContainerLaunchContextInfo), typeof(LocalResourceInfo), typeof(DelegationToken ), typeof(AppQueue) }; this.typesContextMap = new Dictionary <Type, JAXBContext>(); context = new JSONJAXBContext(JSONConfiguration.Natural().RootUnwrapping(false).Build (), cTypes); unWrappedRootContext = new JSONJAXBContext(JSONConfiguration.Natural().RootUnwrapping (true).Build(), rootUnwrappedTypes); foreach (Type type in cTypes) { typesContextMap[type] = context; } foreach (Type type_1 in rootUnwrappedTypes) { typesContextMap[type_1] = unWrappedRootContext; } }
/// <summary> /// Returns JSON data for displaying a team's map analysis. /// </summary> /// <param name="teamName"></param> public MapData LoadMapAnalysis(string teamName) { JSONConfiguration config = LoadTeamJSONConfiguration(teamName); QueryGoogleSheets(config, config.GetMapAnalysisBatchQueries()); return(new MapData(config)); }
/// <exception cref="System.Exception"/> public JAXBContextResolver() { // you have to specify all the dao classes here this.types = new HashSet <Type>(Arrays.AsList(cTypes)); // sets the json configuration so that the json output looks like // the xml output this.context = new JSONJAXBContext(JSONConfiguration.Natural().RootUnwrapping(false ).Build(), cTypes); }
/// <summary> /// Create new JSON schema using given settings /// </summary> /// <param name="configuration">Text encoding, ignore null...</param> public JSONSchema(JSONConfiguration configuration) { var writerDefinition = new WriterDefinition <TEntity>(); var readerDefinition = new ReaderDefinition <TEntity>(); this.configuration = configuration; this.decoderConverter = new DecoderConverter(); this.encoderConverter = new EncoderConverter(); this.decoderDescriptor = new TreeDecoderDescriptor <ReaderState, JSONValue, int, TEntity>(this.decoderConverter, readerDefinition); this.encoderDescriptor = new TreeEncoderDescriptor <WriterState, JSONValue, TEntity>(this.encoderConverter, writerDefinition); }
/// <summary> /// Returns JSON data for displaying a team's shop. /// </summary> /// <param name="teamName"></param> /// <returns></returns> public ShopData LoadShopData(string teamName) { JSONConfiguration config = LoadTeamJSONConfiguration(teamName); if (config.Shop == null) { throw new ShopNotConfiguredException(); } QueryGoogleSheets(config, config.GetShopBatchQueries()); return(new ShopData(config)); }
/// <summary> /// Returns JSON data for displaying a team's convoy. /// </summary> /// <param name="teamName"></param> /// <returns></returns> public ConvoyData LoadConvoyData(string teamName) { JSONConfiguration config = LoadTeamJSONConfiguration(teamName); if (config.Convoy == null) { throw new ConvoyNotConfiguredException(); } QueryGoogleSheets(config, config.GetConvoyBatchQueries()); return(new ConvoyData(config)); }
/// <summary> /// Returns an alphabetical list of team configurations present within the "JSON/TeamConfigs/Active" file directory. /// </summary> /// <returns></returns> public IList <TeamData> LoadTeamList() { IList <TeamData> teams = new List <TeamData>(); //Top directory enumeration foreach (string filePath in Directory.EnumerateFiles("JSON/TeamConfigs/Active")) { JSONConfiguration config = DeserializeJSONConfiguration(filePath); teams.Add(new TeamData(config.Team.Name, (config.Convoy != null), (config.Shop != null))); } return(teams.OrderBy(t => t.TeamName).ToList()); }
public static ConfigSectionNode AsJSONConfig(this object val, ConfigSectionNode dflt = null, string wrapRootName = "azos", ConvertErrorHandling handling = ConvertErrorHandling.ReturnDefault) { string content; try { if (val == null) { return(dflt); } content = val.ToString(); } catch { if (handling != ConvertErrorHandling.ReturnDefault) { throw; } return(dflt); } try { return(JSONConfiguration.CreateFromJson(content).Root); } catch { if (wrapRootName.IsNotNullOrWhiteSpace()) { try { return(JSONConfiguration.CreateFromJson("{'" + wrapRootName + "':\n" + content + "\n}").Root); } catch { if (handling != ConvertErrorHandling.ReturnDefault) { throw; } return(dflt); } } if (handling != ConvertErrorHandling.ReturnDefault) { throw; } return(dflt); } }
public void LaconicJSONRoundtrip() { var conf1 = @" tezt-root='Hahaha\nha!' { types { _override=stop t1='Type1' t2='Type2' } providers { provider1 { type=$(/types/$t1) name='Zhaba' } provider2 { type=$(/types/$t2) name='Koshka' //notice sub-sections with the same name set{ a=123 b=true c=11{da=net}} set{ a=5623 b=false} set{ a=78 b=true} } } }".AsLaconicConfig(); assert(conf1); conf1.ToLaconicString().See(); var map = conf1.Configuration.ToConfigurationJSONDataMap(); var json = map.ToJson(); var cjson = JSONConfiguration.CreateFromJson(json); assert(cjson.Root); json = cjson.SaveToString(JsonWritingOptions.PrettyPrint); json.See(); cjson = JSONConfiguration.CreateFromJson(json); assert(cjson.Root); }
public MapData(JSONConfiguration config) { this.ShowConvoyLink = (config.Convoy != null); this.ShowShopLink = (config.Shop != null); //Process data, order is important on these this.System = new SystemInfo(config.System); this.Map = new MapObj(config.Map, this.System.TerrainTypes, this.System.TerrainEffects); this.Units = UnitsHelper.Process(config.Units, this.System, this.Map); //Calculate unit ranges RangeHelper rangeHelper = new RangeHelper(this.Units, this.Map); rangeHelper.CalculateUnitRanges(); //Clean up this.System.RemoveUnusedObjects(); }
/// <summary> /// Divides the list of <c>Query</c> objects into horizontal and vertical dimension subsets, then executes a batch query on each. /// </summary> /// <param name="config"></param> /// <param name="queries"></param> private void QueryGoogleSheets(JSONConfiguration config, IList <Query> queries) { SheetsService service = new SheetsService(new BaseClientService.Initializer() { ApplicationName = "RedditEmblemAPI", ApiKey = Environment.GetEnvironmentVariable("APIKey") }); ExecuteBatchQuery(service, config.Team.WorkbookID, MajorDimensionEnum.ROWS, queries.Where(q => q != null && q.Orientation == MajorDimensionEnum.ROWS).ToList() ); ExecuteBatchQuery(service, config.Team.WorkbookID, MajorDimensionEnum.COLUMNS, queries.Where(q => q != null && q.Orientation == MajorDimensionEnum.COLUMNS).ToList() ); }
/// <summary> /// Constructor. /// </summary> /// <exception cref="ItemProcessingException"></exception> /// <exception cref="ConvoyItemProcessingException"></exception> public ConvoyData(JSONConfiguration config) { this.Currency = config.System.Currency; this.ShowShopLink = (config.Shop != null); if (config.System.Tags != null) { this.Tags = Tag.BuildDictionary(config.System.Tags); } else { this.Tags = new Dictionary <string, Tag>(); } this.Items = Item.BuildDictionary(config.System.Items, this.Tags); //Build the convoy item list this.ConvoyItems = new List <ConvoyItem>(); foreach (IList <object> row in config.Convoy.Query.Data) { try { IList <string> item = row.Select(r => r.ToString()).ToList(); string name = ParseHelper.SafeStringParse(item, config.Convoy.Name, "Name", false); if (string.IsNullOrEmpty(name)) { continue; } this.ConvoyItems.Add(new ConvoyItem(config.Convoy, item, this.Items)); } catch (Exception ex) { throw new ConvoyItemProcessingException((row.ElementAtOrDefault(config.Convoy.Name) ?? string.Empty).ToString(), ex); } } //Build page parameters IList <ItemSort> sorts = new List <ItemSort>() { new ItemSort("Name", "name", false), new ItemSort("Owner", "owner", false), new ItemSort("Category", "category", true), new ItemSort("Uses", "maxUses", true) }; if (config.System.WeaponRanks.Count > 0) { sorts.Add(new ItemSort("Weapon Rank", "weaponRank", true)); } this.Parameters = new FilterParameters(sorts, new List <string>() { "All" }.Union(this.ConvoyItems.Select(i => i.Owner).Where(o => !string.IsNullOrEmpty(o)).Distinct().OrderBy(o => o)).ToList(), this.ConvoyItems.Select(i => i.Item.Category).Distinct().OrderBy(c => c).ToList(), this.ConvoyItems.SelectMany(i => i.Item.UtilizedStats).Where(s => !string.IsNullOrEmpty(s)).Distinct().OrderBy(c => c).ToList(), new Dictionary <string, bool>()); //Always do this last RemoveUnusedObjects(); }
/// <summary> /// Constructor. /// </summary> /// <exception cref="ItemProcessingException"></exception> /// <exception cref="ShopItemProcessingException"></exception> public ShopData(JSONConfiguration config) { this.Currency = config.System.Currency; this.ShowConvoyLink = (config.Convoy != null); if (config.System.Tags != null) { this.Tags = Tag.BuildDictionary(config.System.Tags); } else { this.Tags = new Dictionary <string, Tag>(); } this.Items = Item.BuildDictionary(config.System.Items, this.Tags); //Build the shop item list this.ShopItems = new List <ShopItem>(); foreach (IList <object> row in config.Shop.Query.Data) { try { IList <string> item = row.Select(r => r.ToString()).ToList(); string name = ParseHelper.SafeStringParse(item, config.Shop.Name, "Name", false); if (string.IsNullOrEmpty(name)) { continue; } this.ShopItems.Add(new ShopItem(config.Shop, item, this.Items)); } catch (Exception ex) { throw new ShopItemProcessingException((row.ElementAtOrDefault(config.Shop.Name) ?? string.Empty).ToString(), ex); } } //Build page parameters IList <ItemSort> sorts = new List <ItemSort>() { new ItemSort("Name", "name", false), new ItemSort("Price", "price", false), new ItemSort("Category", "category", true) }; if (config.System.WeaponRanks.Count > 0) { sorts.Add(new ItemSort("Weapon Rank", "weaponRank", true)); } IDictionary <string, bool> filters = new Dictionary <string, bool>(); filters.Add("AllowNew", (config.Shop.IsNew != -1)); filters.Add("AllowSales", (config.Shop.SalePrice != -1)); this.Parameters = new FilterParameters(sorts, new List <string>(), //shop items don't have owners this.ShopItems.Select(i => i.Item.Category).Distinct().OrderBy(c => c).ToList(), this.ShopItems.SelectMany(i => i.Item.UtilizedStats).Where(s => !string.IsNullOrEmpty(s)).Distinct().OrderBy(c => c).ToList(), filters); //Always do this last. RemoveUnusedObjects(); }