-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFireNET.cs
More file actions
54 lines (47 loc) · 1.34 KB
/
Copy pathFireNET.cs
File metadata and controls
54 lines (47 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace FireNET
{
public class FireNET
{
private String root, current;
private System.Net.HttpWebRequest request;
public FireNET(String URL, String auth = null)
{
current = root = URL;
}
public String getRoot()
{
return root;
}
public String getChildren(String child = "")
{
request = System.Net.WebRequest.Create(current + child + ".json") as System.Net.HttpWebRequest;
request.Method = "GET";
request.ContentLength = 0;
using (var response = request.GetResponse() as System.Net.HttpWebResponse)
{
using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
{
return reader.ReadToEnd();
}
}
}
public String getChild(String child)
{
return getChildren(child);
}
public void descend(String child)
{
current += child;
}
public void ascend(String parent)
{
var t = current.LastIndexOf(parent);
current = current.Substring(0, t + parent.Length);
}
}
}