Esempio n. 1
0
        protected virtual IList <XamlType> LookupPositionalParameters(int parameterCount)
        {
            if (UnderlyingType == null /* || !IsMarkupExtension*/)            // see nunit tests...
            {
                return(null);
            }

            // check if there is applicable ConstructorArgumentAttribute.
            // If there is, then return its type.
            if (parameterCount == 1)
            {
                foreach (var xm in GetAllMembers())
                {
                    var ca = xm.GetCustomAttributeProvider().GetCustomAttribute <ConstructorArgumentAttribute> (false);
                    if (ca != null)
                    {
                        return new XamlType [] { xm.Type }
                    }
                    ;
                }
            }

            var methods = (from m in UnderlyingType.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) where m.GetParameters().Length == parameterCount select m).ToArray();

            if (methods.Length == 1)
            {
                return((from p in methods [0].GetParameters() select SchemaContext.GetXamlType(p.ParameterType)).ToArray());
            }

            if (SchemaContext.SupportMarkupExtensionsWithDuplicateArity)
            {
                throw new NotSupportedException("The default LookupPositionalParameters implementation does not allow duplicate arity of markup extensions");
            }
            return(null);
        }

        BindingFlags flags_get_static = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;