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


C# JsonObject.Exists方法代码示例

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


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

示例1: HasSuccess

        /// <summary>
        /// check is status is equal success
        /// </summary>
        /// <param name="result">result of request</param>
        /// <returns>True if status is equal success</returns>
        private bool HasSuccess(string result)
        {
            JsonObject jsonObject = new JsonObject(result);
            string status = null;
            if (!jsonObject.Exists("status") || !jsonObject.TryGetString("status", out status))
            {
                return false;
            }

            return status == "success";
        }
开发者ID:jackyped,项目名称:blog,代码行数:16,代码来源:AGSAdmin.cs

示例2: GenerateAGSToken

        /// <summary>
        /// 产生token
        /// </summary>
        /// <returns>返回一个toke,采用默认的过期时间令牌</returns>
        private string GenerateAGSToken()
        {
            try
            {
                string urlGenerateToken = string.Format("{0}/generateToken", this.urlRestAdmin);
                string credential = string.Format("username={0}&password={1}&client=requestip&expiration=&f=json", this.username, this.password);
                string result = this.GetResult(urlGenerateToken, credential);

                JsonObject jsonObject = new JsonObject(result);
                string token = null;
                if (!jsonObject.Exists("token") || !jsonObject.TryGetString("token", out token))
                {
                    throw new Exception("Token not found!");
                }

                return token;
            }
            catch(Exception ex)
            {
                return string.Empty;
            }
        }
开发者ID:jackyped,项目名称:blog,代码行数:26,代码来源:AGSAdmin.cs

示例3: GetServerDirectory

        /// <summary>
        /// Get physical Path and virtual Path from directory ags
        /// </summary>
        /// <param name="directory">directory ags</param>
        /// <param name="physicalPath">physical Path</param>
        /// <param name="virtualPath">virtual Path</param>
        /// <returns>True if successfully return path</returns>
        public bool GetServerDirectory(string directory, out string physicalPath, out string virtualPath)
        {
            physicalPath = null;
            virtualPath = null;
            try
            {
                string token = this.GenerateAGSToken();
                string directoryUrl = this.urlRestAdmin + "/system/directories/" + directory + "?f=json&token=" + token;

                string result = this.GetResult(directoryUrl);

                JsonObject jsonObject = new JsonObject(result);
                if (!jsonObject.Exists("physicalPath") || !jsonObject.TryGetString("physicalPath", out physicalPath))
                {
                    throw new Exception();
                }

                jsonObject = new JsonObject(result);
                if (!jsonObject.Exists("virtualPath") || !jsonObject.TryGetString("virtualPath", out virtualPath))
                {
                    throw new Exception();
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
开发者ID:jackyped,项目名称:blog,代码行数:37,代码来源:AGSAdmin.cs

示例4: ListServices

        /// <summary>
        /// list of services in folder
        /// </summary>
        /// <param name="folder">name of folder</param>
        public void ListServices(string folder)
        {
            try
            {
                string token = this.GenerateAGSToken();
                string serviceUrl = this.urlRestAdmin + "/services/" + folder;
                string postcontent = "f=json&token=" + token;
                string result = this.GetResult(serviceUrl, postcontent);

                JsonObject jsonObject = new JsonObject(result);
                object[] folders = null;
                if (jsonObject.Exists("folders") && jsonObject.TryGetArray("folders", out folders))
                {
                    foreach (string subfolder in folders)
                    {
                        this.ListServices(subfolder);
                    }
                }

                object[] services = null;
                if (jsonObject.Exists("services") && jsonObject.TryGetArray("services", out services))
                {
                    IEnumerable<JsonObject> jsonObjectService = services.Cast<JsonObject>();
                    jsonObjectService.ToList().ForEach(jo =>
                    {
                        string serviceName;
                        jo.TryGetString("serviceName", out serviceName);
                        string folderName;
                        jo.TryGetString("folderName", out folderName);
                        Console.WriteLine(folderName + "/" + serviceName);
                    });
                }
            }
            catch
            {
                throw;
            }
        }
开发者ID:jackyped,项目名称:blog,代码行数:42,代码来源:AGSAdmin.cs

示例5: HasError

        /// <summary>
        /// check is status is equal error
        /// </summary>
        /// <param name="result">result of request</param>
        /// <returns>True if status is equal error</returns>
        private bool HasError(string result)
        {
            JsonObject  jsonObject =  new  JsonObject (result);
             String  status =  null ,
             if  (! jsonObject.Exists ( "status" ) | |! jsonObject.TryGetString ( "status" ,  out  status))
            {
                return false;
            }
 
            return status == "error";
        }
开发者ID:jackyped,项目名称:blog,代码行数:16,代码来源:AGSAdmin.cs


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