Exemplo n.º 1
0
        internal bool NeedsDefaultArgs(IntPtr args)
        {
            var pynargs = Runtime.PyTuple_Size(args);

            MethodBase[] methods = SetterBinder.GetMethods();
            if (methods.Length == 0)
            {
                return(false);
            }

            MethodBase mi = methods[0];

            ParameterInfo[] pi = mi.GetParameters();
            // need to subtract one for the value
            int clrnargs = pi.Length - 1;

            if (pynargs == clrnargs || pynargs > clrnargs)
            {
                return(false);
            }

            for (var v = pynargs; v < clrnargs; v++)
            {
                if (pi[v].DefaultValue == DBNull.Value)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Helper to get docstrings from reflected method / param info.
        /// </summary>
        internal IntPtr GetDocString()
        {
            if (doc != IntPtr.Zero)
            {
                return(doc);
            }
            var  str    = "";
            Type marker = typeof(DocStringAttribute);

            MethodBase[] methods = binder.GetMethods();
            foreach (MethodBase method in methods)
            {
                if (str.Length > 0)
                {
                    str += Environment.NewLine;
                }
                var attrs = (Attribute[])method.GetCustomAttributes(marker, false);
                if (attrs.Length == 0)
                {
                    str += method.ToString();
                }
                else
                {
                    var attr = (DocStringAttribute)attrs[0];
                    str += attr.DocString;
                }
            }
            doc = Runtime.PyString_FromString(str);
            return(doc);
        }