假设我有一个目标类和一个大致相同的源类.几乎所有属性都使用automapper自动映射.
比如说这些类中的30个属性,其中两个没有以任何方式直接进行核心化,而后者可以自动计算出来.
有没有办法告诉automapper手动连接两个属性?
例如:
class DTOMyObject
{
public int Test {get; set;}
public int Test2 {get; set;}
public int Test3 {get; set;}
public int Test4 {get; set;}
public int Test5 {get; set;}
// Continues for many many more properties.
public int RandomOtherName {get; set;}
public int SecondRandomName {get; set;}
}
class ViewMyObject
{
public int Test {get; set;}
public int Test2 {get; set;}
public int Test3 {get; set;}
public int Test4 {get; set;}
public int Test5 {get; set;}
// Continues …Run Code Online (Sandbox Code Playgroud) 我正在学习SharePoint以及您可以部署的不同类型的解决方案.从我正在观看的训练看来,你应该尽可能地使用沙盒解决方案.这是因为Farm Solutions会把事情弄得太乱.
但是,Sandbox Solutions不支持我使用WebParts做的两件主要事情.这些是Visual WebParts和WebPart通信.(第一个是不允许的,因为它需要命中文件系统而第二个是不允许的,因为它使用反射).
在我看来,我的WebParts总是想要做至少其中一件事.(不通信的WebParts真的不是模块化的吗?)
我是否忽略了这一点,或者Sandbox Solutions是一个"好主意",实际代码中并没有真正使用它?
sharepoint web-parts sharepoint-2010 sandbox-solution farm-solution
我需要一种方法来将字符串形式的数字列表带到List对象.
这是一个例子:
string ids = "10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19";
List<String> idList = new List<String>();
idList.SomeCoolMethodToParseTheText(ids); <------+
|
foreach (string id in idList) |
{ |
// Do stuff with each id. |
} |
|
// This is the Method that I need ----------------+
Run Code Online (Sandbox Code Playgroud)
.net库中有什么东西让我不必写SomeCoolMethodToParseTheText自己的东西吗?
我有两个方法做非常相似的事情,但有不同的返回类型(字符串vs int)
他们来了:
private static string LoadAttributeString(this XElement xmlElement,
string attributeName, string defaultValue)
{
try
{return xmlElement.Attribute(attributeName).Value;}
catch (Exception)
{return defaultValue;}
}
private static int LoadAttributeInt(this XElement xmlElement,
string attributeName, int defaultValue)
{
try
{return int.Parse(xmlElement.Attribute(attributeName).Value);}
catch (Exception)
{return defaultValue;}
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用泛型将这些方法组合成一种方法?(我尝试过但失败了.)
注意:我有两种不同的方法.我想扩展我对泛型的了解.所以我想我会问是否有可能.
因此,作为一名新的.NET程序员,我认为垃圾收集器会一直为我清理混乱.
现在,一年半之后,当我不知道我不得不在某些资源上调用dispose时,我写的代码中出现了内存异常.我猜这是因为该代码分配了许多不会被处理掉的位图...
我已经通过代码来清理它们,因为我知道的更好.但我总是想念一些.是否有工具或设置可以看到IDisposables没有被处置?
虽然我可以看到简单的情况很容易被编译器或工具捕获,但我也可以看到一些非常难以捕获的更复杂的情况.因此,如果没有我理解的工具,并将继续手工完成.
我们有一个非常古老的应用程序.它是重写的块.但由于它非常复杂,重写不断被推迟.
现在我需要知道是否有办法让Delphi 5应用程序调用WCF Web服务?
我知道当Delphi 5发布时,WCF在其发明者的眼中甚至不是一个闪光......但它可以做到吗?如果是这样,怎么样?
我正在设计一个新项目,我正在试图找出将数据/事件从服务器应用程序推送到客户端应用程序(即WPF应用程序)的方法.
我知道的两个是:
服务器是否有其他解决方案可以与客户端通信?如果是这样,他们是什么?
我有一个像这样的字符串:
项目1,项目2,项目3
但也可能
项目1
是否有一个灵活的.net方法将其导入List?
我试着效仿这个例子:
http://msdn.microsoft.com/en-us/library/aa179614%28SQL.80%29.aspx#
它说要将以下路径添加为Web引用:
http://myserver/reportserver/reportservice.asmx
我已经尝试过(使用myserver的服务器名称)并且它总是返回错误.
当我尝试将其作为Web引用时,它说"HTML文档不包含Web服务发现信息".
我该如何添加此服务?我显然遗漏了文档中没有的内容.有没有人能够为SSRS添加Web引用(或服务引用)?如果是这样,它是如何完成的?
注意:我使用的是Visual Studio 2010 Ultimate和SQL Server 2008 R2.
visual-studio-2010 service-reference visual-studio reporting-services ssrs-2008
我正在松散地遵循WCF中的方法正确的方法...手动方式来设置我的WCF服务.
我有一个手动生成的代理类,如下所示:
// Setup a client so we can call our web services.
public class EmployeeClient :IEmployeeService
{
private readonly IEmployeeService EmployeeChannel;
public EmployeeClient(Binding binding, string address)
{
var endpointAddress = new EndpointAddress(address);
EmployeeChannel = new ChannelFactory<IEmployeeService>
(binding, endpointAddress).CreateChannel();
}
public EmployeeResponse SaveOrUpdateEmployee(EmployeeContract employee)
{
return EmployeeChannel.SaveOrUpdateEmployee(employee);
}
}
Run Code Online (Sandbox Code Playgroud)
然后我想打电话给其中的一些服务.但我不想使用任何配置文件(我正在设置一些集成测试,我不希望有更多的依赖项.)
我目前正试图像这样打电话给他们:
serviceHost = SelfServiceHost.StartupService();
employeeClient = new EmployeeClient(new BasicHttpBinding(),
SelfServiceHost.StartUpUrl);
EmployeeResponse employeeResponse = employeeClient.SaveOrUpdateEmployee(emp);
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我得到这个例外:
System.ServiceModel.ProtocolException:Content Type text/xml; 服务http:// localhost:8090/EmployeeService不支持charset = utf-8 .客户端和服务绑定可能不匹配.---> System.Net.WebException:远程服务器返回错误:(415)无法处理消息,因为内容类型为'text/xml; …