public string GetYaml(YamlType yamlType, Dictionary <string, object> filter = null) { string result = null; var candidates = _yamlInformations.Where(y => y.YamlType == yamlType); if (filter != null) { candidates = candidates.Where(y => y.MatchesFilter(filter)); } else { var candidatesWithoutFilter = candidates.Where(y => y.Filter == null); if (candidatesWithoutFilter.Any()) { candidates = candidatesWithoutFilter; } } if (candidates.Any()) { result = candidates.FirstOrDefault(y => y.Yaml != null && y.DirectlySet)?.Yaml ?? candidates.FirstOrDefault(y => y.YamlUri != null && y.DirectlySet)?.YamlUri.ToString() ?? candidates.FirstOrDefault(y => y.YamlUri != null && !y.DirectlySet)?.YamlUri.ToString(); } if (result == null) { throw new LayersYamlException($"The requested yaml was not found"); } return(result); }
public void Remove(YamlType pYamlType, Yaml_BaseObject pObject) { if (!mCurrentDic.ContainsKey(pYamlType) || mCurrentDic[pYamlType] == null) { return; } mCurrentDic[pYamlType].Remove(pObject); }
public void Add(YamlType pYamlType, Yaml_BaseObject pObject) { if (!mCurrentDic.ContainsKey(pYamlType)) { mCurrentDic.Add(pYamlType, new List <Yaml_BaseObject>()); } mCurrentDic[pYamlType].Add(pObject); }
public void SetYaml(YamlType yamlType, string yaml, Dictionary <string, object> filter = null) { if (yaml.StartsWith("http")) { SetUri(yamlType, yaml, filter); return; } SetString(yamlType, yaml, filter); }
private void SetString(YamlType yamlType, string yaml, Dictionary <string, object> filter = null, bool directlySet = true) { AttachYamlInformation(new YamlInformation { YamlType = yamlType, Yaml = yaml, Filter = filter, DirectlySet = directlySet }); }
private void SetUri(YamlType yamlType, string yamlUri, Dictionary <string, object> filter = null, bool directlySet = true) { try { var uri = new Uri(yamlUri); AttachYamlInformation(new YamlInformation { YamlType = yamlType, YamlUri = uri, Filter = filter, DirectlySet = directlySet }); } catch (Exception ex) { throw new LayersYamlException($"The value suppied '{yamlUri}' is not a valid Uri.", ex); } }
public Yaml_BaseArg(string pFileID, string pFullPath, YamlType pYamlType) { fileID = pFileID; fullPath = pFullPath; yamlType = pYamlType; }
private static void SetDefaultIfProvidedAndNothingSetYet(IYamlSourceController yamlSourceController, string yaml, YamlType type) { if (yaml != null) { try { yamlSourceController.GetYaml(type); } catch { yamlSourceController.SetYaml(type, yaml); } } }
public bool GetEnabledForType(YamlType type) { return(Types.ContainsKey(type) && Types[type]); }