在我目前的项目中,我必须使用子字符串,我想知道是否有更简单的方法从字符串中获取数字.
示例:我有一个这样的字符串:12个文本文本7个文本
我希望能够获得第一个数字集或第二个数字集.因此,如果我要求数字集1,我将获得12作为回报,如果我要求数字集2,我将获得7作为回报.
谢谢!
在从StructureMap 2.6.4升级到StructureMap 3.1.6之后,我们在嵌套容器中的通用接口的注册停止工作,我找不到它们不再工作的原因.
这是我得到的错误
StructureMap.StructureMapConfigurationException:没有注册默认实例,无法自动确定类型'ITest <ExtendClass>'
以下是演示此问题的示例:
public class StructureMapContainerTests
{
[Test]
public void GlobalContainer()
{
var container = new Container();
container.Configure(x => x.For(typeof(ITest<>)).Use(typeof(Test<>)));
var impl = container.GetInstance<ITest<ExtendClass>>();
Debug.WriteLine(impl.Temp()); //Works
}
[Test]
public void NestedContainer()
{
var container = new Container();
var nestedContainer = container.GetNestedContainer();
nestedContainer.Configure(x => x.For(typeof(ITest<>)).Use(typeof(Test<>)));
var impl = nestedContainer.GetInstance<ITest<ExtendClass>>();
Debug.WriteLine(impl.Temp()); //Doesn't work
}
}
public interface ITest<T> where T : BaseClass
{
string Temp();
}
public class Test<T> : ITest<T> where T : ExtendClass
{
public string …Run Code Online (Sandbox Code Playgroud)