我最近安装了Visual Studio 11 Beta,我正在尝试更新现有的4.0项目以使用4.5.在程序中,它使用编译一些动态生成的代码CSharpCodeProvider.
/// <summary>
/// Compile and return a reference to the compiled assembly
/// </summary>
private Assembly Compile()
{
var referencedDlls = new List<string>
{
"mscorlib.dll",
"System.dll",
"System.Core.dll",
};
referencedDlls.AddRange(RequiredReferences);
var parameters = new CompilerParameters(
assemblyNames: referencedDlls.ToArray(),
outputName: GeneratedDllFileName,
// only include debug information if we are currently debugging
includeDebugInformation: Debugger.IsAttached);
parameters.TreatWarningsAsErrors = false;
parameters.WarningLevel = 0;
parameters.GenerateExecutable = false;
parameters.GenerateInMemory = false;
parameters.CompilerOptions = "/optimize+ /platform:x64";
string[] files = Directory.GetFiles(GenerationDirectory, "*.cs");
var compiler = …Run Code Online (Sandbox Code Playgroud) 我有一个用户控件中使用的Xaml,用作属性网格中的编辑器.问题是,从后面的代码中附加行为的c#会是什么样子?
<i:Interaction.Behaviors>
<igExt:XamComboEditorSelectedItemsBehavior SelectedItems="{Binding SelectedItems, ElementName=_uc}"/>
</i:Interaction.Behaviors>
Run Code Online (Sandbox Code Playgroud)
因为这是在一个动态加载到PropertyGrid中的编辑器上,所以我只是创建一个编辑器实例,其中包含来自代码的绑定,而不是必须拥有非常简短且只包含一个编辑器的不同xaml文件.
或者更简单地重新实现行为中的所有代码并在我在后面的代码中创建编辑器时调用它?
我有一个使用小数执行大量计算的系统,偶尔会添加相同的数字,但返回不同的结果,+/ - 0.000000000000000000000000001
这是一个简短的例子:
decimal a = 2.016879990455473621256359079m;
decimal b = 0.8401819425625631128956517177m;
decimal c = 0.4507062854741283043456903406m;
decimal d = 6.7922317815078349615022988627m;
decimal result1 = a + b + c + d;
decimal result2 = a + d + c + b;
Console.WriteLine((result1 == result2) ? "Same" : "DIFFERENT");
Console.WriteLine(result1);
Console.WriteLine(result2);
Run Code Online (Sandbox Code Playgroud)
那输出:
DIFFERENT
10.100000000000000000000000000
10.100000000000000000000000001
Run Code Online (Sandbox Code Playgroud)
差异很小,没有实际效果,但有人见过这样的事情吗?我期望在添加相同的数字时,您将始终获得相同的结果.
我有以下数据帧:
import pandas as pd
index = pd.date_range('2013-1-1',periods=10,freq='15Min')
data = pd.DataFrame(data=[1,2,3,4,5,6,7,8,9,0], columns=['value'], index=index)
Run Code Online (Sandbox Code Playgroud)
如何根据索引值生成掩码?我知道我可以这样做:
data['value'] > 3
Out[40]:
2013-01-01 00:00:00 False
2013-01-01 00:15:00 False
2013-01-01 00:30:00 False
2013-01-01 00:45:00 True
2013-01-01 01:00:00 True
2013-01-01 01:15:00 True
2013-01-01 01:30:00 True
2013-01-01 01:45:00 True
2013-01-01 02:00:00 True
2013-01-01 02:15:00 False
Freq: 15T, Name: value, dtype: bool
Run Code Online (Sandbox Code Playgroud)
我想生成一个掩码,只考虑索引在一定范围内的某些行.我想做一些像data['index'].time() > datetime.time(1,15)生成面具的事情.当然,除非data['index']索引不是列的名称,否则会失败.如何引用掩码中行的索引值?
使用此在线测试仪,很容易看到以下问题
我有一个web.config看起来像:
<?xml version="1.0"?>
<configuration>
<nlog/>
</configuration>
Run Code Online (Sandbox Code Playgroud)
转换如下所示:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<xdt:Import assembly="AppHarbor.TransformTester" namespace="AppHarbor.TransformTester.Transforms"/>
<nlog xdt:Transform="Replace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets async="true">
<target name="LogMill" xsi:type="FallbackGroup" returnToFirstOnSuccess="true">
<target xsi:type="LogMillMessageBus"/>
<target xsi:type="File" fileName="..\LogMill-FailSafe.log" layout="${TextErrorLayout}"/>
</target>
</targets>
</nlog>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但是输出不是我期望的结果,它将xsi名称空间声明下移到使用它的元素,这将导致nlog无法解析带有错误的配置 Parameter p4 not supported on FallbackGroupTarget
<?xml version="1.0"?>
<configuration>
<nlog>
<targets async="true">
<target name="LogMill" p4:type="FallbackGroup" returnToFirstOnSuccess="true" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">
<target p4:type="LogMillMessageBus" /><target p4:type="File" fileName="..\LogMill-FailSafe.log" layout="${TextErrorLayout}" />
</target>
</targets>
</nlog>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我一直在尝试将DynamicEdmModelCreation示例从https://github.com/OData/ODataSamples/tree/master/WebApi/v4/DynamicEdmModelCreation调整为可行的v3版本(我想将odata直接加载到excel中,而不是支持odata v4)
我添加config.AddODataQueryFilter()到设置和[EnableQuery]Controller的get方法,但我现在收到异常:
System.Web.Http.OData.dll中发生'System.Runtime.Serialization.SerializationException'类型的第一次机会异常
附加信息:'EnumerableQuery`1'无法使用ODataMediaTypeFormatter序列化.
这是从https://github.com/ASP-NET-MVC/aspnetwebstack/blob/master/OData/src/System.Web.Http.OData/OData/Formatter/ODataMediaTypeFormatter.cs#L577抛出的
事实上我的Controller的Get方法正在返回EdmEntityObjectCollection一个问题吗?我原本以为只需添加EnableQuery属性就足以让框架知道如何将该查询操作应用于EdmEntityObjectCollection我正在返回的内容(这将包含比可能需要的更多的数据)
我已经为NLog创建了一个自定义目标,它工作正常,但是当我编辑nlog.config文件时,我得到一个警告This is an invalid xsi:type 'http://www.nlog-project.org/schemas/NLog.xsd:LogMillMessageBus'
这是我的nlog.config文件:
<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="Core.v40.NLog.Extensions"/>
</extensions>
<targets async="true">
<target name="LogMillMessageBus" xsi:type="LogMillMessageBus"/>
<target name="Console" xsi:type="ColoredConsole" layout="${date:format=HH\:mm\:ss.fff} ${message} ${exception:format=tostring}${event-context:item=Details}"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="Console" />
<logger name="*" minlevel="Debug" writeTo="LogMillMessageBus" />
</rules>
</nlog>
Run Code Online (Sandbox Code Playgroud)
我可以以某种方式创建我自己的xsd,附加http://nlog-project.org/schemas/NLog.xsd,以便我不会收到警告吗?