以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]Inherits 接口怎么来对接? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=183877) |
-- 作者:浙江仔 -- 发布时间:2022/11/17 9:37:00 -- [求助]Inherits 接口怎么来对接? C#代码转VB,结果出现了Inherits 接口,我改怎么去对接dll? 全局代码: Namespace MAPIDemo Inherits XX.IStrList \'写在这里,提示:类只能从其他类继承 Public Class MmForCSharp () As List Inherits IStrlist \'dll接口 Public Function XX As List Return list End Function End Class End Namespace 代码使用: XX.StrList = New MmForCSharp() 全局代码中不写Inherits这句,则提示: 无法将类型为“MmForCSharp”的对象强制转换为类型“XX.StrList”。 [此贴子已经被作者于2022/11/17 9:46:31编辑过]
|
-- 作者:有点蓝 -- 发布时间:2022/11/17 9:49:00 -- C#代码发上来看看 |
-- 作者:浙江仔 -- 发布时间:2022/11/17 10:05:00 -- namespace MAPIDemo { /// <summary> /// C#实现接口IFoldingStrategy /// </summary> public class MmForCSharp: IFoldingStrategy { public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation) { List<FoldMarker> list = new List<FoldMarker>(); Stack<int> startLines = new Stack<int>(); // Create foldmarkers for the whole document, enumerate through every line. for (int i = 0; i < document.TotalNumberOfLines; i++) { // Get the text of current line. string text = document.GetText(document.GetLineSegment(i)); if (text.Trim().StartsWith("#region")) // Look for method starts { startLines.Push(i); } if (text.Trim().StartsWith("#endregion")) // Look for method endings { int start = startLines.Pop(); // Add a new FoldMarker to the list. // document = the current document // start = the start line for the FoldMarker // document.GetLineSegment(start).Length = the ending of the current line = the start column of our foldmarker. // i = The current line = end line of the FoldMarker. // 7 = The end column list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.Region, "...")); } //支持嵌套 {} if (text.Trim().StartsWith("{")) // Look for method starts { startLines.Push(i); } if (text.Trim().StartsWith("}")) // Look for method endings { if (startLines.Count > 0) { int start = startLines.Pop(); list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, "...}")); } } // /// <summary> if (text.Trim().StartsWith("/// <summary>")) // Look for method starts { startLines.Push(i); } if (text.Trim().StartsWith("/// <returns>")) // Look for method endings { int start = startLines.Pop(); //获取注释文本(包括空格) string display = document.GetText(document.GetLineSegment(start + 1).Offset, document.GetLineSegment(start + 1).Length); //remove /// display = display.Trim().TrimStart(\'/\'); list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, display)); } } return list; } } } 或者如这种接口: https://www.cnblogs.com/farrio/archive/2005/03/29/127917.html
[此贴子已经被作者于2022/11/17 10:06:09编辑过]
|
-- 作者:有点蓝 -- 发布时间:2022/11/17 10:13:00 -- 全局代码: Public Class MmForCSharp Implements IFoldingStrategy Public Function XX As List Return list End Function End Class |
-- 作者:浙江仔 -- 发布时间:2022/11/17 13:38:00 -- 感谢,实现了 Public Class MmForCSharp Implements IFoldingStrategy Public Function XX As List Implements IFoldingStrategy.XX 这里也要加,XX的函数要和接口里面的函数对应 Return list End Function End Class
|