Ejemplo n.º 1
0
        /// <summary>
        /// Provide a binding list by constructor argument.
        /// </summary>
        public bool TryGetChildren(
            DetectedMethodArgument constructorArgument,
            out IReadOnlyList <ExtenderAndTypePair> result
            )
        {
            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"
                          );
            }

            if (!_groups.TryGetValue(constructorArgument.Type, out var @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);
        }
Ejemplo n.º 2
0
        public ExtenderAndTypePair(
            BindingExtender bindingExtender,
            DetectedMethodArgument constructorArgument
            )
        {
            if (bindingExtender is null)
            {
                throw new ArgumentNullException(nameof(bindingExtender));
            }

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

            BindingExtender     = bindingExtender;
            ConstructorArgument = constructorArgument;
        }