Example #1
0
        /*******************************************/

        protected string GetCurrentTypeValue(IBsonReader reader)
        {
            // You gotta do what you gotta do. I couldn't really find an easy way to get the type as a string without spending time in the source code of Mongo
            BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
            Type         type      = reader.GetType();

            FieldInfo field = type.GetField("_currentValue", bindFlags);

            if (field == null)
            {
                return("");
            }

            BsonValue value = field.GetValue(reader) as BsonValue;

            if (value == null)
            {
                return("");
            }

            return(value.AsString);
        }