public void Unbind(TemplateContract templateContract) { foreach (var partDescription in _partDescriptions) { partDescription.Setter(templateContract, null); } }
public void Attach(TemplateContract templateContract) { if (templateContract == null) { throw new ArgumentNullException(nameof(templateContract)); } var type = templateContract.GetType(); TemplateContractInfos.GetValueOrCreate(type, () => new TemplateContractInfo(type)).Bind(templateContract, _templateChildProvider); }
public void Bind(TemplateContract templateContract, GetTemplateChild templateChildProvider) { foreach (var partDescription in _partDescriptions) { var templatePart = templateChildProvider(partDescription.Name); if (templatePart == null) { if (partDescription.Required) { throw new TemplateValidationException(partDescription.Name); } continue; } if (partDescription.PartType.IsInstanceOfType(templatePart)) { partDescription.Setter(templateContract, templatePart); } } }
public void Detach(TemplateContract templateContract) { TemplateContractInfos.GetValueOrDefault(templateContract.GetType())?.Unbind(templateContract); }