OpenAPI.NET.OData/src/Microsoft.OpenApi.OData.Reader/Vocabulary/Core/ResourceExampleValue.cs
2019-06-25 13:04:59 -07:00

39 lines
1.3 KiB
C#

// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
namespace Microsoft.OpenApi.OData.Vocabulary.Core
{
/// <summary>
/// Base class for <see cref="EntityExampleValue"/> and <see cref="ComplexExampleValue"/>.
/// </summary>
internal abstract class ResourceExampleValue : ExampleValue
{
/// <summary>
/// Gets the Example value for the custom parameter
/// </summary>
public ODataResourceValue Value { get; private set; }
/// <summary>
/// Init the <see cref="ResourceExampleValue"/>
/// </summary>
/// <param name="record">The input record.</param>
public override void Initialize(IEdmRecordExpression record)
{
// Load ExampleValue
base.Initialize(record);
// Value of PrimitiveExampleValue
IEdmPropertyConstructor property = record.FindProperty("Value");
if (property != null)
{
Value = property.Value.Convert() as ODataResourceValue;
}
}
}
}