可能不是,但我想问.重定向会避免双重发布吗?我知道有更好的方法可以避免它,但大多数双重发布怎么办?从我的理解它当前页面没有加载和用户点击刷新,而不是多次点击发布的bc.我认为重定向信息非常小,当用户点击刷新时,它只会尝试加载新页面而不会重新发送POST数据.
它只是一个非常简单快速的解决方案,我只是想知道它是否高效?
嗨,我有以下场景,我将尽力解释,如果这是一个愚蠢的问题,请提前预测.我有两个接口(出于本示例的目的,它们中没有任何内容)
public interface interfaceA {}
public interface interfaceB: interfaceA {}
Run Code Online (Sandbox Code Playgroud)
还有2节课
public classA<interfaceA> {}
public classB: classA<interfaceB> { }
Run Code Online (Sandbox Code Playgroud)
现在还有其他地方我有一个接受泛型类型作为参数的方法:
public static void DoSomething( ClassA<interfaceB> p_val ) {}
Run Code Online (Sandbox Code Playgroud)
好的,我在创建对象时使用这些类.
ClassB obj1 = new ClassB();
ClassA<interfaceA> obj2 = new ClassA<interfaceA>();
Run Code Online (Sandbox Code Playgroud)
好吧,当我将obj1传递给DoSomething()时,当我尝试将obj2传递给我的DoSomething()方法时,我得到一个编译错误,说它无法从interfaceA转换为interfaceB.
这种意义有道理,因为在我的方法中,泛型param类型是显式的interfaceB.但是,如果我希望该方法接受两种泛型类型(obj1和obj2),我该怎么办?希望这是有道理的.
关于我如何将其重构为一个体面的模式,我正在努力解决一个小问题.
public class DocumentLibrary
{
private IFileSystem fileSystem;
private IDocumentLibraryUser user;
public DocumentLibrary(IDocumentLibraryUser user) : this(user, FileSystemFrom(user)) { }
public DocumentLibrary(IDocumentLibraryUser user, IFileSystem fileSystem)
{
this.user = user;
this.fileSystem = fileSystem;
}
public void Create(IWorkerDocument document)
{
document.SaveTo(fileSystem);
}
public IWorkerDocument AttemptContractRetrieval()
{
return new Contract(fileSystem, user);
}
public IWorkerDocument AttemptAssignmentRetrieval()
{
return new Assignment(fileSystem, user);
}
private static IFileSystem FileSystemFrom(IDocumentLibraryUser user)
{
var userLibraryDirectory = new DirectoryInfo("/DocLib/" + EnvironmentName() + "/" + user.Id);
return new FileSystem(userLibraryDirectory);
}
private static …Run Code Online (Sandbox Code Playgroud) 如果我有一个如下所示的实用方法,我该如何进行单元测试呢?好像我想确定输出是否正确我似乎必须将代码构建到测试方法中?我可以看到是否存在条件逻辑,例如输入字符串是否为空返回null,但测试正确的输出似乎很棘手.
public static string EncodeTo64(string input)
{
byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes(input);
string returnValue = System.Convert.ToBase64String(b);
return returnValue;
}
Run Code Online (Sandbox Code Playgroud) 我在C#中导入csv文件,有时使用'.',有时使用','作为小数分隔符.
是否有一种确定小数点分隔符的最佳方法,而不是从最后一个字符到第一个字符的计数?
提前致谢.
富兰克林Albricias.
第一件事......我是模式世界的新手,所以在任何地方错误都要纠正我情景:有多家公司提供多种差异化产品
所以有3个实体,即公司,他们的产品和产品的大小
我已经实现了抽象模式,这样我就可以创建IProductFactory接口的实例来获得所需的产品......
以下是抽象工厂模式的实现正确??? 如果没有那么请更正方法+还告诉我是否有任何其他模式可以用于这种情况提前谢谢...
public enum Companies
{
Samsung = 0,
LG = 1,
Philips = 2,
Sony = 3
}
public enum Product
{
PlasmaTv = 0,
DVD = 1
}
public enum ProductSize
{
FortyTwoInch,
FiftyFiveInch
}
interface IProductFactory
{
IPhilips GetPhilipsProduct();
ISony GetSonyProduct();
}
interface ISony
{
string CreateProducts(Product product, ProductSize size);
}
interface IPhilips
{
string CreateProducts(Product product, ProductSize size);
}
class ProductFactory : IProductFactory
{
public IPhilips GetPhilipsProduct()
{
return new Philips();
}
public …Run Code Online (Sandbox Code Playgroud) 我在IMultiValueConverter中编写了这个转换代码
public object Convert(object[] values ...)
{
return new Microsoft.Practices.Composite.Presentation.Commands.DelegateCommand<object>(
delegate
{
foreach (ICommand cmd in values)
{
cmd.Execute(null);
}
});
}
Run Code Online (Sandbox Code Playgroud)
values参数是两个命令对象,但是当回调执行(WPF mulibinding)时,values数组仅包含空值.为什么?如何解决这个问题?