实施净蒙戈外壳的功能外壳、功能、净蒙戈

2023-09-09 21:00:29 作者:命运的齿轮

好奇,我想知道,怎么会有人实现一个自定义蒙戈壳.NET。允许用户做同样的事情,你可以在蒙戈外壳,但实施的.Net与提升用户体验的选项。

Of curiosity, I would like to know, how anyone would implement a custom mongo shell in .Net. allowing the user to do the exact same things as you can in the mongo shell, but implemented in .Net with the option of enhancing the user experience.

我发现这个线程,告诉我,我不能使用官方10gen的司机archieve这样的:Using MongoDB的外壳上MongoDB的10gen公司的司机命令

I have found this thread which tells me, that I cannot use the official 10gen driver to archieve this: Using MongoDB shell commands on MongoDB 10Gen's driver

什么是这样做的适当方法是什么?我想最终的定制解决办法是通过手工转换源$ C ​​$下蒙戈外壳为净?

What is the appropriate way of doing this? I guess the ultimate custom solution would be to convert the source code for the mongo shell into .Net by hand?

任何建议都非常AP preciated因为我一直在使用Google的在相当一段时间的答案。三江源提前!

Any suggestions are very much appreciated as I have been googling for answers in quite some time. Thankyou in advance!

推荐答案

您的要求做同样的事情,你可以在蒙戈贝壳最好的答案取决于你所想的是完全一样的东西是什么

The best answer to your request to "do the exact same things as you can in the mongo shell" depends on what you are thinking of as "exact same things".

目前的最低水平,蒙戈外壳只是发送使用记录连线协议,这是一个有点绕BSON数据,JSON的记录二进制版本/扩展包装的消息。因此,在较低的水平(超过TCP / IP发送邮件),你可以做任何你想要的。

At the lowest level, the mongo shell just sends messages using the documented "wire protocol", which is a bit of wrapping around BSON data, the documented binary version/extension of JSON. So, at a low level (by sending messages over TCP/IP) you can do anything you want.

在一个稍高的水平,蒙戈外壳包括JavaScript的引擎,这在目前发布的版本是SpiderMonkey的1.7版的Mozilla基金会,也是开源的。未来的版本将使用谷歌的V8 JavaScript引擎,再次开源和可供下载。外壳为那些发动机的一些本土code函数使用方法:请参见MongoDB的源$ C ​​$ C engine_spidermonkey.cpp和engine_v8.cpp

At a slightly higher level, the mongo shell includes a JavaScript "engine", which in currently released versions is SpiderMonkey version 1.7 from the Mozilla Foundation, also open source. A future version will use Google's V8 JavaScript engine, again open source and available for download. The shell provides some native code functions for those engines to use: see engine_spidermonkey.cpp and engine_v8.cpp in the MongoDB source code.

在一个更高的水平,壳包括用JavaScript编写的一些辅助功能,简化了输入一些命令。您可以通过键入一个函数调用的名称,并留下关闭的括号看到从shell提示下这些功能:输入睡眠(500),将睡500毫秒,输入休眠将显示,睡眠呼吁nativeHelper。申请(sleep_,参数)。所有这些辅助功能在.js文件中在MongoDB的源$ C ​​$ C,您可以下载壳的目录。

At a still higher level, the shell includes some "helper functions" written in JavaScript that simplify typing some commands. You can see these functions from the shell's prompt by typing the name of a function call and leaving off the parentheses: typing "sleep(500)" will sleep for 500 milliseconds, typing "sleep" will show that "sleep" calls "nativeHelper.apply(sleep_, arguments)". All of these helper functions are in .js files in the "shell" directory in the MongoDB source code, which you can download.

除此之外,还有一个命令行循环,提供命令行编辑和召回,code上调用命令行和code处理参数与服务器读写BSON格式的数据通信,非常类似于C#的驱动程序提供。

Beyond that, there is a command line loop that provides command line editing and recall, code for processing arguments on the invoking command line and code to read and write BSON-formatted data for communication with the server, very similar to what the C# driver provides.

所以,你可以使用任何本code,它是有帮助的,你还是写类似或不同的code自己。确实没有任何魔法隐藏起来,这是所有开源。

So, you can use any of this code that is helpful to you or write similar or different code yourself. There isn't really any magic hidden away, it's all open source.

如果你知道你想要什么来完成,并卡住在如何做一些事情,问你的具体问题的细节,希望你会得到比这少了一个一般性的回答。

If you know what you want to accomplish and get stuck on the details of how to do something, ask your specific question and hopefully you'll get less general answers than this one.