﻿// Decompiled with JetBrains decompiler
// Type: MongoDB.Bson.Serialization.Conventions.TypeRepresentationSerializationOptionsConvention
// Assembly: MongoDB.Bson, Version=1.6.1.21837, Culture=neutral, PublicKeyToken=f686731cfb9cc103
// MVID: 93880221-3735-46FB-8891-84D897158E28
// Assembly location: C:\Users\CGA Computer\Desktop\LEGO Universe Stuff\LOCO Server\Unity Web Player Extractor\Saved Files\LOCO Server.unity3d_unpacked\MongoDB.Bson.dll

using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Options;
using System;
using System.Reflection;

namespace MongoDB.Bson.Serialization.Conventions
{
  public class TypeRepresentationSerializationOptionsConvention : ISerializationOptionsConvention
  {
    private readonly Type _type;
    private readonly BsonType _representation;

    public TypeRepresentationSerializationOptionsConvention(Type type, BsonType representation)
    {
      this._type = type;
      this._representation = representation;
    }

    public IBsonSerializationOptions GetSerializationOptions(MemberInfo memberInfo)
    {
      PropertyInfo propertyInfo = memberInfo as PropertyInfo;
      if (propertyInfo != null && propertyInfo.PropertyType == this._type)
        return (IBsonSerializationOptions) new RepresentationSerializationOptions(this._representation);
      FieldInfo fieldInfo = memberInfo as FieldInfo;
      if (fieldInfo != null && fieldInfo.FieldType == this._type)
        return (IBsonSerializationOptions) new RepresentationSerializationOptions(this._representation);
      return (IBsonSerializationOptions) null;
    }
  }
}
