Example #1
0
        private static async Task <List <Schema> > TryGetMetadataSchemasAsync(CheckMetadataOptions options)
        {
            if (string.IsNullOrEmpty(options.ServiceMetadataLocation))
            {
                RecordError("No service metadata file location specified.");
                return(null);
            }

            FancyConsole.WriteLine(FancyConsole.ConsoleHeaderColor, "Loading service metadata from '{0}'...", options.ServiceMetadataLocation);

            List <Schema> schemas;

            try
            {
                Uri metadataUrl;
                if (Uri.TryCreate(options.ServiceMetadataLocation, UriKind.Absolute, out metadataUrl))
                {
                    schemas = await ODataParser.ReadSchemaFromMetadataUrlAsync(metadataUrl);
                }
                else
                {
                    schemas = await ODataParser.ReadSchemaFromFileAsync(options.ServiceMetadataLocation);
                }
            }
            catch (Exception ex)
            {
                RecordError("Error parsing service metadata: {0}", ex.Message);
                return(null);
            }

            return(schemas);
        }