Tag: partial

用于计算class级计数的部分语法

我需要计算正确的C#源文件中的类数。 我写了下面的语法: grammar CSharpClassGrammar; options { language=CSharp2; } @parser::namespace { CSharpClassGrammar.Generated } @lexer::namespace { CSharpClassGrammar.Generated } @header { using System; using System.Collections.Generic; } @members { private List _classCollector = new List(); public List ClassCollector { get { return _classCollector; } } } /*—————————————————————— * PARSER RULES *——————————————————————*/ csfile : class_declaration* EOF ; class_declaration : (ACCESSLEVEL […]

Selenium:如何通过部分href找到元素?

工作代码1: Driver.Instance.FindElement( By.XPath(“//a[contains(@href,'” + PartialLinkHref + “‘)]” )); 工作代码2: ReadOnlyCollection linkList = Driver.Instance.FindElements(By.TagName(“a”)); for (int i = 0; i < linkList.Count ; i++) { if (linkList[1].GetAttribute("href").Contains(PartialLinkHref)) { element.SetElement(linkList[i]); return element; break; } }

如何自动将VS2003类转换为部分Designer.cs文件?

我正在将项目从Visual Studio 2003升级到2008,并希望自动生成XXX.Designer.cs文件并更新相应的XXX.cs原始文件。 有自动方式吗? 更新 :我指的是WinForms。 当然,我知道旧式的作品,但我正在寻找一种不用手工制作的新方式。

如何检查两个字符串是否在C#中是部分匹配?

可能重复: 是否有为C#编写的模糊搜索或字符串相似性函数库? 我正在创建一个应用程序,除了用户输入歌曲或艺术家或专辑名称之外,然后将通过字符串数组或ArrayList查找任何可能的匹配。 将根据匹配百分比计算自动建议。 例如 如果用户键入链接prk,它应该找到Linkin Park或Link 80或Link Wray但匹配百分比将对所有人不同 假设该集合仅搜索艺术家集合中的艺术家姓名和歌曲集合中的歌曲名称。 (百分比数字仅供参考) Linkin Park – 98% Link Wray -82% Link 80 – 62% 解决方案不一定是C#代码,任何正则表达式或伪代码都会很好,但应该可以在C#中实现。

MVC:Dictionary需要一个类型为’System.Collections.Generic.IEnumerable`1的模型项

我收到此错误,我不确定我是否能够这样做,这是我的代码.. 应用控制器 public ActionResult AppView() { List apps; using (ISiteDbContext context = _resolver.GetService()) { apps = context.Applications.ToList(); } return PartialView(“AppView”, apps.OrderBy(a => a.Name).ToList()); } 渲染部分 – 这是在家庭控制器中的视图内。 @{Html.RenderPartial(“~/Views/Application/AppView.cshtml”, new Example.Services.DAL.Application());} 和我的应用程序视图 @model IEnumerable @{ ViewBag.Title = “Applications”; } Applications @Html.ActionLink(“Add New Application”, “Create”) @Html.DisplayNameFor(model => model.Name) @foreach (var item in Model) { @Html.DisplayFor(modelItem => item.Name) […]

在部分类中设置属性的属性

我有一个由Entity Framework (EF)生成的员工类。 public partial class employee { private string name; public string Name { get{return name;} set{ name = value;} } } 现在我想在name属性中放置一个必需的属性,用于在我编写的另一个员工部分类中进行MVC3validation,以扩展由EF生成的那个,这样我就不必重写我的代码了如果我刷新EF生成的模型。 我写的部分类在同一个程序集和名称空间中。 public partial class employee { // What should I write here to add required attribute in the Name property? }

部分类中的接口实现问题

我有一个关于L2S,Autogenerated DataContext和Partial Classes的使用问题的问题。 我已经抽象了我的datacontext,并且对于我使用的每个表,我正在实现一个带接口的类。 在下面的代码中,您可以看到我有接口和两个分部类。 第一个类就是确保自动生成的datacontext中的类具有接口。 另一个自动生成的类确保实现Interface的方法。 namespace PartialProject.objects { public interface Interface { Interface Instance { get; } } //To make sure the autogenerated code inherits Interface public partial class Class : Interface { } //This is autogenerated public partial class Class { public Class Instance { get { return this.Instance; } } } […]

查看PDF作为页面的一部分

我试图在我的MVC网页中查看PDF文档,但我无法使其工作。 我希望PDF显示为页面上其他内容的一部分(页眉,页脚等)。 目前我有一个显示PDF的解决方案,但在整个页面上。 有没有人这样做过,如果有,那怎么样?