在Visual Studio(2012+)中,我想要一个从代码注释到TFS工作项的可点击引用.有没有一种简单的方法可以做到这一点,这也可能来自函数体内的注释(不是函数的摘要)?
所以我想要这样的东西:
/// <summary>
/// Example of a summary
/// </summary>
static void Main()
{
int dummy = 1; //Should be 1 according to @Task1234 <- should be a hyperlink
}
Run Code Online (Sandbox Code Playgroud)
而不是这样的事情:
/// <summary>
/// Example of a summary, see <a href="http://mytfsserver:8080//tfs/myCollection/Branch/_workItems#id=1234"> Task 1234 </a>.
/// </summary>
static void Main()
{
}
Run Code Online (Sandbox Code Playgroud)
一些标签阅读材料: 文档注释的推荐标签(C#编程指南)
我有一个很大的解决方案,需要更换很多行.在Visual Studio中,您可以使用正则表达式进行搜索和替换.
我想替换以下行:
rst.Fields("CustomerName").Value
rst.Fields("Address").Value
rst.Fields("Invoice").Value
Run Code Online (Sandbox Code Playgroud)
至:
row("CustomerName").ToString()
row("Address").ToString()
row("Invoice").ToString()
Run Code Online (Sandbox Code Playgroud)
从而保持动态文本部分,这可以变化.
这可能吗?怎么样?
更新,解决方案:
搜索:rst.Fields{\(.*\)}\.Value
替换:rst\1.ToString()
谢谢JaredPar!
我必须为财务dpt自动化一些东西.我有一个Excel文件,我想用OleDb阅读:
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=A_File.xls;Extended Properties=""HTML Import;IMEX=1;""";
using (OleDbConnection connection = new OleDbConnection())
{
using (DbCommand command = connection.CreateCommand())
{
connection.ConnectionString = connectionString;
connection.Open();
DataTable dtSchema = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
if( (null == dtSchema) || ( dtSchema.Rows.Count <= 0 ) )
{
//raise exception if needed
}
command.CommandText = "SELECT * FROM [NameOfTheWorksheet$]";
using (DbDataReader dr = command.ExecuteReader())
{
while (dr.Read())
{
//do something with the data
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
通常connectionstring会有一个扩展属性"Excel 8.0",但文件无法以这种方式读取,因为它似乎是一个重命名为.xls的html文件.当我将数据从xls复制到新的xls时,我可以读取新的xls,并将EP设置为"Excel 8.0".
是的,我可以通过创建一个Excel实例来读取该文件,但我不愿意..任何想法如何使用OleDb读取xls而不需要手动更改xls或在实例化的Excel中使用范围?
问候, …
我正在尝试使用SvcUtil.exe而不是Xsd.exe生成C#代码类.后者给了我一些问题.
命令行:
SvcUtil.exe myschema.xsd /dconly /ser:XmlSerializer
Run Code Online (Sandbox Code Playgroud)
这里描述并解决了几个SvcUtil问题:http://blog.shutupandcode.net/? p = 761
我无法解决的一个问题是:错误:无法导入命名空间''中的'DatafieldDescription'.属性必须是可选的,并且来自名称空间" http://schemas.microsoft.com/2003/10/Seri alization /".更改架构以便类型可以映射到数据协定类型或使用ImportXmlType或使用其他序列化程序. "
我变了
<xs:attribute name="Order" use="required">
Run Code Online (Sandbox Code Playgroud)
至
<xs:attribute name="Order" use="optional">
Run Code Online (Sandbox Code Playgroud)
和
<xs:attribute name="Order">
Run Code Online (Sandbox Code Playgroud)
但错误仍然存在.是否可以使用属性,或者我是否必须将它们全部删除(在这种情况下,这种表现已经结束)?
我在堆栈面板中有一些WPF文本块,我想要数据绑定和格式化.
例如,以下格式为没有秒部分的日期24h样式:
<TextBlock Text="{Binding MyCustomObject, StringFormat={}{0:HH:mm}}" />
Run Code Online (Sandbox Code Playgroud)
现在,我想绑定一个整数,并显示+和 - 符号(即+6或-4).
<TextBlock Text="{Binding MyOtherCustomObject, StringFormat={}{0:+#}}" />
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用.这是可能的还是我必须为此编写完整的转换器?
编辑
尼古拉斯的帖子让我得到了答案:
<TextBlock Text="{Binding MyOtherCustomObject, StringFormat={}{0:+#;-#;''}}" />
Run Code Online (Sandbox Code Playgroud)
实质上,您提供了正数,负数和可选部分的格式,如何处理零.在这种情况下,我声明零应显示为空字符串.
问候,
米歇尔
我在SQL Server 2008中有问卷数据,我想将其转置为矩阵.
我看了几篇关于同一主题的帖子,但我没有得到转动.
给出以下表格:
Question table
Answer table
Customer table
列:
[CustomerID],[QuestionName_1],...,[QuestionName_n]< - 动态数问题的列)
的数据:
CustomerID,Answer_1,...,Answer_n
检索列的代码:
DECLARE @columns VARCHAR(8000)
SELECT @columns = COALESCE(@columns + ',[' + cast(QuestionName as varchar) + ']',
'[' + cast(QuestionName as varchar)+ ']')
FROM Answer A
INNER JOIN Question Q ON A.QuestionID = Q.QuestionID
INNER JOIN Customer C ON A.CustomerID = C.CustomerID
GROUP BY Q.QuestionName
SET @columns = '[CustomerID],' + @columns
DECLARE @query VARCHAR(8000) …Run Code Online (Sandbox Code Playgroud) 我使用此代码将数据加载到工作表(C#、EPPlus 4.04)中并自动设置列宽:
workSheet.Cells["A1"].LoadFromCollection(itemsToExport, PrintHeaders: true);
workSheet.Cells[workSheet.Dimension.Address].AutoFitColumns();
Run Code Online (Sandbox Code Playgroud)
有一个显着的性能损失,似乎与工作表中的记录数量成线性关系。例如,15K 记录有 2 秒的差异,我必须创建多个文件。
有没有办法在不诉诸异步处理等的情况下加快速度?
Ps,在填充数据之前设置 AutoFitColumns 不起作用,列的宽度对于数据来说太小了。
鉴于此WSDL:
Adyen通知WSDL
和此svcutil命令创建相应的C#类:
svcutil.exe https://ca-test.adyen.com/ca/services/Notification?wsdl /t:code /l:c# /o:"C:\NotificationRequest.cs" /ct:System.Collections.Generic.List`1
Run Code Online (Sandbox Code Playgroud)
而OperationContract:
[OperationContract(Action="http://notification.services.adyen.com/sendNotification")]
string SendNotification(NotificationRequest notificationRequest);
Run Code Online (Sandbox Code Playgroud)
调用SendNotification方法(SOAP)与WCFStorm一起使用.
但是,当我通过具有测试按钮的第三方网站调用该方法时,我得到:
OperationFormatter遇到无效的Message正文.预计会找到名为"SendNotification"的节点类型"Element"和名称空间" http://tempuri.org/ ".找到名为"ns1:sendNotification"的节点类型"Element"和名称空间" http://notification.services.adyen.com "
这是第三方请求调用的一部分,它给我提出了问题:
<soap:Body><ns1:sendNotification xmlns:ns1="http://notification.services.adyen.com"><ns1:notification>
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题,最好是一些小的C#属性指令?
更新通过向IPSPNotificationService ServiceContract 添加命名空间来
修复问题的" http://tempuri.org/ "部分:
[ServiceContract(Namespace = "http://notification.services.adyen.com")]
public interface IPSPNotificationService
Run Code Online (Sandbox Code Playgroud)
更新2
通过更改OperationContract WCFStorm仍然可以正常工作.现在该方法也被第三方调用触发,但在这种情况下,NotificationRequest参数为NULL:
[OperationContract(Action="http://notification.services.adyen.com/sendNotification", Name="sendNotification")]
string SendNotification(NotificationRequest notificationRequest);
Run Code Online (Sandbox Code Playgroud)
更新3
让我们以更简单的方式来看待它.鉴于下面的xml,我需要什么样的合同/服务装饰?
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>0</EventID>
<Type>3</Type>
<SubType Name="Information">0</SubType>
<Level>8</Level>
<TimeCreated SystemTime="2016-03-08T10:27:30.7325676Z" />
<Source Name="System.ServiceModel.MessageLogging" />
<Correlation ActivityID="{742fac90-3b97-4c9f-aee3-fd2589f75c37}" />
<Execution ProcessName="obscured" ProcessID="13280" ThreadID="11" />
<Channel />
<Computer>obscured</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<MessageLogTraceRecord …Run Code Online (Sandbox Code Playgroud) 我执行对不太稳定的外部服务的调用,因此抛出 WebException。
我想重试几次,在最后一次尝试后我想抛出收到的最后一个错误。
public static Policy WaitAndRetryPolicy<T>(short nrOfRetryAttempts = 5) where T : Exception
{
var waitAndRetry = Policy
.Handle<T>()
.WaitAndRetry(nrOfRetryAttempts, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
var fallbackForLastError = Policy
.Handle<T>()
.Fallback(
fallbackAction: () => { },
onFallback: (ex) => { throw ex; });
return Policy.Wrap(fallbackForLastError, waitAndRetry);
}
Run Code Online (Sandbox Code Playgroud)
调用者,旧版 VB.Net:
Dim retryPolicy = Policies.WaitAndRetryPolicy(Of WebException)()
Dim theResult = retryPolicy.
ExecuteAndCapture(Function()
Return aProxy.GetSomething(a, b)
End Function).Result
Run Code Online (Sandbox Code Playgroud)
当我运行上面描述的代码时,结果保持为空,并且似乎没有调用该服务。如果我只使用 WaitAndRetryPolicy 而不使用Fallback函数,则会调用该服务并且重试机制按预期工作(当然不会引发异常)。
如何实现我的目标,而无需检查调用者代码中的PolicyResult.FinalException ?
c# ×5
.net ×2
attributes ×1
binding ×1
epplus-4 ×1
excel ×1
formatting ×1
html ×1
integer ×1
oledb ×1
performance ×1
pivot ×1
polly ×1
regex ×1
replace ×1
soap ×1
svcutil.exe ×1
tfs ×1
tfs-workitem ×1
transpose ×1
vb.net ×1
wcf ×1
wpf ×1
xml-comments ×1
xsd ×1