Когда я перетаскиваю свой пользовательский контроль и изменяю свое свойство ComponentType, он не может найти метод ComponentLogicFactory.CreateInstance (_ComponentType). Когда я перестраиваю или компилирую, компилятор не показывает никаких ошибок, когда я запускаю симуляцию, все работает нормально. Я посмотрел на Anssers
Ошибка конструктора WinForm, открыть конструктор , но не сделал этого для меня, у меня есть конструктор по умолчанию. Я не использую синглтоны или переменные, установленные во время выполнения. Что может быть причиной этого?
public ComponentTypes ComponentType
{
get
{
return this._ComponentType;
}
set
{
if(component == null)
{
_ComponentType = value;
component = ComponentDesignFactory.CreateInstance(_ComponentType);
if (!DesignMode)
{
logicChip = ComponentLogicFactory.CreateInstance(_ComponentType);
}
if(NumberInputPins > component.MaxInput)
{
this.NumberInputPins = component.MaxInput;
}
if(NumberOutputPins > component.MaxOutput)
{
this.NumberOutputPins = component.MaxOutput;
}
RepositionComponent();
gridPanel.Controls.Add(component);
}
else
{
MessageBox.Show("You can only change this once");
}
}
}
private static readonly IDictionary<ComponentTypes, Func<IComponent>> Creator =
new Dictionary<ComponentTypes, Func<IComponent>>()
{
{ ComponentTypes.And, () => new AndLogic() },
{ ComponentTypes.Or, () => new OrLogic() },
{ ComponentTypes.Not, () => new NotLogic() },
{ ComponentTypes.Led, () => new LedLogic() },
{ ComponentTypes.On, () => new OnLogic() },
{ ComponentTypes.Off, () => new OffLogic() },
{ ComponentTypes.Clock, () => new ClockLogic() },
};
public static IComponent CreateInstance(ComponentTypes typeComponent)
{
return Creator[typeComponent]();
}