的ConditionalAttribute可用于除去呼叫取决于所定义的编译器的符号的显着方法.我假设我们不能自己创建这个类,因为编译器必须专门寻找它.
我想知道编译器或语言使用的其他类是什么,我们无法自己编码.
我已经按照这个建议来调试NUnit测试.
http://www.blackwasp.co.uk/NUnitCSharpExpress.aspx
但是,我有几个测试Assert.Throws<...>,这会导致调试器在我正在测试的异常发生时中断,当我真的希望它在这些调用之外发生异常时中断.
如何让调试器忽略这些方法中引起的异常?
编辑:我的事件尝试了下面,这是行不通的!
[Test]
public void InstanciatingWithNullParameterThrowsException()
{
try
{
Assert.Throws<ArgumentNullException>(() => new CachedStreamingEnumerable<int>(null));
// This still throws and stops be being able to debug tests called after this one
}
catch
{
}
}
Run Code Online (Sandbox Code Playgroud) 我在某些客户端计算机上部署了我的应用程序.
我真的需要在运行时看到我的应用程序的内容,我的日志记录还不够.
计算机在不同的网络上,我在办公室没有任何连接.
是否有一些工具可以记录我的应用程序的执行情况?至少输入功能输出?
我正在尝试Texture2D使用默认导入程序(XML内容)加载包含xml文件的自定义类,而不使用处理器.
大量的在线研究和大量处理其他错误的研究引导我使用这种XML:
<?xml version="1.0" encoding="utf-16"?>
<XnaContent xmlns:Components="Entities.Components">
<Asset Type="EntitiesContentPipeline.EntityTemplateContent">
<Name>entity name</Name>
<TestTexture>
<Reference>#External1</Reference>
</TestTexture>
</Asset>
<ExternalReferences>
<ExternalReference ID="#External1" TargetType="Microsoft.Xna.Framework.Graphics.Texture2D">C:\Documents and Settings\GDuckett\My Documents\Visual Studio 2010\Projects\Gravitron\Gravitron\Gravitron\bin\x86\Debug\Content\Bullet.xnb</ExternalReference>
</ExternalReferences>
</XnaContent>
Run Code Online (Sandbox Code Playgroud)
是的,我也不喜欢硬编码的路径,但是如果我能够在没有自定义阅读器的情况下工作,或者每个包含Texture2Di的类型的编写者都可以使用它.
下面是我的类的内容版本(由管道使用):
[ContentSerializerRuntimeType("Entities.Content.EntityTemplate, Entities")]
public class EntityTemplateContent
{
public string Name;
public ExternalReference<Texture2D> TestTexture;
public EntityTemplateContent()
{
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我的运行时版本:
public class EntityTemplate
{
public string Name;
public Texture2D TestTexture;
public EntityTemplate()
{
}
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试var test = Content.Load<EntityTemplate>("BulletTemplate");下面做的是我得到的错误:
加载"Bullet"时出错.ContentTypeReader Microsoft.Xna.Framework.Content.Texture2DReader,Microsoft.Xna.Framework.Graphics,Version = 4.0.0.0,Culture = neutral,PublicKeyToken …
我理解如何在两种不同类型之间进行,但我的问题是; 为什么这种类型的差异?
我原以为它会是ParamterInfo对象的属性,而不是单独的特殊类型.
假设它表现为在反射分离型,因为这是它是如何在内部,什么语言的好处是有具有该作为一个单独的类型(我猜简单的方法重载或东西)?
在一个类似的说明,为什么ref做一个不同的类型,但out没有(我不能想到ref作为一个单独的类型的原因,不适用out)?
我有一个组合元素的公式列表:
A + B + C = X
D + E + F = Y
G + H + I = Z
Run Code Online (Sandbox Code Playgroud)
我想确保给定任意随机4个元素,永远不会有超过1个适用的公式.例如,不应允许下面的公式,就像我得到元素A,B,C和D那样两者都适用:
A + B + C = X
B + C + D = Y
Run Code Online (Sandbox Code Playgroud)
每个公式都由LHS中的3个元素组成,它是我想要强制执行规则的LHS.如果有帮助,这些元素是可排序的.
一个替代的,等效的问题:
我有一个包含3个元素的数组列表:List<Element[3]>如何确保没有2个元素出现在多个数组中.
对于大量元素和大量公式(除了暴力强制)这样做的合理有效(运行时速度)方法是什么?
我想渲染一个模型,然后,如果特定的顶点(我将如何标记它们?)是可见的,我想渲染它们所在的2D.
我该怎么做呢?
应用程序配置文件中标记<Clear \>内的XML元素的用途是什么<AppSettings>?
我看到它删除了以前添加的设置(请参阅下面的代码),但为什么要这样做呢?
<appSettings>
<add key="LogInformation" value="False"/>
<add key="LogAPIMessages" value="False"/>
<add key="LogErrors" value="True"/>
<clear/> <!--This line removes previously added keys.-->
</appSettings>
Run Code Online (Sandbox Code Playgroud)
我也明白,在代码中操作应用程序设置时,您可以清除现有密钥,但为什么要使用<clear\>XML元素?
而且,出于习惯,我一直把<clear\>元素放在任何<add>元素之前.如果我不这样做,我是否需要这样做?
我想创建一个应用方法的FxRule,只有在从特定类调用该方法时才会这样.
注意:我不想只是将规则应用于特定类的方法,我希望能够处理调用其他方法调用其他方法进行装箱的方法.
我想让FxCop报告与拳击方法相关的问题.
以下是我到目前为止的代码:
using System;
using System.Linq;
using Microsoft.FxCop.Sdk;
using System.Collections.Generic;
class CheckUpdatableComponents : BaseIntrospectionRule
{
private string[] MethodsToCheck = new string[] { "BeginDraw", "BeginRun", "Draw", "EndRun", "EndDraw", "Update" };
/// <summary>Gets the base class hooked up.</summary>
public CheckUpdatableComponents()
: base("CheckUpdatableComponents", "FxCopRules.Rules", typeof(CheckUpdatableComponents).Assembly)
{
}
public override ProblemCollection Check(string namespaceName, TypeNodeCollection types)
{
foreach (var type in types.Where(T => IsSubClassOf(T, "Microsoft.Xna.Framework.Game")))
{
foreach (var MethodToCheck in MethodsToCheck)
{
Method RunMethod = type.GetMethod(Identifier.For(MethodToCheck));
if (RunMethod != null)
{
Visit(RunMethod);
} …Run Code Online (Sandbox Code Playgroud) 我正在使用MiniProfiler来配置我的sql命令.
我正在处理的一个问题是由linq生成的重复INSERT语句.
我已将它们转换为SqlBulkCopy命令,但现在它似乎没有将它记录在MiniProfiler的sql视图中.
是否会为SqlBulkCopy提供相关的命令字符串?
是否可以将批量副本显示在sql命令列表中?
我至少可以在%sql位中计算它吗?
我知道我可以使用MiniProfiler.Current.Step("Doing Bulk Copy")但不会算作SQL,并且不会在列表中显示任何细节.
目前的代码如下:
public static void BulkInsertAll<T>(this DataContext dc, IEnumerable<T> entities)
{
var conn = (dc.Connection as ProfiledDbConnection).InnerConnection as SqlConnection;
conn.Open();
Type t = typeof(T);
var tableAttribute = (TableAttribute)t.GetCustomAttributes(
typeof(TableAttribute), false).Single();
var bulkCopy = new SqlBulkCopy(conn)
{
DestinationTableName = tableAttribute.Name
};
//....
bulkCopy.WriteToServer(table);
}
Run Code Online (Sandbox Code Playgroud) c# ×10
.net ×4
xna ×2
3d ×1
algorithm ×1
app-config ×1
appsettings ×1
attributes ×1
debugging ×1
fxcop ×1
nunit ×1
permutation ×1
reflection ×1
sqlbulkcopy ×1
vb.net ×1
xna-4.0 ×1