/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using MongoDB.Bson;
namespace MongoDB.Driver
{
///
/// Represents the options parameter for .
///
public abstract class ConvertOptions
{
private ByteOrder? _byteOrder;
private string _format;
private BsonBinarySubType? _subType;
///
/// The byteOrder parameter.
///
public ByteOrder? ByteOrder
{
get => _byteOrder;
set => _byteOrder = value;
}
///
/// The format parameter.
///
public string Format
{
get => _format;
set => _format = value;
}
///
/// The subType parameter.
///
public BsonBinarySubType? SubType
{
get => _subType;
set => _subType = value;
}
internal abstract bool OnErrorWasSet(out object onError);
internal abstract bool OnNullWasSet(out object onNull);
}
///
/// Represents the options parameter for .
/// This class allows to set 'onError' and 'onNull'.
///
/// The type of 'onError' and 'onNull'.
public class ConvertOptions : ConvertOptions
{
private TTo _onError;
private bool _onErrorWasSet;
private TTo _onNull;
private bool _onNullWasSet;
///
/// The onError parameter.
///
public TTo OnError
{
get => _onError;
set
{
_onError = value;
_onErrorWasSet = true;
}
}
///
/// The onNull parameter.
///
public TTo OnNull
{
get => _onNull;
set
{
_onNull = value;
_onNullWasSet = true;
}
}
internal override bool OnErrorWasSet(out object onError)
{
onError = _onError;
return _onErrorWasSet;
}
internal override bool OnNullWasSet(out object onNull)
{
onNull = _onNull;
return _onNullWasSet;
}
}
///
/// Represents the byte order of binary data when converting to/from numerical types using .
///
public enum ByteOrder
{
///
/// Big endian order.
///
BigEndian,
///
/// Little endian order.
///
LittleEndian,
}
}