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


C# Args.ContainsKey方法代码示例

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


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

示例1: Resource

        /// <summary>
        /// Initializes a new instance of the <see cref="Resource"/> class, 
        /// adding optional arguments for namespace and other endpoint 
        /// arguments.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="path">The path of this resource.</param>
        /// <param name="args">The variable arguments.</param>
        public Resource(Service service, string path, Args args)
        {
            this.Service = service;
            /* Pull out namespace items (app, owner, sharing) from the args, and
             * then use to create the full path.
             */
            Args clonedArgs = new Args(args);
            Args splunkNamespace = new Args();
            if (args.ContainsKey("app"))
            {
                splunkNamespace.Set("app", args["app"].ToString());
                clonedArgs.Remove("app");
            }
            if (args.ContainsKey("owner"))
            {
                splunkNamespace.Set("owner", args["owner"].ToString());
                clonedArgs.Remove("owner");
            }
            if (args.ContainsKey("sharing"))
            {
                splunkNamespace.Set(
                    "sharing", args["sharing"].ToString());
                clonedArgs.Remove("sharing");
            }
            if (!clonedArgs.ContainsKey("count"))
            {
                clonedArgs.Set("count", "-1");
            }

            this.RefreshArgs = clonedArgs;
            this.Path = service.Fullpath(
                path, splunkNamespace.Count == 0 ? null : splunkNamespace);
            this.MaybeValid = false;
        }
开发者ID:ravibeta,项目名称:csharpexamples,代码行数:42,代码来源:Resource.cs

示例2: Fullpath

        /// <summary>
        /// Ensures that the given path is fully qualified, prepending a path
        /// prefix if necessary. 
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="splunkNamespace">The Splunk namespace.</param>
        /// <returns>A fully qualified URL.</returns>
        /// <remarks>
        /// The path prefix is constructed using the current owner and app
        /// context when available.
        /// </remarks>
        public string Fullpath(string path, Args splunkNamespace)
        {
            // If already fully qualified (i.e. root begins with /), then return
            // the already qualified path.
            if (path.StartsWith("/"))
            {
                return path;
            }

            // If no namespace at all and no service instance of app and no
            // sharing, return base service endpoint + path.
            if (splunkNamespace == null && this.App == null)
            {
                return "/services/" + path;
            }

            // Base namespace values.
            string localApp = this.App;
            string localOwner = this.Owner;
            string localSharing = string.Empty;

            // Override with invocation namespace if set.
            if (splunkNamespace != null)
            {
                if (splunkNamespace.ContainsKey("app"))
                {
                    localApp = (string)splunkNamespace["app"];
                }
                if (splunkNamespace.ContainsKey("owner"))
                {
                    localOwner = (string)splunkNamespace["owner"];
                }
                if (splunkNamespace.ContainsKey("sharing"))
                {
                    localSharing = (string)splunkNamespace["sharing"];
                }
            }

            // Sharing, if set calls for special mapping, override here.
            // "user"    --> {user}/{app}
            // "app"     --> nobody/{app}
            // "global"  --> nobody/{app}
            // "system"  --> nobody/system
            if (localSharing.Equals("app") || localSharing.Equals("global"))
            {
                localOwner = "nobody";
            }
            else if (localSharing.Equals("system"))
            {
                localApp = "system";
                localOwner = "nobody";
            }

            return string.Format(
                "/servicesNS/{0}/{1}/{2}",
                localOwner == null ? "-" : localOwner,
                localApp   == null ? "-" : localApp,
                path);
        }
开发者ID:sim0629,项目名称:splunk-sdk-csharp,代码行数:70,代码来源:Service.cs


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