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


C# XUri.GetSegments方法代码示例

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


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

示例1: Remove

 internal void Remove(XUri uri)
 {
     Remove(uri.GetSegments(UriPathFormat.Normalized), 0);
 }
开发者ID:nataren,项目名称:DReAM,代码行数:4,代码来源:feature.cs

示例2: ParseFeatureSignature

        //--- Class Methods ---
        private static void ParseFeatureSignature(XUri baseUri, string signature, out string[] pathSegments, out KeyValuePair<int, string>[] paramNames, out int optional)
        {
            List<string> segments = new List<string>(baseUri.GetSegments(UriPathFormat.Normalized));
            List<KeyValuePair<int, string>> names = new List<KeyValuePair<int, string>>();
            optional = 0;

            // normalize and remove any leading and trailing '/'
            signature = signature.ToLowerInvariant().Trim();
            if((signature.Length > 0) && (signature[0] == '/')) {
                signature = signature.Substring(1);
            }
            if((signature.Length > 0) && (signature[signature.Length - 1] == '/')) {
                signature = signature.Substring(0, signature.Length - 1);
            }
            if(signature.Length > 0) {
                string[] parts = signature.Split('/');

                // loop over all parts
                for(int i = 0; i < parts.Length; ++i) {

                    // check if part is empty (this only happens for "//")
                    if(parts[i].Length == 0) {

                        // we found two slashes in a row; the next token MUST be the final token
                        if((i != (parts.Length - 2)) || (parts[i + 1] != "*")) {
                            throw new ArgumentException("invalid feature signature", signature);
                        }
                        optional = int.MaxValue;
                        break;
                    } else {
                        string part = parts[i].Trim();
                        if((part.Length >= 2) && (part[0] == '{') && (part[part.Length - 1] == '}')) {

                            // we have a path variable (e.g. /{foo}/)
                            if(optional != 0) {
                                throw new ArgumentException("invalid feature signature", signature);
                            }
                            segments.Add(SysUtil.NameTable.Add("*"));
                            names.Add(new KeyValuePair<int, string>(baseUri.Segments.Length + i, SysUtil.NameTable.Add(part.Substring(1, part.Length - 2))));
                        } else if(part == "*") {

                            // we have a path wildcard (e.g. /*/)
                            if(optional != 0) {
                                throw new ArgumentException("invalid feature signature", signature);
                            }
                            segments.Add(SysUtil.NameTable.Add(part));
                            names.Add(new KeyValuePair<int, string>(baseUri.Segments.Length + i, SysUtil.NameTable.Add(i.ToInvariantString())));
                        } else if(part == "?") {

                            // we have an optional path (e.g. /?/)
                            ++optional;
                            segments.Add(SysUtil.NameTable.Add(part));
                        } else {

                            // we have a path constant (e.g. /foo/)
                            if(optional != 0) {
                                throw new ArgumentException("invalid feature signature", signature);
                            }
                            segments.Add(SysUtil.NameTable.Add(part));
                        }
                    }
                }
            }
            pathSegments = segments.ToArray();
            paramNames = names.ToArray();
        }
开发者ID:bjorg,项目名称:DReAM,代码行数:67,代码来源:types.cs

示例3: Find

 internal List<DreamFeature> Find(XUri uri)
 {
     return Find(uri.GetSegments(UriPathFormat.Normalized), 0);
 }
开发者ID:nataren,项目名称:DReAM,代码行数:4,代码来源:feature.cs


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