本文整理汇总了C#中BsonValue.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# BsonValue.GetType方法的具体用法?C# BsonValue.GetType怎么用?C# BsonValue.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonValue
的用法示例。
在下文中一共展示了BsonValue.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BsonValueMemberProvider
public BsonValueMemberProvider(BsonValue value)
{
this.mValue = value;
this.mPropsToWrite = mValue.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(p => !IgnoredProperties.Contains(p.Name) && p.GetIndexParameters().Length == 0)
.ToArray();
}
示例2: ConvertBsonValue
private static object ConvertBsonValue(BsonValue bsonValue, ResourceType resourceType, ResourceProperty resourceProperty, string propertyName, MongoMetadata mongoMetadata)
{
if (bsonValue == null)
return null;
object propertyValue = null;
bool convertValue;
if (bsonValue.GetType() == typeof(BsonDocument))
{
var bsonDocument = bsonValue.AsBsonDocument;
if (IsCsharpNullDocument(bsonDocument))
{
convertValue = false;
}
else
{
propertyValue = CreateDSPResource(bsonDocument, mongoMetadata, propertyName,
MongoMetadata.GetQualifiedTypePrefix(resourceType.Name));
convertValue = true;
}
}
else if (bsonValue.GetType() == typeof(BsonArray))
{
var bsonArray = bsonValue.AsBsonArray;
if (bsonArray != null && bsonArray.Count > 0)
propertyValue = ConvertBsonArray(bsonArray, resourceType, propertyName, mongoMetadata);
convertValue = false;
}
else if (bsonValue.GetType() == typeof(BsonNull) && resourceProperty.Kind == ResourcePropertyKind.Collection)
{
propertyValue = ConvertBsonArray(new BsonArray(0), resourceType, propertyName, mongoMetadata);
convertValue = false;
}
else
{
propertyValue = ConvertRawValue(bsonValue);
convertValue = true;
}
if (propertyValue != null && convertValue)
{
var propertyType = resourceProperty.ResourceType.InstanceType;
Type underlyingNonNullableType = Nullable.GetUnderlyingType(resourceProperty.ResourceType.InstanceType);
if (underlyingNonNullableType != null)
{
propertyType = underlyingNonNullableType;
}
propertyValue = Convert.ChangeType(propertyValue, propertyType);
}
return propertyValue;
}
示例3: ResolveProviderType
private static Type ResolveProviderType(BsonValue elementValue, bool isKey)
{
if (elementValue.GetType() == typeof(BsonArray) || elementValue.GetType() == typeof(BsonDocument))
{
return elementValue.GetType();
}
else if (BsonTypeMapper.MapToDotNetValue(elementValue) != null)
{
return GetRawValueType(elementValue, isKey);
}
else
{
return null;
}
}
示例4: ResolveProviderType
private static Type ResolveProviderType(BsonValue elementValue)
{
if (elementValue.GetType() == typeof(BsonArray) || elementValue.GetType() == typeof(BsonDocument))
{
return elementValue.GetType();
}
else if (elementValue.RawValue != null)
{
switch (elementValue.BsonType)
{
case BsonType.DateTime:
return typeof(DateTime);
default:
return elementValue.RawValue.GetType();
}
}
return null;
}