本文整理汇总了C#中JsonObject.GetNamedNumber方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.GetNamedNumber方法的具体用法?C# JsonObject.GetNamedNumber怎么用?C# JsonObject.GetNamedNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.GetNamedNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Game
//----------------------------------------------------------------------
public Game( JsonObject aJsonObject )
{
Viewers = Convert.ToInt32( aJsonObject.GetNamedNumber( scViewersString ) );
Channels = Convert.ToInt32( aJsonObject.GetNamedNumber( scChannelsString ) );
var theGameObject = aJsonObject.GetNamedObject( scGameString );
Name = theGameObject.GetNamedString( scNameString );
ImageUrl = theGameObject.GetNamedObject( scImageUrlString ).GetNamedString( scLargeImageUrlString );
}
示例2: SlackChannel
public SlackChannel(JsonObject source)
{
Id = source.GetNamedString("id");
Name = source.GetNamedString("name");
var timestampCreation = (int)source.GetNamedNumber("created");
var offset = DateTimeOffset.FromUnixTimeSeconds(timestampCreation);
Created = offset.DateTime;
IsArchived = source.GetNamedBoolean("is_archived", false);
IsMember = source.GetNamedBoolean("is_member");
MembersCount = (int)source.GetNamedNumber("num_members");
var topicObject = source.GetNamedObject("topic");
Topic = topicObject.GetNamedString("value");
var purposeObject = source.GetNamedObject("purpose");
Purpose = purposeObject.GetNamedString("value");
}
示例3: mapAssessmentJsonToAssessment
public static Assessment mapAssessmentJsonToAssessment(JsonObject assessmentJson)
{
Assessment assessment = new Assessment();
assessment.id = assessmentJson.GetNamedString("id");
assessment.title = assessmentJson.GetNamedString("assessmentTitle");
assessment.subject = assessmentJson.GetNamedString("academicSubject");
assessment.category = assessmentJson.GetNamedString("assessmentCategory");
var studentAssessmentArray = assessmentJson.GetNamedArray("studentAssessmentAssociation");
var studentAssessment = studentAssessmentArray[0].GetObject();
try
{
var startDate = studentAssessment.GetNamedString("administrationDate");
if (startDate != null) assessment.startDate = DateTime.Parse(startDate);
var endDate = studentAssessment.GetNamedString("administrationEndDate");
if (endDate != null) assessment.endDate = DateTime.Parse(endDate);
var scoreResults = studentAssessment.GetNamedArray("scoreResults");
var firstScore = scoreResults[0];
assessment.score = firstScore.GetObject().GetNamedString("result") + "/" + assessmentJson.GetNamedNumber("maxRawScore");
}
catch (Exception e)
{
}
assessment.description = "Bacon ipsum dolor sit amet meatloaf tail doner, sausage pig jowl flank chicken beef ribs drumstick leberkas ham rump ball tip prosciutto. Boudin pig prosciutto, leberkas ball tip meatloaf ham hock hamburger ribeye salami beef jerky. Pork belly pork chop tongue pancetta salami biltong capicola meatloaf prosciutto pastrami sirloin spare ribs. Tri-tip filet mignon tail beef ribs. Biltong flank ribeye short ribs, cow ground round brisket jerky pork.\n\n Turkey frankfurter meatball, shank fatback ball tip boudin shankle chuck. Shankle shoulder shank pig ham turkey brisket pork chop filet mignon. Strip steak sausage turkey, shank fatback filet mignon hamburger jowl. Pig bacon drumstick, swine chicken sausage prosciutto brisket strip steak doner ham pork loin bresaola shank. Doner beef capicola fatback pork belly, pork chop t-bone shank turducken andouille corned beef. Tail turducken sausage andouille chuck kielbasa pig bacon corned beef t-bone flank beef. Tenderloin chicken sirloin, tail swine turkey short ribs tongue meatball capicola ham spare ribs filet mignon kielbasa meatloaf.";
return assessment;
}
示例4: ServiceDescription
public ServiceDescription(JsonObject json)
{
LastDetection = double.MaxValue;
ServiceFilter = json.GetNamedString(KeyFilter);
IpAddress = json.GetNamedString(KeyIpAddress);
Uuid = json.GetNamedString(KeyUuid);
FriendlyName = json.GetNamedString(KeyFriendly);
ModelName = json.GetNamedString(KeyModelName);
ModelNumber = json.GetNamedString(KeyModelNumber);
Port = (int)json.GetNamedNumber(KeyPort);
Version = json.GetNamedString(KeyVersion,"");
ServiceId = json.GetNamedString(KeyServiceId,"");
}
示例5: GetJosnObjectIntegerValue
internal static string GetJosnObjectIntegerValue(JsonObject jsonObject, string key)
{
string reValue = "";
if ((jsonObject == null) || string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
{
return reValue;
}
if (jsonObject.ContainsKey(key))
{
double value = jsonObject.GetNamedNumber(key);
reValue = Convert.ToString((int)value);
}
return reValue;
}
示例6: read
public override Data read(JsonObject obj)
{
Facet facet = new Facet();
try
{
facet.Key = obj.GetNamedString("key");
facet.DisplayName = obj.GetNamedString("displayName");
facet.Count = (uint)obj.GetNamedNumber("count");
}
catch (Exception e)
{
//TODO: log exception
System.Diagnostics.Debug.WriteLine(e.Message);
}
return facet;
}
示例7: ParseRawChannelData
private ChannelInfo ParseRawChannelData(JsonObject channelRawData)
{
string channelName = null;
string channelId = null;
var channelInfo = new ChannelInfo();
channelInfo.RawData = channelRawData;
try
{
if (channelRawData.ContainsKey("channelName"))
channelName = channelRawData.GetNamedString("channelName","");
if (channelRawData.ContainsKey("channelId"))
channelId = channelRawData.GetNamedString("channelId", "");
string channelNumber = channelRawData.GetNamedString("channelNumber", "");
int majorNumber;
if (channelRawData.ContainsKey("majorNumber"))
majorNumber = (int)channelRawData.GetNamedNumber("majorNumber");
else
majorNumber = ParseMajorNumber(channelNumber);
int minorNumber;
if (channelRawData.ContainsKey("minorNumber"))
minorNumber = (int)channelRawData.GetNamedNumber("minorNumber");
else
minorNumber = ParseMinorNumber(channelNumber);
channelInfo.Name = channelName;
channelInfo.Id = channelId;
channelInfo.Number = channelNumber;
channelInfo.MajorNumber = majorNumber;
channelInfo.MinorNumber = minorNumber;
}
catch (Exception e)
{
throw e;
}
return channelInfo;
}
示例8: HandleMessage
protected void HandleMessage(JsonObject message)
{
try
{
var shouldProcess = true;
if (Listener != null)
shouldProcess = Listener.OnReceiveMessage(message);
if (!shouldProcess)
return;
var type = message.GetNamedString("type");
Object payload = 1;
try
{
payload = message.GetNamedObject("payload");
}
// ReSharper disable once EmptyGeneralCatchClause
catch
{
// we will fail when the type is error because payload is not retrievable
}
ServiceCommand request = null;
int id = 0;
if (message.ContainsKey("id"))
{
if (message.ContainsKey("id"))
{
if (message.GetNamedValue("id").ValueType != JsonValueType.String)
{
id = (int)message.GetNamedNumber("id");
}
else
{
var intstr = message.GetNamedString("id");
int.TryParse(intstr, out id);
}
}
try
{
if (Requests.ContainsKey(id))
request = Requests[id];
}
// ReSharper disable once EmptyGeneralCatchClause
catch
{
// since request is assigned to null, don't need to do anything here
}
}
if (type.Length == 0)
return;
if ("response".Equals(type))
{
if (request != null)
{
Logger.Current.AddMessage("Found requests. Need to handle response.");
if (payload != null)
{
try
{
Util.PostSuccess(request.ResponseListenerValue, payload);
}
catch
{
}
}
else
{
try
{
Util.PostError(request.ResponseListenerValue,
new ServiceCommandError(-1, "JSON parse error"));
}
// ReSharper disable once EmptyGeneralCatchClause
catch
{
}
}
if (!(request is UrlServiceSubscription))
{
if (!message.ContainsKey("pairingType"))
{
Requests.Remove(id);
}
}
}
}
else if ("registered".Equals(type))
{
if (!(service.ServiceConfig is WebOsTvServiceConfig))
{
service.ServiceConfig = new WebOsTvServiceConfig(service.ServiceConfig.ServiceUuid);
//.........这里部分代码省略.........
示例9: GameSearchResults
//----------------------------------------------------------------------
public GameSearchResults( JsonObject aJsonObject )
{
Total = Convert.ToInt32( aJsonObject.GetNamedNumber( scTotalString ) );
Links = new Links( aJsonObject.GetNamedObject( scLinksString ) );
var theGameList = new List<Game>();
var theTop = aJsonObject.GetNamedArray( scTopString );
foreach( var theGame in theTop )
{
theGameList.Add( new Game( theGame.GetObject() ) );
}
GamesList = theGameList;
}
示例10: AssignRootTypeDetails
// Depth 0 Assignment (Course)
private static void AssignRootTypeDetails(Course course, JsonObject courseObject)
{
course.ClassNumber = (ushort)courseObject.GetNamedNumber("class_number");
course.CourseCode = courseObject.GetNamedString("course_code");
course.CourseMode = courseObject.GetNamedString("course_mode");
course.CourseOption = courseObject.GetNamedString("course_option");
course.SubjectType = courseObject.GetNamedString("subject_type");
course.Faculty = courseObject.GetNamedString("faculty");
course.Title = courseObject.GetNamedString("course_title");
course.Ltpjc = courseObject.GetNamedString("ltpjc");
course.Credits = (ushort)int.Parse(course.Ltpjc.Substring(4));
}
示例11: ProcessTemperature
private async Task ProcessTemperature(JsonObject json)
{
if (GetResult(json) == 0)
{
// Retrieve the temperature
double temperature = json.GetNamedNumber("Temp");
// Output the temperature
SetTextBlock(txtTemperatureValue, string.Format("{0:0.0} °C", temperature), greenBrush);
}
else
{
SetTextBlock(txtTemperatureValue, METER_DISCONNECTED, redBrush);
}
await Task.Delay(1);
}
示例12: ApplyJSONPortState
private void ApplyJSONPortState(IOBoardController ioBoard, JsonObject value)
{
int port = (int) value.GetNamedNumber("port", 0);
bool state = value.GetNamedBoolean("state", false);
bool commit = value.GetNamedBoolean("commit", true);
ioBoard.SetPortState(port, state ? BinaryState.High : BinaryState.Low);
if (commit)
{
ioBoard.CommitChanges();
}
}
示例13: ServiceConfig
public ServiceConfig(JsonObject json)
{
ServiceUuid = json.GetNamedString(KeyUuid);
LastDetected = json.GetNamedNumber(KeyLastDetect);
}
示例14: FromJson
internal static ReportItem FromJson(JsonObject report)
{
ReportItem item = new ReportItem();
item.NativeId = report.GetNamedString("_id");
item.Title = report.GetNamedString("title");
item.Description = report.GetNamedString("description");
item.Latitude = report.GetNamedNumber("latitude");
item.Longitude = report.GetNamedNumber("longitude");
// return...
return item;
}
示例15: ParseRawChannelData
public static ChannelInfo ParseRawChannelData(JsonObject channelRawData)
{
string channelName = null;
string channelId = null;
var minorNumber = 0;
var majorNumber = 0;
var channelInfo = new ChannelInfo {RawData = channelRawData};
try
{
if (!channelRawData.ContainsKey("channelName"))
channelName = channelRawData.GetNamedString("channelName");
if (!channelRawData.ContainsKey("channelId"))
channelId = channelRawData.GetNamedString("channelId");
if (!channelRawData.ContainsKey("majorNumber"))
majorNumber = (int)channelRawData.GetNamedNumber("majorNumber");
if (!channelRawData.ContainsKey("minorNumber"))
minorNumber = (int)channelRawData.GetNamedNumber("minorNumber");
var channelNumber = !channelRawData.ContainsKey("channelNumber")
? channelRawData.GetNamedString("channelNumber")
: string.Format("{0}-{1}", majorNumber, minorNumber);
channelInfo.Name = channelName;
channelInfo.Id = channelId;
channelInfo.Number = channelNumber;
channelInfo.MajorNumber = majorNumber;
channelInfo.MinorNumber = minorNumber;
}
catch (Exception e)
{
//TODO: get some analysis here
throw new Exception("There was an error parsin the channel information", e);
}
return channelInfo;
}