Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public void Remove(YamlType pYamlType, Yaml_BaseObject pObject)
 {
     if (!mCurrentDic.ContainsKey(pYamlType) || mCurrentDic[pYamlType] == null)
     {
         return;
     }
     mCurrentDic[pYamlType].Remove(pObject);
 }
Exemplo n.º 3
0
 public void Add(YamlType pYamlType, Yaml_BaseObject pObject)
 {
     if (!mCurrentDic.ContainsKey(pYamlType))
     {
         mCurrentDic.Add(pYamlType, new List <Yaml_BaseObject>());
     }
     mCurrentDic[pYamlType].Add(pObject);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 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
     });
 }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
 public Yaml_BaseArg(string pFileID, string pFullPath, YamlType pYamlType)
 {
     fileID   = pFileID;
     fullPath = pFullPath;
     yamlType = pYamlType;
 }
Exemplo n.º 8
0
 private static void SetDefaultIfProvidedAndNothingSetYet(IYamlSourceController yamlSourceController, string yaml, YamlType type)
 {
     if (yaml != null)
     {
         try
         {
             yamlSourceController.GetYaml(type);
         }
         catch
         {
             yamlSourceController.SetYaml(type, yaml);
         }
     }
 }
Exemplo n.º 9
0
 public bool GetEnabledForType(YamlType type)
 {
     return(Types.ContainsKey(type) && Types[type]);
 }