自Visual Studio 2017发布以来,我们可以使用新的C#7功能,我希望在部署Azure Web应用程序时可以使用它.
不幸的是,我们在使用持续部署(kudu git deploy)时会看到编译错误,所以Azure似乎还不支持新的工具链.
有什么我们可以做的就是让它现在起作用(除了直接发布程序集)吗?
我想使用propertygrid编辑键值(字符串,字符串)项的列表.当我使用Dictionary<string,string>as类型时,propertygrid将显示一个GUI,但它似乎没有"启用",即.我无法添加任何物品.
是否支持Dictionary对象,或者是否有任何其他对象可以解决此问题?
.NET框架4.6已发布.我已经迁移了我的应用程序但是当我部署到Azure网站时,我收到以下错误:
D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(983,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. …Run Code Online (Sandbox Code Playgroud) 我想知道在Firefox插件中检测首次运行的最简单方法.我不喜欢使用(SQLite)存储API,因为这对于这个简单的用例来说似乎有些过分.
我想我的问题也可能是:存储旗帜的最简单方法是什么?
在旧的 MVC 版本中有一个ValueProviderFactory,但在 MVC6 中,我找不到那个工厂。如何在 MVC6 中定义自定义 valueProvider?
我正在WCF中实现一项服务,需要通过用户名/密码进行自定义用户身份验证.此服务配置为WebScript(JSON)服务.
我想知道是否有可能获得安全上下文,所以我不必在每次调用中包含哈希或用户/传递.我知道我可以使用证书,但我需要使用身份验证的使用/传递机制.
我将使用AJAX(jQuery)与此服务进行通信,并且应该可以使用基本的HTTP身份验证.
此服务稍后还会公开其他端点,例如通过TCP,这确实支持"正确"的身份验证.
在WCF中有很多方法可以保证安全性,我觉得有点迷失,感觉就像我读的越多,我知道的就越少.
访问propertygrid时,只会调用ConvertTo方法(很多次).这正确地返回了"Foo!" propertygrid中的字符串.当我点击编辑时,我得到一个例外Cannot convert object of type Foo to type System.String.(不完全,翻译).ConvertFrom方法没有被调用,任何线索为什么?并且错误表明它正在尝试转换为字符串,而不是来自.
我想当我想编辑这个对象时,它必须从Foo转换为字符串,并在完成编辑后.
StringConverter类:
public class FooTypeConverter : StringConverter {
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
return new Foo((string) value);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
return "Foo!";
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
return true;
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) {
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
正在访问的财产:
Foo _foo = new Foo();
[Editor(typeof(System.ComponentModel.Design.MultilineStringEditor), …Run Code Online (Sandbox Code Playgroud) 在DDD示例中,我经常看到使用方法,我可能会使用属性.为什么是这样?
例如(来自强化您的域名:聚合构建)
public class Order
{
public bool IsLocal()
{
return Customer.Province == BillingProvince;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 fetchXML 连接两个实体,并且只能获取第一个列表的结果。我可能犯了一个愚蠢的错误,但这让我折腾了好几个小时。
var query = @"
<fetch version='1.0' mapping='logical' distinct='true'>
<entity name='contact'>
<all-attributes />
<link-entity name='new_custom' from='new_contactid' to='contactid' link-type='inner'>
<all-attributes />
</link-entity>
</entity>
</fetch>
";
var fe = new FetchExpression(query);
var result = service.RetrieveMultiple(fe);
// This contact entity is properly filled
var contact = result.Entities.First().Cast<Contact>();
// This relationship is null, that's unexpected!
var custom = contact.new_contact_new_custom;
// Also null (not sure if this should work)
var related = contact.GetRelatedEntity<new_custom>("new_contact_new_custom", null);
Run Code Online (Sandbox Code Playgroud)
我确实看到在 Contact 实体的Attributes和FormattedValues属性中检索到了正确的数据。但是为什么关系没有正确建立呢?以及如何将此数据转换为正确的“自定义”实体类型?
我无法理解如何使用ORM生成的对象.我们使用LLBLGen将数据库模型映射到对象.我们将这些对象封装在代表我们业务模型的另一层中(我认为).
也许这段代码会更好地解释这一点.
public class Book { // The class as used in our application
private BookEntity book; // LLBLGen entity
private BookType bookType; // BookType is another class that wraps an entity
public Book(int Id) {
book = new BookEntity(Id);
}
public BookType BookType {
get { return this.bookType; }
set {
this.bookType = value;
this.book.BookType = new BookTypeEntity(value.ID);
this.book.Save();
}
}
public int CountPages() { } // Example business method
}
Run Code Online (Sandbox Code Playgroud)
暴露实体的字段就像属性一样,感觉很尴尬,因为我重新映射了一遍.对于列表类型,它甚至更糟,因为我必须编写一个"添加"和"删除"方法以及一个公开List的属性.
在BookType setter中的上述示例中,我需要访问BookTypeEntity对象,我可以通过使用BookType对象的ID实例化一个新对象来获取此对象.这也感觉不舒服.
我想知道我是不是应该只扩展BookEntity对象并在那里添加我的业务逻辑?或者也许使用部分?
在LLGLGen示例中,他们直接使用实体对象,但这看起来非常混乱.我想在上面的代码中拥有可以为我的业务逻辑(如CountPages)提供方法的对象.
我正在尝试确定是否需要在Azure Service Bus上使用MassTransit或直接使用ASB.我不打算使用saga或中间件等高级功能,但需要一个支持命令和pub/sub样式消息传递的简单ESB.
有关选择运输的MassTransit文档仍在开发中.看看ASB文档,似乎Azure提供的不仅仅是传输.
我没有使用其他ESB的经验,所以我不确定我需要什么功能.
我正在寻找一些关于为什么我应该使用其中一个的指导.更具体一点:MassTransit仅提供ASB所必需的功能(如果有的话)?
让我们说我想设计一个抽象系统来计算文档中的部分.我设计了两个类,Document和Section,该文档有一个部分列表和一个计算它们的方法.
public abstract class Document {
List<Section> sections;
public void addSection(Section section) {
sections.Add(section);
}
public int sectionCount() {
return sections.count;
}
}
public abstract class Section {
public string Text;
}
Run Code Online (Sandbox Code Playgroud)
现在,我希望能够在多重场景中使用此代码.例如,我有章节书籍.本书将是Document的子类,而Chapter是Section的子类.这两个类都将包含额外的字段和功能,与计数部分无关.
我偶然遇到的问题是因为Document包含部分而不是Chapters,章节的附加功能对我来说是无用的,它只能作为 Book 的一部分添加.
我正在阅读有关向下倾斜的内容,但我认为这不是正确的方法.我想也许我完全采取了错误的做法.
我的问题是:如何设计这样一个抽象系统,可以被子类化对象重用,这是要走的路吗?
假设我有一个很好的域模型,在需要的地方使用(构造函数)DI.现在我希望能够坚持这个模型,所以我开始添加基础设施(实体框架)来做到这一点.现在发生的是持久性框架应该能够使用您的IoC容器初始化您的类型.
也许这是可能的,也许不是.无论如何,我现在想知道的是; 通常在你的POCO课上使用DI吗?如果是的话,我如何让Entity Framework使用我最喜欢的IoC容器(在我的案例中为NInject)来构建我的类.
.net domain-driven-design entity-framework dependency-injection ioc-container
c# ×7
.net ×5
azure ×2
oop ×2
propertygrid ×2
ajax ×1
asp.net-core ×1
c#-7.0 ×1
data-binding ×1
dynamics-crm ×1
llblgenpro ×1
masstransit ×1
orm ×1
wcf ×1
web-services ×1
winforms ×1