/// <summary> /// 构造函数 /// </summary> /// <param name="model">规则使用的模型</param> /// <param name="urlType">URL类型</param> /// <param name="strict">是否进行严格匹配</param> internal RangeUrlRuler(IUrlRangeModel model, UrlTypes urlType, bool strict) : this() { this.rangModel = model; this.UrlType = urlType; this.strictMatch = strict; }
private void Add(IEnumerable <Type> types, string layer, ICollection <Type> excludedTypes) { foreach (var type in types) { var key = GetInterfaceKey(type, layer); if (!excludedTypes.Contains(type)) { if (!UnmatchedInterfaces.ContainsKey(layer)) { UnmatchedInterfaces.Add(layer, new List <Type>()); } if (!UnmatchedInterfaces[layer].Contains(type)) { UnmatchedInterfaces[layer].Add(type); } continue; } if (!UrlTypes.ContainsKey(key)) { UrlTypes.Add(key, type); } } }
protected UrlRuler(SerializationInfo info, StreamingContext context) { this.httpMethod = info.GetString("httpMethod"); this.urlType = (UrlTypes)info.GetValue("urlType", typeof(UrlTypes)); this.appendParams = info.GetValue("appendParams", typeof(NameValueCollection)) as NameValueCollection; this.ignoreParams = info.GetValue("ignoreParams", typeof(NameValueCollection)) as NameValueCollection; this.contentHandlers = info.GetValue("contentHandlers", typeof(ICollection <IContentHandler>)) as ICollection <IContentHandler>; }
public void SetUp () { filter = "filter"; urlTypes = UrlTypes.DocRelative; upa = new UrlPropertyAttribute (); upa1 = new UrlPropertyAttribute (filter); upa2 = new UrlPropertyAttribute (filter, urlTypes); }
protected UrlRuler(SerializationInfo info, StreamingContext context) { this.httpMethod = info.GetString("httpMethod"); this.urlType = (UrlTypes)info.GetValue("urlType", typeof(UrlTypes)); this.appendParams = info.GetValue("appendParams", typeof(NameValueCollection)) as NameValueCollection; this.ignoreParams = info.GetValue("ignoreParams", typeof(NameValueCollection)) as NameValueCollection; this.contentHandlers = info.GetValue("contentHandlers", typeof(ICollection<IContentHandler>)) as ICollection<IContentHandler>; }
protected UrlRuler() { this.httpMethod = "GET"; this.urlType = 0x0; this.appendParams = new NameValueCollection(); this.ignoreParams = new NameValueCollection(); this.contentHandlers = new List <IContentHandler>(); }
protected UrlRuler() { this.httpMethod = "GET"; this.urlType = 0x0; this.appendParams = new NameValueCollection(); this.ignoreParams = new NameValueCollection(); this.contentHandlers = new List<IContentHandler>(); }
public string GetGitTargetDescription(UrlTypes type) { switch (type) { case UrlTypes.CurrentBranch: return(string.Format("Branch: {0}", _repository.Head.CanonicalName.Replace("origin/", ""))); case UrlTypes.CurrentRevision: return(string.Format("Revision: {0}", _repository.Commits.First().Id.ToString(8))); case UrlTypes.CurrentRevisionFull: return(string.Format("Revision: {0}... (Full ID)", _repository.Commits.First().Id.ToString(8))); case UrlTypes.Master: default: return("master"); } }
public string GetGitTargetPath(UrlTypes type) { switch (type) { case UrlTypes.CurrentBranch: return(_repository.Head.CanonicalName.Replace("origin/", "")); case UrlTypes.CurrentRevision: return(_repository.Commits.First().Id.ToString(8)); case UrlTypes.CurrentRevisionFull: return(_repository.Commits.First().Id.Sha); case UrlTypes.Master: default: return("master"); } }
public override string BuildGitUrl(UrlTypes type, Tuple <int, int> selectionLineRange) { var originUrl = _repository.Config.Get <string>("remote.origin.url"); if (originUrl == null) { throw new InvalidOperationException("Origin url can't found"); } var rootUrl = (originUrl.Value.EndsWith(".git", StringComparison.InvariantCultureIgnoreCase)) ? originUrl.Value.Substring(0, originUrl.Value.Length - 4) // remove .git : originUrl.Value; rootUrl = Regex.Replace(rootUrl, "^git@(.+):(.+)/(.+)$", match => "http://" + string.Join("/", match.Groups.OfType <Group>().Skip(1).Select(group => group.Value)), RegexOptions.IgnoreCase); rootUrl = Regex.Replace(rootUrl, "([^@/]+)@", string.Empty); // foo/bar.cs var rootDir = _repository.Info.WorkingDirectory; var fileIndexPath = _targetFullPath.Substring(rootDir.Length).Replace("\\", "/"); var targetRepository = GetGitTargetPath(type); // Line selection var fragment = string.Empty; if (selectionLineRange != null) { var lines = string.Join(",", Enumerable.Range(selectionLineRange.Item1, selectionLineRange.Item2 - selectionLineRange.Item1 + 1)); fragment = string.Format("#{0}-{1}", fileIndexPath.Split('/').Last(), lines); } var fileUrl = string.Format("{0}/src/{1}/{2}?fileviewer=file-view-default{3}", rootUrl.Trim('/'), WebUtility.UrlEncode(targetRepository.Trim('/')), fileIndexPath.Trim('/'), fragment); return(fileUrl); }
public override string BuildGitUrl(UrlTypes type, Tuple <int, int> selectionLineRange) { // https://github.com/user/repo.git var originUrl = _repository.Config.Get <string>("remote.origin.url"); if (originUrl == null) { throw new InvalidOperationException("Origin url can't found"); } // https://github.com/user/repo var rootUrl = (originUrl.Value.EndsWith(".git", StringComparison.InvariantCultureIgnoreCase)) ? originUrl.Value.Substring(0, originUrl.Value.Length - 4) // remove .git : originUrl.Value; // [email protected]:user/repo -> http://github.com/user/repo rootUrl = Regex.Replace(rootUrl, "^git@(.+):(.+)/(.+)$", match => "http://" + string.Join("/", match.Groups.OfType <Group>().Skip(1).Select(group => group.Value)), RegexOptions.IgnoreCase); // https://[email protected]/user/repo -> https://github.com/user/repo rootUrl = Regex.Replace(rootUrl, "(?<=^https?://)([^@/]+)@", string.Empty); // foo/bar.cs var rootDir = _repository.Info.WorkingDirectory; var fileIndexPath = _targetFullPath.Substring(rootDir.Length).Replace("\\", "/"); var targetRepository = GetGitTargetPath(type); // Line selection var fragment = (selectionLineRange != null) ? (selectionLineRange.Item1 == selectionLineRange.Item2) ? string.Format("#L{0}", selectionLineRange.Item1) : string.Format("#L{0}-L{1}", selectionLineRange.Item1, selectionLineRange.Item2) : string.Empty; var fileUrl = string.Format("{0}/blob/{1}/{2}{3}", rootUrl.Trim('/'), WebUtility.UrlEncode(targetRepository.Trim('/')), fileIndexPath.Trim('/'), fragment); return(fileUrl); }
public abstract string BuildGitUrl(UrlTypes type, Tuple <int, int> slectionLineRange);
/// <summary> /// 根据自定义的Regex实例,创建一个正则表达式类型的URL规则 /// </summary> /// <param name="regex">Regex实例</param> /// <returns>UrlRuler</returns> public static UrlRuler CreateRegexRuler(Regex regex, UrlTypes type) { return new RegexUrlRuler(regex, type); }
/// <summary> /// 创建一个大小写敏感的正则表达式类型的URL规则 /// </summary> /// <param name="regExpress">有效的正则表达式</param> /// <returns>UrlRuler</returns> public static UrlRuler CreateRegexRuler(string regExpress, UrlTypes type) { return CreateRegexRuler(regExpress,type, false); }
/// <summary> /// 创建一个正则表达式类型的URL规则 /// </summary> /// <param name="regExpress">有效的正则表达式</param> /// <param name="ignoreCase">指示是否忽略大小写</param> /// <returns>UrlRuler</returns> public static UrlRuler CreateRegexRuler(string regExpress, UrlTypes type, bool ignoreCase) { return new RegexUrlRuler(new Regex(regExpress, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None), type); }
/// <summary> /// 创建一个正则表达式类型的URL规则 /// </summary> /// <param name="regExpress">有效的正则表达式</param> /// <param name="ignoreCase">指示是否忽略大小写</param> /// <returns>UrlRuler</returns> public static UrlRuler CreateRegexRuler(string regExpress, UrlTypes type, bool ignoreCase) { return(new RegexUrlRuler(new Regex(regExpress, ignoreCase ? RegexOptions.IgnoreCase : RegexOptions.None), type)); }
/// <summary> /// 创建一个范围类型的URL规则 /// </summary> /// <param name="rangeModel">IUrlRangeModel的实例</param> /// <param name="strictMatch">指示是否采用严格匹配</param> /// <returns>UrlRuler</returns> public static UrlRuler CreateRangeRuler(IUrlRangeModel rangeModel, UrlTypes type, bool strictMatch) { return(new RangeUrlRuler(rangeModel, type, strictMatch)); }
/// <summary> /// 根据自定义的Regex实例,创建一个正则表达式类型的URL规则 /// </summary> /// <param name="regex">Regex实例</param> /// <returns>UrlRuler</returns> public static UrlRuler CreateRegexRuler(Regex regex, UrlTypes type) { return(new RegexUrlRuler(regex, type)); }
/// <summary> /// 创建一个大小写敏感的正则表达式类型的URL规则 /// </summary> /// <param name="regExpress">有效的正则表达式</param> /// <returns>UrlRuler</returns> public static UrlRuler CreateRegexRuler(string regExpress, UrlTypes type) { return(CreateRegexRuler(regExpress, type, false)); }
/// <summary> /// 创建一个范围类型的URL规则 /// </summary> /// <param name="rangeModel">IUrlRangeModel的实例</param> /// <param name="strictMatch">指示是否采用严格匹配</param> /// <returns>UrlRuler</returns> public static UrlRuler CreateRangeRuler(IUrlRangeModel rangeModel,UrlTypes type, bool strictMatch) { return new RangeUrlRuler(rangeModel,type, strictMatch); }
/// <summary> /// 从给定的绝对URL和相对URL,以及类型创建URL实例 /// </summary> /// <param name="url">绝对URL字符串的表示</param> /// <param name="relativeUrl">相对对URL字符串的表示</param> /// <param name="type">UrlTypes</param> /// <param name="holder">holder URL</param> /// <returns>Url</returns> private static Url Create(string url, string relativeUrl, UrlTypes type, Url holder) { Url u = null; switch (type) { case UrlTypes.Index: u = new IndexUrl(url, relativeUrl); break; case UrlTypes.Final: u = new FinalUrl(url, relativeUrl, holder); break; } return u; }
public UrlPropertyAttribute (string filter, UrlTypes urlTypes) { this.filter = filter; this.urlTypes = urlTypes; }
/// <summary> /// 构造函数 /// </summary> /// <param name="regObj">Regex实例</param> internal RegexUrlRuler(Regex regObj, UrlTypes urlType) : this() { this.regex = regObj; this.UrlType = urlType; }