示例#1
0
        public bool TryGetChildren(
            IBindingContainer bindingContainer,
            DetectedConstructorArgument constructorArgument,
            out IReadOnlyList <ExtenderAndTypePair> result
            )
        {
            if (bindingContainer is null)
            {
                throw new ArgumentNullException(nameof(bindingContainer));
            }

            if (constructorArgument is null)
            {
                throw new ArgumentNullException(nameof(constructorArgument));
            }

            var rresult = new List <ExtenderAndTypePair>();

            if (constructorArgument.Type is null)
            {
                throw new DpdtException(
                          DpdtExceptionTypeEnum.InternalError,
                          $"constructorArgument.Type is null somehow"
                          );
            }

            BindingContainerGroup?group;

            if (!Groups.TryGetValue(constructorArgument.Type, out group))
            {
                var unwrappedType = constructorArgument.GetUnwrappedType();

                if (!Groups.TryGetValue(unwrappedType, out group))
                {
                    result = new List <ExtenderAndTypePair>();
                    return(false);
                }
            }

            if (group is null)
            {
                throw new DpdtException(
                          DpdtExceptionTypeEnum.InternalError,
                          $"Something wrong with the {nameof(BindingExtenderBox)}"
                          );
            }

            foreach (var childBindingContainer in group.BindingExtenders)
            {
                rresult.Add(
                    new ExtenderAndTypePair(
                        childBindingContainer,
                        constructorArgument
                        )
                    );
            }

            result = rresult;
            return(rresult.Count > 0);
        }
示例#2
0
        public ExtenderAndTypePair(
            BindingContainerExtender bindingExtender,
            DetectedConstructorArgument constructorArgument
            )
        {
            if (bindingExtender is null)
            {
                throw new ArgumentNullException(nameof(bindingExtender));
            }

            if (constructorArgument is null)
            {
                throw new ArgumentNullException(nameof(constructorArgument));
            }

            BindingExtender     = bindingExtender;
            ConstructorArgument = constructorArgument;
        }