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


C# JObject.Value方法代码示例

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


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

示例1: TryParseDeploymentInfo

        // { 
        //   'format':'basic'
        //   'url':'http://host/repository',
        //   'is_hg':true // optional
        // }
        public override DeployAction TryParseDeploymentInfo(HttpRequestBase request, JObject payload, string targetBranch, out DeploymentInfo deploymentInfo)
        {
            deploymentInfo = null;
            if (!String.Equals(payload.Value<string>("format"), "basic", StringComparison.OrdinalIgnoreCase))
            {
                return DeployAction.UnknownPayload;
            }

            string url = payload.Value<string>("url");
            if (String.IsNullOrEmpty(url))
            {
                return DeployAction.UnknownPayload;
            }

            string scm = payload.Value<string>("scm");
            bool is_hg;
            if (String.IsNullOrEmpty(scm))
            {
                // SSH [email protected] vs [email protected]
                is_hg = url.StartsWith("[email protected]", StringComparison.OrdinalIgnoreCase);
            }
            else
            {
                is_hg = String.Equals(scm, "hg", StringComparison.OrdinalIgnoreCase);
            }

            deploymentInfo = new DeploymentInfo();
            deploymentInfo.RepositoryUrl = url;
            deploymentInfo.RepositoryType = is_hg ? RepositoryType.Mercurial : RepositoryType.Git;
            deploymentInfo.Deployer = GetDeployerFromUrl(url);
            deploymentInfo.TargetChangeset = DeploymentManager.CreateTemporaryChangeSet(message: "Fetch from " + url);

            return DeployAction.ProcessDeployment;
        }
开发者ID:40a,项目名称:kudu,代码行数:39,代码来源:GenericHandler.cs

示例2: Deserialize

        public object Deserialize(JObject obj, JsonSerializer serializer)
        {
            if (obj == null) return null;

            var customField = new IssueCustomField
            {
                Id = obj.Value<int>(RedmineKeys.ID),
                Name = obj.Value<string>(RedmineKeys.NAME),
                Multiple = obj.Value<bool>(RedmineKeys.MULTIPLE)
            };

            var val = obj.Value<object>(RedmineKeys.VALUE);
            var items = serializer.Deserialize(new JTokenReader(val.ToString()), typeof(List<CustomFieldValue>)) as List<CustomFieldValue>;

            customField.Values = items;

            if (items == null) return customField;
            if (customField.Values == null) customField.Values = new List<CustomFieldValue>();

            var list = val as ArrayList;

            if (list != null)
            {
                foreach (string value in list)
                {
                    customField.Values.Add(new CustomFieldValue {Info = value});
                }
            }
            else
            {
                customField.Values.Add(new CustomFieldValue {Info = val as string});
            }

            return customField;
        }
开发者ID:Jopie64,项目名称:redmine-net-api,代码行数:35,代码来源:IssueCustomFieldConverter.cs

示例3: GetDeploymentInfo

        protected override GitDeploymentInfo GetDeploymentInfo(HttpRequestBase request, JObject payload, string targetBranch)
        {
            var info = base.GetDeploymentInfo(request, payload, targetBranch);

            if (info == null)
            {
                return null;
            }

            // CodebaseHq format, see http://support.codebasehq.com/kb/howtos/repository-push-commit-notifications
            var repository = payload.Value<JObject>("repository");
            var urls = repository.Value<JObject>("clone_urls");
            var isPrivate = repository.Value<bool>("private");
            info.NewRef = payload.Value<string>("after");

            if (isPrivate)
            {
                info.RepositoryUrl = urls.Value<string>("ssh");
            }
            else
            {
                // use http clone url if it's a public repo
                info.RepositoryUrl = urls.Value<string>("http");                
            }

            return info;
        }
开发者ID:40a,项目名称:kudu,代码行数:27,代码来源:CodebaseHqHandler.cs

示例4: MigrateAvailability

        bool MigrateAvailability(JObject x)
        {
            // determine our mode
            var a = new Availability();
            var availableToPublic = x.Value<bool>("AvailableToPublic ");
            var availableToAll = x.Value<bool>("AvailableToAllUsers");
            a.Mode = availableToPublic
                ? AvailabilityMode.AvailableToPublic
                : availableToAll 
                    ? AvailabilityMode.AvailableToAllUsers
                    : AvailabilityMode.AvailableOnlyTo;
            
            // copy users & groups arrays if there's any reason to
            if (AvailabilityMode.AvailableOnlyTo == a.Mode)
            {
                var users = x["Users"] as JArray;
                if (null != users)
                {
                    a.Users = users.Select(y => y.Value<string>()).ToArray();
                }
                var groups = x["Groups"] as JArray;
                if (null != groups)
                {
                    a.Groups = groups.Select(y => y.Value<string>()).ToArray();
                }
            }

            x["Availability"] = Session.Serializer.WriteFragment(a);
            return true;
        }
开发者ID:nicknystrom,项目名称:AscendRewards,代码行数:30,代码来源:MigrateFrom0000.cs

示例5: RenewAccessToken

		void RenewAccessToken()
		{
			var postData = new StringBuilder();

			postData.AppendFormat("{0}={1}&", "grant_type", "client_credentials");
			postData.AppendFormat("{0}={1}&", "client_id", HttpUtility.UrlEncode(this.channelSettings.PackageSecurityIdentifier));
			postData.AppendFormat("{0}={1}&", "client_secret", HttpUtility.UrlEncode(this.channelSettings.ClientSecret));
			postData.AppendFormat("{0}={1}", "scope", "notify.windows.com");
			
			var wc = new WebClient();
			wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

			var response = string.Empty;

			response = wc.UploadString("https://login.live.com/accesstoken.srf", "POST", postData.ToString()); 

			var json = new JObject();

			try { json = JObject.Parse(response); }
			catch { }

			var accessToken = json.Value<string>("access_token");
			var tokenType = json.Value<string>("token_type");

			if (!string.IsNullOrEmpty(accessToken) && !string.IsNullOrEmpty(tokenType))
			{
				this.AccessToken = accessToken;
				this.TokenType = tokenType;
			}
			else
			{
				throw new UnauthorizedAccessException("Could not retrieve access token for the supplied Package Security Identifier (SID) and client secret");
			}
		}
开发者ID:StrangerMosr,项目名称:PushSharp,代码行数:34,代码来源:WindowsPushChannel.cs

示例6: Auth

        public void Auth(JObject authData)
        {
            string key;
            User user;

            if(authData == null)
            {
                key = AuthProcessor.GenerateKey();
                user = AuthProcessor.NewAuthUser(key);
            }
            else
            {
                key = authData.Value<string>("key");
                user = AuthProcessor.GetUser(authData.Value<int>("id"));

                if (user == null || user.Key != key) //비정상 계정으로 판단하고 새로운 계정을 발급
                {
                    user = AuthProcessor.NewAuthUser(key);
                }

                user.Key = AuthProcessor.GenerateKey();
                user.Save();
            }

            _id = user.Id;

            //유저에게 바뀐 정보를 전송
            var obj = new JObject();
            obj.Add("type", "auth_data");
            obj.Add("id", user.Id);
            obj.Add("key", user.Key);
            _channel.SendMessage(obj);
        }
开发者ID:shlee322,项目名称:Netronics,代码行数:33,代码来源:Client.cs

示例7: GetPatternsCollection

        public static IEnumerable<string> GetPatternsCollection(JObject rawProject,
                                                                string projectDirectory,
                                                                string projectFilePath,
                                                                string propertyName,
                                                                IEnumerable<string> defaultPatterns = null,
                                                                bool literalPath = false)
        {
            defaultPatterns = defaultPatterns ?? Enumerable.Empty<string>();

            try
            {
                JToken propertyNameToken;
                if (!rawProject.TryGetValue(propertyName, out propertyNameToken))
                {
                    return CreateCollection(projectDirectory, propertyName, defaultPatterns, literalPath);
                }

                if (propertyNameToken.Type == JTokenType.String)
                {
                    return CreateCollection(projectDirectory, propertyName, new string[] { propertyNameToken.Value<string>() }, literalPath);
                }

                if (propertyNameToken.Type == JTokenType.Array)
                {
                    var valuesInArray = propertyNameToken.Values<string>();
                    return CreateCollection(projectDirectory, propertyName, valuesInArray.Select(s => s.ToString()), literalPath);
                }
            }
            catch (Exception ex)
            {
                throw FileFormatException.Create(ex, rawProject.Value<JToken>(propertyName), projectFilePath);
            }

            throw FileFormatException.Create("Value must be either string or array.", rawProject.Value<JToken>(propertyName), projectFilePath);
        }
开发者ID:krwq,项目名称:cli,代码行数:35,代码来源:PatternsCollectionHelper.cs

示例8: OnPut

        public override void OnPut(string key, JObject document, JObject metadata, TransactionInformation transactionInformation)
        {
			if (VersioningContext.IsInVersioningContext)
				return;
			if (key.StartsWith("Raven/", StringComparison.InvariantCultureIgnoreCase))
				return;

			if (excludeByEntityName.Contains(metadata.Value<string>("Raven-Entity-Name")))
				return;

			if (metadata.Value<string>(RavenDocumentRevisionStatus) == "Historical")
				return;

			using(VersioningContext.Enter())
			{
				var copyMetadata = new JObject(metadata);
				copyMetadata[RavenDocumentRevisionStatus] = JToken.FromObject("Historical");
				copyMetadata.Remove(RavenDocumentRevision);
				var parentRevision = metadata.Value<string>(RavenDocumentRevision);
				if(parentRevision!=null)
				{
					copyMetadata[RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
					metadata[RavenDocumentParentRevision] = key + "/revisions/" + parentRevision;
				}

				PutResult newDoc = Database.Put(key + "/revisions/", null, document, copyMetadata,
											 transactionInformation);
				int revision = int.Parse(newDoc.Key.Split('/').Last());

				RemoveOldRevisions(key, revision, transactionInformation);

				metadata[RavenDocumentRevisionStatus] = JToken.FromObject("Current");
				metadata[RavenDocumentRevision] = JToken.FromObject(revision);
			}
        }
开发者ID:ajaishankar,项目名称:ravendb,代码行数:35,代码来源:VersioningPutTrigger.cs

示例9: FileQuote

 internal FileQuote(JObject obj)
     : base(obj)
 {
     Body = obj.Value<string>("body");
     Title = obj.Value<string>("title");
     Identifier = obj.Value<string>("identifier");
 }
开发者ID:kevinkuszyk,项目名称:gengo-dotnet,代码行数:7,代码来源:Quote.cs

示例10: ParserMatches

        protected virtual bool ParserMatches(HttpRequestBase request, JObject payload, string targetBranch)
        {
            JObject repository = payload.Value<JObject>("repository");
            if (repository == null)
            {
                return false;
            }

            // The format of ref is refs/something/something else
            // e.g. refs/head/master or refs/head/foo/bar
            string branch = payload.Value<string>("ref");

            if (String.IsNullOrEmpty(branch) || !branch.StartsWith("refs/", StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }
            else
            {
                // Extract the name from refs/head/master notation.
                int secondSlashIndex = branch.IndexOf('/', 5);
                branch = branch.Substring(secondSlashIndex + 1);
                if (!branch.Equals(targetBranch, StringComparison.OrdinalIgnoreCase))
                {
                    return false;
                }
            }
            return true;
        }
开发者ID:projectkudu,项目名称:kudu,代码行数:28,代码来源:GitHubCompatHandler.cs

示例11: CreateFromJObject

        public static Ticker CreateFromJObject(JObject o)
        {
            if (o == null)
            {
                return null;
            }

            decimal highestBid = 0m, lowestAsk = 0m;

            var sellOrders = o["sellorders"] as JArray;
            if (sellOrders != null)
            {
                lowestAsk = sellOrders.Min(s => s.Value<decimal>("price"));
            }
            var buyOrders = o["buyorders"] as JArray;
            if (buyOrders != null)
            {
                highestBid = buyOrders.Max(s => s.Value<decimal>("price"));
            }


            var tick = new Ticker()
            {
                Bid = highestBid,
                Ask = lowestAsk,
                Volume = o.Value<decimal>("volume"),
                High = o.Value<decimal>("24hhigh"),
                Low = o.Value<decimal>("24hlow"),
                Last = o.Value<decimal>("lasttradeprice")
            };

            return tick;
        }
开发者ID:erdincay,项目名称:CoinTNet,代码行数:33,代码来源:Ticker.cs

示例12: ExecuteCommand

        public HttpResponseMessage ExecuteCommand(JObject input)
        {
            if (input == null)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            string command = input.Value<string>("command");
            string workingDirectory = input.Value<string>("dir");
            using (_tracer.Step("Executing " + command, new Dictionary<string, string> { { "CWD", workingDirectory } }))
            {
                try
                {
                    CommandResult result = _commandExecutor.ExecuteCommand(command, workingDirectory);
                    return Request.CreateResponse(HttpStatusCode.OK, result);
                }
                catch (CommandLineException ex)
                {
                    _tracer.TraceError(ex);
                    return Request.CreateResponse(HttpStatusCode.OK, new CommandResult { Error = ex.Error, ExitCode = ex.ExitCode });
                }
                catch (Exception ex)
                {
                    _tracer.TraceError(ex);
                    return Request.CreateResponse(HttpStatusCode.OK, new CommandResult { Error = ex.ToString(), ExitCode = -1 });
                }
            }
        }
开发者ID:40a,项目名称:kudu,代码行数:28,代码来源:CommandController.cs

示例13: Statement

        public Statement(JObject jobj) : base(jobj) {
            if (jobj["id"] != null)
            {
                id = new Guid(jobj.Value<String>("id"));
            }
            if (jobj["stored"] != null)
            {
                stored = jobj.Value<DateTime>("stored");
            }
            if (jobj["authority"] != null)
            {
                authority = (Agent)jobj.Value<JObject>("authority");
            }
            if (jobj["version"] != null)
            {
                version = (TCAPIVersion)jobj.Value<String>("version");
            }

            //
            // handle SubStatement as target which isn't provided by StatementBase
            // because SubStatements are not allowed to nest
            //
            if (jobj["object"] != null && (String)jobj["object"]["objectType"] == SubStatement.OBJECT_TYPE)
            {
                target = (SubStatement)jobj.Value<JObject>("object");
            }
        }
开发者ID:rmabraham,项目名称:TinCan.NET,代码行数:27,代码来源:Statement.cs

示例14: ParseOrderBook

        /// <summary>
        /// Parse market depth data (a paired list of bids and asks)
        /// </summary>
        /// <param name="depthJson"></param>
        /// <returns></returns>
        public static Book ParseOrderBook(JObject depthJson)
        {
            List<MarketDepth> asks = depthJson.Value<JArray>("asks").Select(depth => ParseMarketDepthEntry(depth)).ToList();
            List<MarketDepth> bids = depthJson.Value<JArray>("bids").Select(depth => ParseMarketDepthEntry(depth)).ToList();

            return new Book(asks, bids);
        }
开发者ID:dxzcc,项目名称:ncrypto-currency-exchange,代码行数:12,代码来源:VoSParsers.cs

示例15: ParseWallets

        public static List<Wallet> ParseWallets(JObject fundsJson)
        {
            JObject availableFundsJson = fundsJson.Value<JObject>("available_funds");
            JObject lockedFundsJson = fundsJson.Value<JObject>("locked_funds");
            List<Wallet> wallets = new List<Wallet>();

            foreach (JProperty fund in availableFundsJson.Properties())
            {
                decimal availableFunds = availableFundsJson.Value<decimal>(fund.Name);
                JToken lockedFundJson;
                decimal lockedFunds;

                if (null != lockedFundsJson
                    && lockedFundsJson.TryGetValue(fund.Name, out lockedFundJson))
                {
                    lockedFunds = decimal.Parse(lockedFundJson.ToString());
                }
                else
                {
                    lockedFunds = 0.0m;
                }

                wallets.Add(new Wallet(fund.Name, availableFunds + lockedFunds, lockedFunds));
            }

            return wallets;
        }
开发者ID:dxzcc,项目名称:ncrypto-currency-exchange,代码行数:27,代码来源:BterParsers.cs


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