我Line graph在我的应用程序中使用并且工作正常.我试图在折线图中绘制标记点,但标记点没有显示.在折线图标记属性中,我选择markerSize了5,markerStyle圆圈,MarkerColor蓝色.请参阅下面的代码.
series1.Name = "Series1";
series1.IsVisibleInLegend = false;
series1.IsXValueIndexed = true;
series1.XValueType = ChartValueType.Time;
series1.YAxisType = AxisType.Primary;
series1.ChartType = SeriesChartType.Line;
this.chart1.Series.Add(series1);
Run Code Online (Sandbox Code Playgroud) 我正在检查Jon Skeet的MoreLinq,我对获取扩展源代码感到好奇
将实现如下
/// <summary>
/// Ensures that a source sequence of <see cref="IDisposable"/>
/// objects are all acquired successfully. If the acquisition of any
/// one <see cref="IDisposable"/> fails then those successfully
/// acquired till that point are disposed.
/// </summary>
/// <typeparam name="TSource">Type of elements in <paramref name="source"/> sequence.</typeparam>
/// <param name="source">Source sequence of <see cref="IDisposable"/> objects.</param>
/// <returns>
/// Returns an array of all the acquired <see cref="IDisposable"/>
/// object and in source order.
/// </returns> …Run Code Online (Sandbox Code Playgroud) 使用asp.net 5我喜欢我的控制器注入Func<T>而不是T
例如:
public HomeController(Func<Interfaces.IUnitOfWork> uow)
Run Code Online (Sandbox Code Playgroud)
代替
public HomeController(Interfaces.IUnitOfWork uow)
Run Code Online (Sandbox Code Playgroud)
是否可以使用内置DI或我被迫移动到外部DI?
前几天我正在查看C#Boolean struct元数据.
Boolean实现了IConvertible接口.但看看布尔的成员,我看不到大多数IConvertible成员.
我和一些同事做了一些测试,包括创建我们自己的类,并得出结论,IConvertible必须明确地为Boolean实现.
问题是,为什么它们不可见?我理解它可能是一个"按设计决定"但我明白如果检查元数据的任何人都可以看到它会增加更多的价值.
测试在VS2010 .NET4.0中完成
我正在尝试将Dapper.net与Oracle一起使用.
从这篇文章我明白我们可以使用没有前缀的参数,然后dapper将适用于sql server和oracle
如果没有明确的oracle命名参数前缀,我很难让它工作 :
以下查询
sqlConnection.Query("Select * FROM document WHERE id = param1", new { param1 = 963 });
Run Code Online (Sandbox Code Playgroud)
抛出 ORA-00904: "PARAM1": invalid identifier
如果我尝试使用@前缀,它会抛出ORA-00936: missing expression
如果我使用:前缀它按预期工作.但我不希望我的查询在Oracle或Sql Server上依赖(尽可能).
我使用的是最新的nuget软件包版本Dapper.dll 1.12.1.1
我做错了什么或者我误解了这篇文章?
考虑这个例子
public interface IAnimal
{
[Obsolete("Animals can't eat anymore", true)]
void Eat();
}
public class Animal : IAnimal
{
public void Eat()
{
Console.WriteLine("Hello");
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个接口IAnimal与一个废弃的方法.Class Animal实现了该接口.
稍后,我称之为Eat方法:
var animal = new Animal();
animal.Eat();
Run Code Online (Sandbox Code Playgroud)
编译器无法编译(我已将Obsolete标记为给出错误而不是警告).程序编译并调用方法,没有错误.
据我所知,这是编译器的一个错误.我错过了什么吗?
注意:我使用的是VS2010
我试图找到最流畅的方式来断言某个字符串是有效的 Guid。
iterTags.GUID是一个string.
我的第一次尝试以错误结束,因为string没有实现Guid. 好吧,我看到了它的到来,因为它是在黑暗中拍摄的
iterTags.GUID.Should().BeAssignableTo<Guid>();
Run Code Online (Sandbox Code Playgroud)
所以我想出了这个工作解决方案,但它并不流畅
Guid parsedGuid;
if (!Guid.TryParseExact(iterTags.GUID, "D", out parsedGuid))
Assert.Fail("iterTags.GUID: '{0}' is not a valid guid");
Run Code Online (Sandbox Code Playgroud)
阅读文档后,我发现没有更好的方法来进行断言。
我的问题:是否有一种流畅的方法来断言字符串是有效的Guid
或许,类似...
iterTags.GUID.Should().BeParsedAs<Guid>()
Run Code Online (Sandbox Code Playgroud) 我用来svcutil.exe从由WebSphere创建的托管WebService生成代理类,该WebService在后台使用Java。
我在VS2010中使用Framework v3.5 XmlSerializer而不是其DataContractSerializer目标
为每个属性使用以下属性生成代理类
[System.Xml.Serialization.XmlArrayAttribute(Order=20)]
Run Code Online (Sandbox Code Playgroud)
如何告诉实用程序禁止生成Order参数?
当您使用int.Parse("1")作为后缀增量++运算符的操作数时:
var result = int.Parse("1")++;
Run Code Online (Sandbox Code Playgroud)
C#编译器显示错误:
增量或减量运算符的操作数必须是变量,属性或索引器.
我可以理解前缀输入或减少运算符,但不适用于后缀输入或减量运算符.对于带前缀的运算符,没有值执行操作,但在后缀的情况下总会有一个值.与属性相同,在幕后是"getter",因此以相同的方式返回值(假设,未在IL中检查).
我在这里错过了什么?
我有一个通用类型为"G"的类
在我的班级模型中,我有
public class DetailElement : ElementDefinition
Run Code Online (Sandbox Code Playgroud)
假设我有这样的方法
public void DoSomething<G>(G generic)
where G : ElementDefinition
{
if (generic is DetailElement)
{
((DetailElement)generic).DescEN = "Hello people"; //line 1
//////
ElementDefinition element = generic;
((DetailElement)element).DescEN = "Hello again"; //line 3
//////
(generic as DetailElement).DescEN = "Howdy"; //line 5
}
else
{
//do other stuff
}
}
Run Code Online (Sandbox Code Playgroud)
编译器报告第1行中的一个错误:
Cannot convert type 'G' to 'DetailElement'
Run Code Online (Sandbox Code Playgroud)
但第3行工作正常.我可以通过执行第5行编写的代码解决此问题.
我想知道的是,为什么编译器报告第1行中的错误而不是第3行中的错误,因为据我所知,它们是相同的.
编辑:恐怕我可能会遗漏一些重要的框架逻辑
edit2:虽然编译器错误的解决方案很重要,但我的问题是编译器为什么在第1行而不是第3行报告错误.
这里简单的linq到实体查询返回anonymous type.问题是其中一个int?值像参数一样用于获取另一个值int.
我知道的所有方法都不起作用.请告知如何解决这个问题.
public IQueryable<toursistdata> GetxTouristByCategory(string category)
{
var now = System.DateTime.MinValue;
int i;
switch (category)
{
case "arrival":
now = System.DateTime.Now.AddDays(-3);
var arrival = from a in db.xTourist
where a.ArrDate >= now && a.Room == null
select new toursistdata
{
kodt = a.Kod,
name = a.Name,
paxad = a.Paxad,
paxch = a.Paxch,
**//Here is h.Kod is int but KodH is int?**
hotel = (from h in db.Address where h.Kod = (int)a.KodH.HasValue select h.NameC).FirstOrDefault(), …Run Code Online (Sandbox Code Playgroud) 我正在尝试转换一些单位.转换函数如何使用以下内容.得到以下XAML.标记在我的ViewModel中设置为唯一对象.
<TextBox Grid.Row="2" Grid.Column="0" Margin="5" HorizontalAlignment="Right" Tag ="{Binding MyObject1}" Style ="{StaticResource TextBoxStyle}"/>
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" HorizontalAlignment="Right" Tag ="{Binding MyObject2}" Style ="{StaticResource TextBoxStyle}"/>
Run Code Online (Sandbox Code Playgroud)
这种风格......
<Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
<Setter Property="Text">
<Setter.Value>
<MultiBinding Converter="{StaticResource EditUnitsConverterEx}">
<Binding RelativeSource="{RelativeSource Self}" Path="Tag"/>
<Binding Path="IsMetric"/>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
用这个转换器......
class EditUnitsConverter : IMultiValueConverter
{
MyObject item; //
bool IsMetric; // bool telling me what units the system is in
public object Convert(object[] values,
Type targetType,
object parameter,
System.Globalization.CultureInfo culture)
{
string sResult = ""; …Run Code Online (Sandbox Code Playgroud) 我创建了一个TaskScheduler,我将它作为两个不同任务的参数传递.
这样做有什么问题吗?我应该为每个任务创建一个新的TaskScheduler实例吗?
这是示例示例(为简单起见,每个任务中的实际代码都被删除)
var uiSch = System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext();
var t1 = Task.Factory.StartNew<List<Carrier>>(() =>
{
//does stuff
})
.ContinueWith(previous =>
{
//does stuff
},
System.Threading.CancellationToken.None,
TaskContinuationOptions.OnlyOnRanToCompletion,
uiSch);
var t2 = Task.Factory.StartNew<List<Logic.WarehouseLogic.Warehouse>>(() =>
{
//does stuff
})
.ContinueWith(previous =>
{
//does stuff
},
System.Threading.CancellationToken.None,
TaskContinuationOptions.OnlyOnRanToCompletion,
uiSch);
Run Code Online (Sandbox Code Playgroud)
[EDIT1]
我的问题部分与以下错误有关:'当前的SynchronizationContext可能不会被用作TaskScheduler'可在此处找到修复