Exemple #1
0
        public APITemplateVersionSet ConvertYAMLFileToAPIVersionSet(string yamlFileLocation)
        {
            APITemplateVersionSet apiVersionSet = new APITemplateVersionSet();
            // Setup the input
            StreamReader streamReader = new StreamReader(yamlFileLocation);
            // Load the stream
            YamlStream yaml = new YamlStream();

            yaml.Load(streamReader);
            // Examine the stream
            YamlMappingNode mapping = (YamlMappingNode)yaml.Documents[0].RootNode;

            foreach (var entry in mapping.Children)
            {
                string key = ((YamlScalarNode)entry.Key).Value;
                if (key == "apiVersionSet")
                {
                    YamlMappingNode node = (YamlMappingNode)entry.Value;
                    // find the the values from the YAML and set the corresponding properties on the version set object
                    apiVersionSet.id                = (string)node.Children.First(child => (string)child.Key == "id").Value;
                    apiVersionSet.description       = (string)node.Children.First(child => (string)child.Key == "description").Value;
                    apiVersionSet.versionHeaderName = (string)node.Children.First(child => (string)child.Key == "versionHeaderName").Value;
                    apiVersionSet.versioningScheme  = (string)node.Children.First(child => (string)child.Key == "versioningScheme").Value;
                    apiVersionSet.versionQueryName  = (string)node.Children.First(child => (string)child.Key == "versionQueryName").Value;
                }
            }
            return(apiVersionSet);
        }
 public Exception AttemptAPIVersionSetConversion(CLICreatorArguments cliArguments)
 {
     try
     {
         YAMLReader            yamlReader = new YAMLReader();
         APITemplateVersionSet versionSet = yamlReader.ConvertYAMLFileToAPIVersionSet(cliArguments.apiVersionSetFile);
         return(null);
     }
     catch (Exception ex)
     {
         return(ex);
     }
 }