基本上,我有一个基于DependencyProperty(FooProperty)绘制子项的面板.
如果FooProperty为真,则安排孩子; 否则,没有安排.第一个直通很好,但是当一个孩子将它的FooProperty从true(draw)更改为false(不绘制)时,该ArrangeOverride方法会跳过它并且孩子仍然被绘制.
我想要而不是跳过那些不应该画的孩子我需要一些方法来画它们吗?
public class Foo
{
private readonly Bar _bar;
}
public class Foo2
{
private Bar _bar;
}
Run Code Online (Sandbox Code Playgroud)
我认为将其标记为只读是没有任何好处的.这是私人的,如果我尝试在内部做一些修改它,那我是愚蠢的,因为我知道我希望我的班级表现如何?那么,有什么意义呢?我不认为这里有任何性能提升,所以不可能.
基本上,我在我的课上有一个方法,Action<T>如果满足某些条件,就会调用它.如何进行单元测试以确保调用操作?
public class MyClass<T>
{
private IDBService _dbService;
private Action<T> _action;
public MyClass(IDBService dbService, Action<T> action)
{
if (dbService == null) throw new ArgumentNullException("dbService");
if (action == null) throw new ArgumentNullException("action");
_dbService = dbService;
_action = action;
}
public void CallActionIfPossible(T param)
{
if (_dbService.IsTopUser)
action(param);
}
}
Run Code Online (Sandbox Code Playgroud) 我有以下情况:
我有一些ViewModel对象,其中一些实现了一个接口ISomeInterface,有些则没有。这些接口公开了一个名为SomeEnumeration(IEnumerable<T>)的属性。
例如:
public sealed class ViewModelA : ViewModelBase, ISomeInterface
{
// ...
IEnumerable<Foo> ISomeInterface.SomeEnumeration
{
get { ...; }
}
}
public sealed class ViewModelB : ViewModelBase
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
我的XAML,到目前为止,已经被设计的方式,无论是的ViewModels的正好有我反对(即绑定属性PropertyA,PropertyB等等)。我还没有遇到过这样的情况,即我设置为的ViewModels上不存在我要绑定的属性DataContext。但是,现在,我将……并且它将针对显式实现的属性(我不确定这是否会对WPF绑定引擎产生任何影响)。
基本上,我的xaml如下所示:
<StackPanel
Visiblity="{Binding Path=SomeEnumeration, Converter={StaticResource AnyConverter}">
...
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
我不确定这是否还能工作,因为:
DataContext属性都包含该属性(如果不包含,则应将其隐藏)...在这种情况下,我该怎么办?DataContext确实包含该属性的,它是显式实现的……您是否必须先强制转换?如何对列表框内容进行排序?在我看来,将它保留在UI层更有意义,因为排序不会影响我的业务逻辑,所以它可能在xaml或代码隐藏中.我无法弄明白该怎么做.
码:
public class ABC.Server.Modules.XService :
ABC.Server.Common.IGenericService<ABC.Server.Module.X.MyType>
{
ABC.Server.Common.GenericResponse<ABC.Server.Module.X.MyType> DoFoo(ABC.Server.Common.GenericRequest<ABC.Server.Module.X.MyType> request)
{
//Do Stuff Here
}
}
Run Code Online (Sandbox Code Playgroud)
简明代码:
public class XService :
IGenericService<MyType>
{
GenericResponse<MyType> DoFoo(GenericRequest<MyType> request)
{
//Do Stuff Here
}
}
Run Code Online (Sandbox Code Playgroud)
Web.config:
我不使用SVC文件,而是在Web.config中处理了这些信息:
<add factory="System.ServiceModel.Activation.ServiceHostFactory"
relativeAddress="Services/X.svc"
service="ABC.Server.Modules.X.XService"/>
<service name="ABC.Server.Modules.X.XService"
behaviorConfiguration="StandardBehavior">
<endpoint bindingConfiguration="StandardBinding"
binding="basicHttpBinding"
contract="?" />
</service>
Run Code Online (Sandbox Code Playgroud)
我如何在合同名称中加入实际工作?
我有一个由字符(管道符)分隔的长字符串.我需要在第3和第4个管道之间获取文本.不知道如何去做...
打开正则表达式或非正则表达式,以最有效率为准.特别是对扩展方法开放,如果不存在则可以传入:
我有一个需要访问TextBox的脚本,但ASP.NET会生成一些疯狂的名称:ctl00$ContentPlaceHolder1$txtEmpFirstName...客户端脚本使得无法知道如何访问此控件.
我们如何解决这个问题?我还需要能够在按下按钮时从服务器端代码访问文本,如果这有所不同?
我不确定这两个签名是否有任何真正的区别:
public static class MyCustomExtensions
{
public static bool IsFoo(this IComparable<T> value, T other)
where T : IComparable<T>
{
// ...
}
public static bool IsFoo(this T value, T other)
where T : IComparable<T>
{
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
我认为这些操作几乎完全相同,但我不太确定......我在这里俯瞰什么?
c# ×6
wpf ×3
generics ×2
action ×1
asp.net ×1
binding ×1
contract ×1
data-binding ×1
datacontext ×1
endpoint ×1
interface ×1
invoke ×1
itemssource ×1
javascript ×1
moq ×1
panel ×1
parsing ×1
private ×1
readonly ×1
regex ×1
server-side ×1
sorting ×1
unit-testing ×1
wcf ×1