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