当前位置: 首页>>代码示例>>C#>>正文


C# Linq.JObject类代码示例

本文整理汇总了C#中Newtonsoft.Json.Linq.JObject的典型用法代码示例。如果您正苦于以下问题:C# JObject类的具体用法?C# JObject怎么用?C# JObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JObject类属于Newtonsoft.Json.Linq命名空间,在下文中一共展示了JObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BetRequest

		public static int BetRequest(JObject jsonState)
		{
			int bet = 0;
			var gameState = JsonConvert.DeserializeObject<GameState>(jsonState.ToString());
            try
			{
				string actualDecision = "none";
				Logger.LogHelper.Log("type=bet_begin action=bet_request request_id={0} game_id={1}", requestId, gameState.GameId);

				foreach (IDecisionLogic decisionLogic in Decisions.DecisionFactory.GetDecisions())
                {
                    //végigpróbáljuk a lehetőségeket
                    int? possibleBet = decisionLogic.MakeADecision(gameState);
                    if (possibleBet.HasValue)
                    {
                        bet = possibleBet.Value;
						actualDecision = decisionLogic.GetName();
                        break;
                    }
				}

				string cards = String.Join(",", gameState.OwnCards);
				Logger.LogHelper.Log("type=bet action=bet_request request_id={0} game_id={1} bet={2} cards={3} decision={4}",
					requestId, gameState.GameId, bet, cards, actualDecision);
            }
            catch (Exception ex)
            {
				Logger.LogHelper.Error("type=error action=bet_request request_id={0} game_id={1} error_message={2}",requestId, gameState.GameId, ex);
            }

			return bet;
		}
开发者ID:kronomanta,项目名称:poker-player-smart-fox,代码行数:32,代码来源:PokerPlayer.cs

示例2: HasRed

 private static bool HasRed(JObject jObject)
 {
     return jObject.Properties()
         .Select(x => x.Value)
         .OfType<JValue>()
         .Any(x => x.Value<string>() == "red");
 }
开发者ID:navoznov,项目名称:AdventOfCode,代码行数:7,代码来源:Program.cs

示例3: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     Response.Clear();
     var obj = new JObject(new JProperty("machineName", ServerManager.MachineName), new JProperty("servers", JArray.FromObject(ServerManager.GetActiveServerList())));
     Response.BinaryWrite(Encoding.UTF8.GetBytes(obj.ToString()));
     Response.End();
 }
开发者ID:nasimsvce,项目名称:planning-poker,代码行数:7,代码来源:ServerList.aspx.cs

示例4: ReadElement

        public IEnumerable<JObject> ReadElement(IAixmConverter converter, JObject currentObject, XElement element)
        {
            currentObject.AddToProperties("elevation", JObject.FromObject(element));

            //If not a feature return null;
            return Enumerable.Empty<JObject>();
        }
开发者ID:s-innovations,项目名称:S-Innovations.Aixm,代码行数:7,代码来源:AIXMElevationConvtertor.cs

示例5: ItemListStatic

 public ItemListStatic(JObject basicO,
     JObject dataO,
     JArray groupsA,
     JArray treeA,
     string type,
     string version,
     JObject originalObject)
 {
     data = new Dictionary<string, ItemStatic>();
     groups = new List<GroupStatic>();
     tree = new List<ItemTreeStatic>();
     if (basicO != null)
     {
         basic = HelperMethods.LoadBasicDataStatic(basicO);
     }
     if (dataO != null)
     {
         LoadData(dataO.ToString());
     }
     if (groupsA != null)
     {
         LoadGroups(groupsA);
     }
     if (treeA != null)
     {
         LoadTree(treeA);
     }
     this.type = type;
     this.version = version;
     this.originalObject = originalObject;
 }
开发者ID:mattregul,项目名称:CreepScore,代码行数:31,代码来源:ItemListStatic.cs

示例6: ToJSON

        public static JObject ToJSON(this QueryResult myQueryResult)
        {
            // root element...
            var _Query = new JObject();

            // query --------------------------------
            _Query.Add(new JProperty("query", myQueryResult.Query));

            // result -------------------------------
            _Query.Add(new JProperty("result", myQueryResult.ResultType.ToString()));

            // duration -----------------------------
            _Query.Add(new JProperty("duration", new JArray(myQueryResult.Duration, "ms")));

            // warnings -----------------------------
            _Query.Add(new JProperty("warnings", new JArray(
                from _Warning in myQueryResult.Warnings
                select new JObject(
                         new JProperty("code", _Warning.GetType().ToString()),
                         new JProperty("description", _Warning.ToString())
                       ))));

            // errors -------------------------------
            _Query.Add(new JProperty("errors", new JArray(
                from _Error in myQueryResult.Errors
                select new JObject(
                         new JProperty("code", _Error.GetType().ToString()),
                         new JProperty("description", _Error.ToString())
                       ))));

            // results ------------------------------
            _Query.Add(new JProperty("results", new JArray(GetJObjectsFromResult(myQueryResult.Vertices))));

            return _Query;
        }
开发者ID:ipbi,项目名称:sones,代码行数:35,代码来源:JSON_IO_Extensions.cs

示例7: GetTypeFromJObject

		private IElasticCoreType GetTypeFromJObject(JObject po, JsonSerializer serializer)
		{
			JToken typeToken;
			serializer.TypeNameHandling = TypeNameHandling.None;
			if (po.TryGetValue("type", out typeToken))
			{
				var type = typeToken.Value<string>().ToLowerInvariant();
				switch (type)
				{
					case "string":
						return serializer.Deserialize(po.CreateReader(), typeof(StringMapping)) as StringMapping;
					case "float":
					case "double":
					case "byte":
					case "short":
					case "integer":
					case "long":
						return serializer.Deserialize(po.CreateReader(), typeof(NumberMapping)) as NumberMapping;
					case "date":
						return serializer.Deserialize(po.CreateReader(), typeof(DateMapping)) as DateMapping;
					case "boolean":
						return serializer.Deserialize(po.CreateReader(), typeof(BooleanMapping)) as BooleanMapping;
					case "binary":
						return serializer.Deserialize(po.CreateReader(), typeof(BinaryMapping)) as BinaryMapping;
				}
			}
			return null;
		}
开发者ID:BiYiTuan,项目名称:elasticsearch-net,代码行数:28,代码来源:ElasticCoreTypeConverter.cs

示例8: PackInclude_is_null_when_it_is_not_set_in_the_ProjectJson

        public void PackInclude_is_null_when_it_is_not_set_in_the_ProjectJson()
        {
            var json = new JObject();
            var project = GetProject(json);

            project.PackOptions.PackInclude.Should().BeNull();
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:7,代码来源:GivenThatIWantToCreateIncludeEntriesFromJson.cs

示例9: CreateEDDNMessage

        public JObject CreateEDDNMessage(JournalFSDJump journal)
        {
            if (!journal.HasCoordinate)
                return null;

            JObject msg = new JObject();

            msg["header"] = Header();
            msg["$schemaRef"] = "http://schemas.elite-markets.net/eddn/journal/1/test";

            JObject message = new JObject();

            message["StarSystem"] = journal.StarSystem;
            message["Government"] = journal.Government;
            message["timestamp"] = journal.EventTimeUTC.ToString("yyyy-MM-ddTHH:mm:ssZ");
            message["Faction"] = journal.Faction;
            message["Allegiance"] = journal.Allegiance;
            message["StarPos"] = new JArray(new float[] { journal.StarPos.X, journal.StarPos.Y, journal.StarPos.Z });
            message["Security"] = journal.Security;
            message["event"] = journal.EventTypeStr;
            message["Economy"] = journal.Economy;

            msg["message"] = message;
            return msg;
        }
开发者ID:amatos,项目名称:EDDiscovery,代码行数:25,代码来源:EDDNClass.cs

示例10: FromJson

        internal static XbmcAlbum FromJson(JObject obj)
        {
            if (obj == null)
            {
                return null;
            }

            try
            {
                return new XbmcAlbum(JsonRpcClient.GetField<int>(obj, "albumid"),
                                     JsonRpcClient.GetField<string>(obj, "thumbnail"),
                                     JsonRpcClient.GetField<string>(obj, "fanart"),
                                     JsonRpcClient.GetField<string>(obj, "album_title"),
                                     JsonRpcClient.GetField<string>(obj, "album_artist"),
                                     JsonRpcClient.GetField<int>(obj, "year"),
                                     JsonRpcClient.GetField<int>(obj, "album_rating"),
                                     JsonRpcClient.GetField<string>(obj, "album_genre", string.Empty),
                                     JsonRpcClient.GetField<string>(obj, "album_mood", string.Empty),
                                     JsonRpcClient.GetField<string>(obj, "album_theme", string.Empty),
                                     JsonRpcClient.GetField<string>(obj, "album_style", string.Empty),
                                     JsonRpcClient.GetField<string>(obj, "album_type", string.Empty),
                                     JsonRpcClient.GetField<string>(obj, "album_label", string.Empty),
                                     JsonRpcClient.GetField<string>(obj, "album_description", string.Empty));
            }
            catch (Exception ex)
            {
                return null;
            }
        }
开发者ID:koenmetsu,项目名称:xbmc-jsonrpc-sharp,代码行数:29,代码来源:XbmcAlbum.cs

示例11: AddMasterFieldToDataset

        public HttpResponseMessage AddMasterFieldToDataset(JObject jsonData)
        {
            var db = ServicesContext.Current;
            dynamic json = jsonData;

            int DatasetId = json.DatasetId.ToObject<int>();
            var dataset = db.Datasets.Find(DatasetId);

            int FieldId = json.FieldId.ToObject<int>();
            var field = db.Fields.Find(FieldId);

            DatasetField df = new DatasetField();

            df.DatasetId = dataset.Id;
            df.FieldId = field.Id;
            df.FieldRoleId = FieldRole.DETAIL;
            df.CreateDateTime = DateTime.Now;
            df.Label = field.Name;
            df.DbColumnName = field.DbColumnName;
            df.SourceId = 1;
            df.ControlType = field.ControlType;

            db.DatasetFields.Add(df);
            db.SaveChanges();

            return new HttpResponseMessage(HttpStatusCode.OK);
        }
开发者ID:CTUIR,项目名称:cdms-services-e,代码行数:27,代码来源:DatastoreController.cs

示例12: Event

 public Event(int appId, string @event, string entityId, string entityType, string targetEntityId, string targetEntityType, Dictionary<string, object> properties)
 {
     this[Constants.AppId] = appId;
     this[Constants.Event] = @event;
     this[Constants.EntityType] = entityType;
     this[Constants.EntityId] = entityId;
     if (!string.IsNullOrWhiteSpace(targetEntityId))
     {
         this[Constants.TargetEntityId] = targetEntityId;
     }
     if (!string.IsNullOrWhiteSpace(targetEntityType))
     {
         this[Constants.TargetEntityType] = targetEntityType;
     }
     if (properties != null)
     {
         var jProperties = new JObject();
         foreach (var property in properties)
         {
             jProperties[property.Key] = JToken.FromObject(property.Value);
         }
         this[Constants.Properties] = jProperties;
     }
     this[Constants.EventTime] = new DateTimeAdapter().Serialize(DateTime.UtcNow);
 }
开发者ID:vinhdang,项目名称:Sensible.PredictionIO.NET,代码行数:25,代码来源:Event.cs

示例13: newLegend

 JObject newLegend(string[] _legend)
 {
     JObject legend = new JObject(
         new JProperty("data", _legend)
         );
     return legend;
 }
开发者ID:DrZhang,项目名称:GMD_DV,代码行数:7,代码来源:relation_updata.cs

示例14: newCategory

 JObject newCategory(string _category)
 {
     JObject category = new JObject(
         new JProperty("name",_category)
         );
     return category;
 }
开发者ID:DrZhang,项目名称:GMD_DV,代码行数:7,代码来源:relation_updata.cs

示例15: ContentTypeDefinition

 public ContentTypeDefinition(string name, string displayName)
 {
     Name = name;
     DisplayName = displayName;
     Parts = Enumerable.Empty<ContentTypePartDefinition>();
     Settings = new JObject();
 }
开发者ID:adwardliu,项目名称:Orchard2,代码行数:7,代码来源:ContentTypeDefinition.cs


注:本文中的Newtonsoft.Json.Linq.JObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。