Exemplo n.º 1
0
 public void Unbind(TemplateContract templateContract)
 {
     foreach (var partDescription in _partDescriptions)
     {
         partDescription.Setter(templateContract, null);
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
            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);
                    }
                }
            }
Exemplo n.º 4
0
 public void Detach(TemplateContract templateContract)
 {
     TemplateContractInfos.GetValueOrDefault(templateContract.GetType())?.Unbind(templateContract);
 }