本文整理汇总了C#中JsonFx.Json.JsonReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# JsonReader.Read方法的具体用法?C# JsonReader.Read怎么用?C# JsonReader.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonFx.Json.JsonReader
的用法示例。
在下文中一共展示了JsonReader.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractAppRevenueData
public List<dynamic> ExtractAppRevenueData(string appName, string queryString)
{
var revenueData = DistimoService.GetDistimoData(SupportedDistimoApis.Revenues, queryString);
var reader = new JsonReader();
dynamic output = reader.Read(revenueData);
List<dynamic> filteredList = new List<dynamic>();
try
{
foreach (dynamic line in output.lines)
{
string localAppName = line.data.application;
if (localAppName.Contains(appName))
filteredList.Add(line);
}
}
catch (RuntimeBinderException)
{
// too many requests, try again
Thread.Sleep(1100);
return ExtractAppRevenueData(appName, queryString);
}
return filteredList;
}
示例2: handleMessage
public void handleMessage(Message msg)
{
if (msg is CardTypesMessage)
{
JsonReader jsonReader = new JsonReader();
Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["cardTypes"];
this.cardids = new int[d.GetLength(0)];
this.cardnames = new string[d.GetLength(0)];
this.cardImageid = new int[d.GetLength(0)];
for (int i = 0; i < d.GetLength(0); i++)
{
cardids[i] = Convert.ToInt32(d[i]["id"]);
cardnames[i] = d[i]["name"].ToString();
cardImageid[i] = Convert.ToInt32(d[i]["cardImage"]);
}
App.Communicator.removeListener(this);//dont need the listener anymore
}
return;
}
示例3: readJsonfromGoogle
public void readJsonfromGoogle(string txt)
{
JsonReader jsonReader = new JsonReader();
Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(txt);
dictionary = (Dictionary<string, object>)dictionary["feed"];
Dictionary<string, object>[] entrys = (Dictionary<string, object>[])dictionary["entry"];
for (int i = 0; i < entrys.GetLength(0); i++)
{
/*for (int j = 0; j < 4; j++)
{
dictionary = (Dictionary<string, object>)entrys[i]["gsx$r"+(j+1)];
Console.WriteLine((string)dictionary["$t"]);
}*/
dictionary = (Dictionary<string, object>)entrys[i]["gsx$r1"];
if (((string)dictionary["$t"]).ToLower() == "version")
{
dictionary = (Dictionary<string, object>)entrys[i]["gsx$r2"];
this.newestversion=(string)dictionary["$t"];
Console.WriteLine("version string recived");
}
}
}
示例4: handleMessage
public void handleMessage(Message msg)
{
if (msg is RoomEnterMessage)
{
RoomEnterMessage rms = (RoomEnterMessage)msg;
this.nomssg.Add(rms.roomName);
}
if (msg is RoomInfoMessage)
{
Console.WriteLine("joinleave bearbeitet: " + msg.getRawText());
//"removed";
//"updated";
JsonReader jsonReader = new JsonReader();
Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
string roomname = (string)dictionary["roomName"];
if (msg.getRawText().Contains("removed"))
{
Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["removed"];
for (int i = 0; i < d.Length; i++)
{
string ltext = d[i]["name"] + " has left the room";
RoomChatMessageMessage leftmessage = new RoomChatMessageMessage(roomname, "<color=#777460>" + ltext + "</color>");
App.ChatUI.handleMessage(leftmessage);
App.ArenaChat.ChatRooms.ChatMessage(leftmessage);
}
}
if (msg.getRawText().Contains("updated") && this.nomssg.Contains(roomname))
{
nomssg.RemoveAll(item => item == roomname);
}
else
{
if (msg.getRawText().Contains("updated"))
{
Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["updated"];
for (int i = 0; i < d.Length; i++)
{
string ltext = d[i]["name"] + " has joined the room";
RoomChatMessageMessage leftmessage = new RoomChatMessageMessage(roomname, "<color=#777460>" + ltext + "</color>");
App.ChatUI.handleMessage(leftmessage);
App.ArenaChat.ChatRooms.ChatMessage(leftmessage);
}
}
}
}
return;
}
示例5: tryUpdate
public static bool tryUpdate()
{
WebClientTimeOut client = new WebClientTimeOut ();
String versionMessageRaw;
try {
versionMessageRaw = client.DownloadString (new Uri("http://mods.scrollsguide.com/version"));
} catch (WebException) {
return false;
}
JsonReader reader = new JsonReader ();
VersionMessage versionMessage = (VersionMessage)reader.Read (versionMessageRaw, typeof(VersionMessage));
int version = versionMessage.version ();
String installPath = Platform.getGlobalScrollsInstallPath () + Path.DirectorySeparatorChar + "ModLoader" + Path.DirectorySeparatorChar;
try {
File.Delete (installPath + "Updater.exe");
} catch {}
if (!System.IO.Directory.Exists(installPath)) {
System.IO.Directory.CreateDirectory(installPath);
}
if (version > ModLoader.getVersion()) {
byte[] asm;
try {
asm = client.DownloadData(new Uri("http://mods.scrollsguide.com/download/update"));
} catch (WebException) {
return false;
}
File.WriteAllBytes (installPath + "Updater.exe", asm);
if (CheckToken (installPath + "Updater.exe", token)) {
try {
App.Popups.ShowInfo ("Scrolls Summoner is updating", "Please wait while the update is being downloaded");
Dialogs.showNotification("Scrolls Summoner is updating", "Please wait while the update is being downloaded");
} catch { }
if (Platform.getOS () == Platform.OS.Win) {
new Process { StartInfo = { FileName = installPath + "Updater.exe", Arguments = "" } }.Start ();
} else if (Platform.getOS () == Platform.OS.Mac) {
Assembly.LoadFrom (installPath + "Updater.exe").EntryPoint.Invoke (null, new object[] { new string[] {} });
}
return true;
}
try {
App.Popups.KillCurrentPopup();
} catch {}
}
return false;
}
示例6: Encode
public void Encode()
{
var id = new InstrumentData() { Pitch = 31, Roll = 89 };
var x = new JsonWriter();
var js = x.Write(id);
var y = new JsonReader();
var decoded = y.Read<InstrumentData>(js);
Assert.AreEqual(id.Roll, decoded.Roll);
Assert.AreEqual(id.Pitch, decoded.Pitch);
}
示例7: CreateSettings
public ExportationOptions CreateSettings()
{
ExportationOptions result = new ExportationOptions();
string apath = Application.dataPath.Replace("/Assets", "");
string ufile = Path.Combine(apath, "UnityBabylonOptions.ini");
if (File.Exists(ufile))
{
var readText = File.ReadAllText(ufile);
var jsReader = new JsonReader();
result = jsReader.Read<ExportationOptions>(readText);
}
return result;
}
示例8: Read
public static JsonPatchDocument Read(TextReader r)
{
JsonPatchDocument patch = new JsonPatchDocument();
JsonReader jsr = new JsonReader();
CompleteOperation[] operations = null;
try
{
operations = jsr.Read<CompleteOperation[]>(r);
}
catch (DeserializationException ex)
{
throw new JsonPatchParserException(ex.Message, ex);
}
foreach (CompleteOperation operation in operations)
{
try
{
switch (operation.op)
{
case "add":
patch.Add(operation.path, operation.value);
break;
case "remove":
patch.Remove(operation.path);
break;
case "replace":
patch.Replace(operation.path, operation.value);
break;
case "move":
patch.Move(operation.from, operation.path);
break;
case "copy":
patch.Copy(operation.from, operation.path);
break;
case "test":
patch.Test(operation.path, operation.value);
break;
case null:
throw new JsonPatchParserException("No 'op' property found.");
}
}
catch (ArgumentNullException ex)
{
throw new JsonPatchParserException(string.Format("Missing parameter '{0}' for op:'{1}'.", ex.ParamName, operation.op), ex);
}
}
return patch;
}
示例9: UploadStringCompleted
void UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message, "Error", MessageBoxButton.OK);
return;
}
var reader =
new JsonReader(
new DataReaderSettings(
new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.PascalCase)));
var result = reader.Read<RunResult>(e.Result);
_codeEditorViewModel.Output = !string.IsNullOrEmpty(result.CompileError) ? result.CompileError : result.Output;
_codeEditorViewModel.IsRunning = false;
}
示例10: SendPassword
private static string SendPassword(string username, string encryptedBase64, Dictionary<string, object> loginParams)
{
// Send the RSA-encrypted password via POST.
var webRequest = WebRequest.Create(API_DO_LOGIN) as HttpWebRequest;
webRequest.Method = "POST";
var timestamp = loginParams["timestamp"] as string;
var fields = new NameValueCollection();
fields.Add("username", username);
fields.Add("password", encryptedBase64);
fields.Add("emailauth", String.Empty);
fields.Add("captchagid", String.Empty);
fields.Add("captcha_text", String.Empty);
fields.Add("emailsteamid", String.Empty);
fields.Add("rsatimestamp", timestamp);
var query = fields.ConstructQueryString();
var queryData = Encoding.ASCII.GetBytes(query);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = queryData.Length;
webRequest.CookieContainer = new CookieContainer();
// Write the request
using (Stream stream = webRequest.GetRequestStream())
{
stream.Write(queryData, 0, queryData.Length);
}
// Perform the request
var response = webRequest.GetResponse() as HttpWebResponse;
String res;
using (Stream stream = response.GetResponseStream())
{
res = stream.ReadAll();
}
response.Close();
var reader = new JsonReader();
var results = reader.Read<Dictionary<string, object>>(res);
return response.Cookies["steamLogin"].Value;
}
示例11: OnGUI
void OnGUI()
{
if (exportationOptions == null)
{
exportationOptions = new ExportationOptions();
if (File.Exists("Unity3D2Babylon.ini"))
{
var readText = File.ReadAllText("Unity3D2Babylon.ini");
var jsReader = new JsonReader();
exportationOptions = jsReader.Read<ExportationOptions>(readText);
}
}
GUILayout.Label("Exportation options", EditorStyles.boldLabel);
exportationOptions.ReflectionDefaultLevel = EditorGUILayout.Slider("Reflection default level", exportationOptions.ReflectionDefaultLevel, 0, 1.0f);
GUILayout.Label("Collisions options", EditorStyles.boldLabel);
exportationOptions.ExportCollisions = EditorGUILayout.Toggle("Collisions", exportationOptions.ExportCollisions);
exportationOptions.CameraEllipsoid = EditorGUILayout.Vector3Field("Camera's Ellipsoid:", exportationOptions.CameraEllipsoid);
exportationOptions.Gravity = EditorGUILayout.Vector3Field("Gravity:", exportationOptions.Gravity);
EditorGUILayout.Space();
EditorGUILayout.Space();
if (GUILayout.Button("Export"))
{
Export();
}
EditorGUILayout.Space();
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
foreach (var log in logs)
{
var bold = log.StartsWith("*");
GUILayout.Label(bold ? log.Remove(0, 1) : log, bold ? (EditorStyles.boldLabel) : EditorStyles.label);
}
EditorGUILayout.EndScrollView();
Repaint();
}
示例12: ListDownloadStringCompleted
void ListDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null && !string.IsNullOrEmpty(e.Result))
{
var reader = new JsonReader();
var result = reader.Read<IEnumerable<string>>(e.Result);
PopulateMainListBox(result);
}
else
{
var localFiles = e.UserState as string[];
if (localFiles != null && localFiles.Length > 0)
{
PopulateMainListBox(localFiles);
}
else
{
MessageBox.Show("No Saved code was found.");
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
}
}
示例13: Login
public ActionResult Login(string assertion)
{
if (assertion == null)
{
// The 'assertion' key of the API wasn't POSTED. Redirect,
// or whatever you'd like, to try again.
return RedirectToAction("Index", "Home");
}
using (var web = new WebClient())
{
// Build the data we're going to POST.
var data = new NameValueCollection();
data["assertion"] = assertion;
data["audience"] = "http://localhost:46758/"; // Use your website's URL here.
// POST the data to the Persona provider (in this case Mozilla)
var response = web.UploadValues("https://verifier.login.persona.org/verify", "POST", data);
var buffer = Encoding.Convert(Encoding.GetEncoding("iso-8859-1"), Encoding.UTF8, response);
// Convert the response to JSON.
var tempString = Encoding.UTF8.GetString(buffer, 0, response.Length);
var reader = new JsonReader();
dynamic output = reader.Read(tempString);
if (output.status == "okay")
{
string email = output.email; // Since this is dynamic, convert it to string.
FormsAuthentication.SetAuthCookie(email, true);
return RedirectToAction("Index", "Home");
}
return RedirectToAction("Index", "Home");
// Example JSON response.
/*{"status":"okay","email":"[email protected]","audience":"http://localhost:46758/","expires":1349141963794,"issuer":"login.persona.org"}*/
}
}
示例14: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string assertion = string.Empty;
if (!String.IsNullOrEmpty(Request.QueryString["assert"]))
{
assertion = Request.QueryString["assert"];
}
using (var web = new WebClient())
{
// Build the data we're going to POST.
var data = new NameValueCollection();
data["assertion"] = assertion;
//data["audience"] = "http://localhost:55298/"; // Use your web site's URL here.
data["audience"] = "http://www.miramarcommunitycreche.org.nz/"; // Use your web site's URL here.
// POST the data to the Persona provider (in this case Mozilla)
var response = web.UploadValues("https://verifier.login.persona.org/verify", "POST", data);
var buffer = Encoding.Convert(Encoding.GetEncoding("iso-8859-1"), Encoding.UTF8, response);
// Convert the response to JSON.
var tempString = Encoding.UTF8.GetString(buffer, 0, response.Length);
var reader = new JsonReader();
dynamic output = reader.Read(tempString);
if (output.status == "okay")
{
string email = output.email; // Since this is dynamic, convert it to string.
Master.CurrentUserName = email;
Response.Redirect("/default.aspx");
}
else
{
Response.Redirect("/auth/logout.aspx");
}
}
}
示例15: FromString
public static Features FromString(string json)
{
var reader = new JsonReader();
dynamic contents = reader.Read(json);
Features f = new Features();
f.imagefile = contents.imagefile;
//try
{
f.intlines = new List<IntLineFeature>();
foreach (dynamic l in contents.intlines)
{
IntLineFeature lf = new IntLineFeature();
lf.id = l.id;
int[] line = l.line;
lf.line.p.X = l.line[0];
lf.line.p.Y = line[1];
lf.line.q.X = line[2];
lf.line.q.Y = line[3];
f.intlines.Add(lf);
}
}
//catch { } //FIXME: catch the right thing
return f;
}