Firebase中的c#(API建议) [英] Firebase in c# (API recommendation)

查看:948
本文介绍了Firebase中的c#(API建议)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个firebase数据库做一个简单的程序。但我想在C#中编写我的客户端是否有任何良好的API可用?我发现了一些,但有一些功能不足,我想知道在这些水域有更多经验的人的意见。

相当便于使用的REST API ,您可以使用此从任何支持的平台上的任何.NET语言。 迪娜克鲁兹有一个彻底的例子这个API ,你可以很容易地转换这个信息,并使用BCL中的便携/基本 HttpWebRequest 类型来代替Dina使用的,例如,这是一个从Dina的博客转译第一个POST示例:

$ $ $ $ $ $ $ var $ json = Newtonsoft.Json.JsonConvert.Serialize(new
{
user =UserNameValue,
message =MessageValue,
});
var request = WebRequest.CreateHttp(https://tm-admin-test.firebaseio.com/.json);
request.Method =POST;
request.ContentType =application / json;
var buffer = Encoding.UTF8.GetBytes(json);
request.ContentLength = buffer.Length;
request.GetRequestStream()。Write(buffer,0,buffer.Length);
var response = request.GetResponse();
json =(new StreamReader(response.GetResponseStream()))。ReadToEnd();
// TODO:根据需要解析响应(包含在`json`变量中)

也有几个开源项目,包括 Fire# FirebaseDatabase.net and FirebaseSharp 。我不确定这些是否支持所有的东西。



引用




I am trying to make a simple program using a firebase database. But i would like to code my client in C# is there any good APIs available? I found a few but some are lacking functions and i would like to know the opinion of someone more experienced in these waters.

解决方案

There is a REST API which is fairly portable, and you can use this from any .NET language on any supported platform. Dina Cruz has a thorough example of using this API, and you could easily convert this info and use the portable/basic HttpWebRequest type from the BCL instead of whatever Dina used, for example, this is a transliteration of the first POST example from Dina's blog:

var json = Newtonsoft.Json.JsonConvert.Serialize(new
{
    user = "UserNameValue",
    message = "MessageValue",
});
var request = WebRequest.CreateHttp("https://tm-admin-test.firebaseio.com/.json");
request.Method = "POST";
request.ContentType = "application/json";
var buffer = Encoding.UTF8.GetBytes(json);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
var response = request.GetResponse();
json = (new StreamReader(response.GetResponseStream())).ReadToEnd();
// TODO: parse response (contained in `json` variable) as appropriate

There are also several open source projects including Fire#, FirebaseDatabase.net and FirebaseSharp. I'm not sure if these support "all the things."

References

这篇关于Firebase中的c#(API建议)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆