internal static object MapToClr()

in src/Readers/Vipr.Reader.OData.v4/ODataVocabularyReader.cs [202:235]


        internal static object MapToClr(IEdmValue value, Type clarifiedType = null)
        {
            switch (value.ValueKind)
            {
                case EdmValueKind.Binary:
                case EdmValueKind.Boolean:
                case EdmValueKind.Date:
                case EdmValueKind.DateTimeOffset:
                case EdmValueKind.Decimal:
                case EdmValueKind.Duration:
                case EdmValueKind.Floating:
                case EdmValueKind.Guid:
                case EdmValueKind.Integer:
                case EdmValueKind.String:
                case EdmValueKind.TimeOfDay:
                {
                    // All of these types of EdmValues expose a .Value parameter which returns an appropriately typed delayedValue 
                    // However, our annotation interface just wants an object. Rather than clutter this code, it's easier to take
                    // a slight reflection cost in the interest of brevity. 
                    return value.GetPropertyByName("Value");
                }
                case EdmValueKind.Collection:
                    return MapToClr(value as IEdmCollectionValue, clarifiedType);
                case EdmValueKind.Structured:
                    // TODO: Refactor structured type generation below and use that code here. 
                case EdmValueKind.Enum: // TODO: Parse enumerations appropriately
                case EdmValueKind.None:
                    // TODO: Find examples of null / none in annotations and either implement or won't fix this gap
                case EdmValueKind.Null:
                default:
//                    Logger.Log($"MapToClr for annotation values is not yet supported for IEdmValue of kind {value.ValueKind}");
                    return null;
            }
        }