Birkaç özellikli bir IAddress sınıfım var. Bu arayüzü uygulayan somut bir türüm var. Bu beton tipinde kullanabileceğim birkaç farklı kurucu var. Parametre değerlerini çalışma zamanında bu kuruculardan birine nasıl geçirebilirim? Bu beton tipini tekrar tekrar kullanacağım ve her defasında parametre değerleri farklı olacak şekilde config dosyasını kullanamıyorum.Castle Windsor kurucu parametreleri iletiliyor
IWindsorContainer container = new WindsorContainer(new XmlInterpreter());
IAddress address = container.Resolve<IAddress>();
public interface IAddress
{
string Address1 { get; set; }
string Address2 { get; set; }
string City { get; set; }
string State { get; set; }
string ZipCode { get; set; }
}
class TestAddress : IAddress
{
private string _address1;
private string _address2;
private string _city;
private string _countyName;
private string _state;
private string _zipCode;
public string Address1
{
get { return _address1; }
set { _address1 = value; }
}
public string Address2
{
get { return _address2; }
set { _address2 = value; }
}
public string City
{
get { return _city; }
set { _city = value; }
}
public string State
{
get { return _state; }
set { _state = value; }
}
public string ZipCode
{
get { return _zipCode; }
set { _zipCode = value; }
}
public string CountyName
{
get { return _countyName; }
set { _countyName = value; }
}
public MelissaAddress(string address1, string address2, string city, string state, string zipcode)
{
Address1 = address1;
Address2 = address2;
City = city;
State = state;
ZipCode = zipcode;
}
public MelissaAddress(string address1, string address2, string zipcode) : this(address1, address2, null, null, zipcode)
{ }
public MelissaAddress(string address1, string address2, string city, string state) : this(address1, address2, city, state, null)
{ }
}
bu gerçek kodunuz yoksa sadece bazı örnek var mı? Kapsayıcıyı yeni() için yedek olarak kullanıyorsunuz gibi görünüyor. –
Kayıt zamanı veya çözünürlük zamanı parametrelerini belirtmek ister misiniz? –
Parametreleri çözünürlük süresinde belirtmek istiyorum. Her biri farklı bir adrese sahip 2 adres sınıfına ihtiyacım varsa, o zaman yapıcıdaki her bir sınıfa değerleri aktarmak istiyorum. –