static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 4 && translator.Assignable <MongoDB.Bson.IO.IBsonChunk>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4))
                {
                    MongoDB.Bson.IO.IBsonChunk _chunk = (MongoDB.Bson.IO.IBsonChunk)translator.GetObject(L, 2, typeof(MongoDB.Bson.IO.IBsonChunk));
                    int  _length     = LuaAPI.xlua_tointeger(L, 3);
                    bool _isReadOnly = LuaAPI.lua_toboolean(L, 4);

                    MongoDB.Bson.IO.SingleChunkBuffer gen_ret = new MongoDB.Bson.IO.SingleChunkBuffer(_chunk, _length, _isReadOnly);
                    translator.Push(L, gen_ret);

                    return(1);
                }
                if (LuaAPI.lua_gettop(L) == 3 && translator.Assignable <MongoDB.Bson.IO.IBsonChunk>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    MongoDB.Bson.IO.IBsonChunk _chunk = (MongoDB.Bson.IO.IBsonChunk)translator.GetObject(L, 2, typeof(MongoDB.Bson.IO.IBsonChunk));
                    int _length = LuaAPI.xlua_tointeger(L, 3);

                    MongoDB.Bson.IO.SingleChunkBuffer gen_ret = new MongoDB.Bson.IO.SingleChunkBuffer(_chunk, _length);
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.IO.SingleChunkBuffer constructor!"));
        }
        static int _m_SetBytes(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.IO.SingleChunkBuffer gen_to_be_invoked = (MongoDB.Bson.IO.SingleChunkBuffer)translator.FastGetCSObj(L, 1);



                {
                    int    _position = LuaAPI.xlua_tointeger(L, 2);
                    byte[] _source   = LuaAPI.lua_tobytes(L, 3);
                    int    _offset   = LuaAPI.xlua_tointeger(L, 4);
                    int    _count    = LuaAPI.xlua_tointeger(L, 5);

                    gen_to_be_invoked.SetBytes(_position, _source, _offset, _count);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
        static int _m_GetSlice(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.IO.SingleChunkBuffer gen_to_be_invoked = (MongoDB.Bson.IO.SingleChunkBuffer)translator.FastGetCSObj(L, 1);



                {
                    int _position = LuaAPI.xlua_tointeger(L, 2);
                    int _length   = LuaAPI.xlua_tointeger(L, 3);

                    MongoDB.Bson.IO.IByteBuffer gen_ret = gen_to_be_invoked.GetSlice(_position, _length);
                    translator.PushAny(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
        static int _s_set_Length(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                MongoDB.Bson.IO.SingleChunkBuffer gen_to_be_invoked = (MongoDB.Bson.IO.SingleChunkBuffer)translator.FastGetCSObj(L, 1);
                gen_to_be_invoked.Length = LuaAPI.xlua_tointeger(L, 2);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(0);
        }
        static int _g_get_IsReadOnly(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                MongoDB.Bson.IO.SingleChunkBuffer gen_to_be_invoked = (MongoDB.Bson.IO.SingleChunkBuffer)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushboolean(L, gen_to_be_invoked.IsReadOnly);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
        static int _m_MakeReadOnly(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.IO.SingleChunkBuffer gen_to_be_invoked = (MongoDB.Bson.IO.SingleChunkBuffer)translator.FastGetCSObj(L, 1);



                {
                    gen_to_be_invoked.MakeReadOnly(  );



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
        static int _m_EnsureCapacity(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.IO.SingleChunkBuffer gen_to_be_invoked = (MongoDB.Bson.IO.SingleChunkBuffer)translator.FastGetCSObj(L, 1);



                {
                    int _minimumCapacity = LuaAPI.xlua_tointeger(L, 2);

                    gen_to_be_invoked.EnsureCapacity(_minimumCapacity);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
        static int _m_AccessBackingBytes(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.IO.SingleChunkBuffer gen_to_be_invoked = (MongoDB.Bson.IO.SingleChunkBuffer)translator.FastGetCSObj(L, 1);



                {
                    int _position = LuaAPI.xlua_tointeger(L, 2);

                    System.ArraySegment <byte> gen_ret = gen_to_be_invoked.AccessBackingBytes(_position);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
        static int _m_SetByte(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.IO.SingleChunkBuffer gen_to_be_invoked = (MongoDB.Bson.IO.SingleChunkBuffer)translator.FastGetCSObj(L, 1);



                {
                    int  _position = LuaAPI.xlua_tointeger(L, 2);
                    byte _value    = (byte)LuaAPI.xlua_tointeger(L, 3);

                    gen_to_be_invoked.SetByte(_position, _value);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }