如何判断计算机是否具有Visual Studio 2010 Ultimate Service Pack 1?
我假设它是版本号,但我不知道什么版本意味着什么.(我看的版本是10.0.30319.1 RTMRel.)
我需要一种方法来做到这一点:
"test, and test but not testing. But yes to test".Replace("test", "text")
Run Code Online (Sandbox Code Playgroud)
归还这个:
"text, and text but not testing. But yes to text"
Run Code Online (Sandbox Code Playgroud)
基本上我想替换整个单词,但不是部分匹配.
注意:我将不得不使用VB(SSRS 2008代码),但C#是我的正常语言,因此两者中的响应都很好.
我IRespository
在以下代码中注册了两次(带名字):
// Setup the Client Repository
IOC.Container.RegisterType<ClientEntities>(new InjectionConstructor());
IOC.Container.RegisterType<IRepository, GenericRepository>
("Client", new InjectionConstructor(typeof(ClientEntities)));
// Setup the Customer Repository
IOC.Container.RegisterType<CustomerEntities>(new InjectionConstructor());
IOC.Container.RegisterType<IRepository, GenericRepository>
("Customer", new InjectionConstructor(typeof(CustomerEntities)));
IOC.Container.RegisterType<IClientModel, ClientModel>();
IOC.Container.RegisterType<ICustomerModel, CustomerModel>();
Run Code Online (Sandbox Code Playgroud)
但是当我想要解决这个问题(使用IRepository
)时,我必须像这样做一个手动解决方案:
public ClientModel(IUnityContainer container)
{
this.dataAccess = container.Resolve<IRepository>(Client);
.....
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是在构造函数中解析它(就像IUnityContainer
).我需要一些方法来说明要解析的命名类型.
这样的事情:( 注意:不是真正的代码)
public ClientModel([NamedDependancy("Client")] IRepository dataAccess)
{
this.dataAccess = dataAccess;
.....
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让我的假代码工作?
在JavaScript中,我可以这样做:
something = 'testing';
Run Code Online (Sandbox Code Playgroud)
然后在另一个文件中:
if (something === 'testing')
Run Code Online (Sandbox Code Playgroud)
它将something
被定义(只要它们以正确的顺序被调用).
我似乎无法弄清楚如何在TypeScript中做到这一点.
这就是我尝试过的.
在.d.ts文件中:
interface Window { something: string; }
Run Code Online (Sandbox Code Playgroud)
然后在我的main.ts文件中:
window.something = 'testing';
Run Code Online (Sandbox Code Playgroud)
然后在另一个文件中:
if (window.something === 'testing')
Run Code Online (Sandbox Code Playgroud)
这很有效.但我希望能够失去window.
它的一部分,让我的something
全球化.有没有办法在TypeScript中做到这一点?
(如果有人感兴趣,我真的想为我的应用程序设置日志记录.我希望能够log.Debug
从任何文件调用而无需导入和创建对象.)
我有一个看起来像这样的方法:
private async void DoStuff(long idToLookUp)
{
IOrder order = await orderService.LookUpIdAsync(idToLookUp);
// Close the search
IsSearchShowing = false;
}
//Other stuff in case you want to see it
public DelegateCommand<long> DoLookupCommand{ get; set; }
ViewModel()
{
DoLookupCommand= new DelegateCommand<long>(DoStuff);
}
Run Code Online (Sandbox Code Playgroud)
我试图对它进行单元测试:
[TestMethod]
public void TestDoStuff()
{
//+ Arrange
myViewModel.IsSearchShowing = true;
// container is my Unity container and it setup in the init method.
container.Resolve<IOrderService>().Returns(orderService);
orderService = Substitute.For<IOrderService>();
orderService.LookUpIdAsync(Arg.Any<long>())
.Returns(new Task<IOrder>(() => null));
//+ Act
myViewModel.DoLookupCommand.Execute(0);
//+ Assert
myViewModel.IsSearchShowing.Should().BeFalse(); …
Run Code Online (Sandbox Code Playgroud) public object MethodName(ref float y)
{
//method
}
Run Code Online (Sandbox Code Playgroud)
如何为此方法定义Func委托?
背景:
我有一个非常大的OData模型,目前正在使用WCF数据服务(OData)来公开它.但是,微软已经表示WCF数据服务已经死亡,Web API OData就是他们的目标.
所以我正在研究如何使Web API OData与WCF数据服务一起工作.
问题设置:
模型的某些部分不需要保护,但有些部分需要保护.例如,客户列表需要安全性来限制谁可以读取它,但我有其他列表,如产品列表,任何人都可以查看.
Customers实体有许多可以访问它的关联.如果您计算2个级别的关联,那么可以通过关联(通过关联)获得数百种方式.例如Prodcuts.First().Orders.First().Customer
.由于客户是我系统的核心,因此您可以从大多数实体开始,最终将您的方式与客户列表相关联.
WCF数据服务有一种方法可以通过以下方法为特定实体提供安全性:
[QueryInterceptor("Customers")]
public Expression<Func<Customer, bool>> CheckCustomerAccess()
{
return DoesCurrentUserHaveAccessToCustomers();
}
Run Code Online (Sandbox Code Playgroud)
当我看到Web API OData时,我没有看到这样的东西.另外,我非常担心,因为我正在制作的控制器在跟随关联时似乎没有被调用.(意思是我不能把安全放在CustomersController
.)
我担心我将不得不尝试以某种方式列举协会如何获得客户并为每个客户提供安全性的所有方式.
问题:
有没有办法将安全性放在Web API OData中的特定实体上? (无需枚举所有可能以某种方式扩展到该实体的关联?)
有没有办法将ZPL(Zebra编程语言)发送到.NET中的打印机?
我有在Delphi中执行此操作的代码,但它并不漂亮,我宁愿不尝试在.NET中重新创建它.
c# ×8
.net ×3
api ×1
async-await ×1
barcode ×1
c#-3.0 ×1
components ×1
delegates ×1
func ×1
odata ×1
reference ×1
string ×1
typescript ×1
unit-testing ×1
vb.net ×1
zpl ×1
zpl-ii ×1