ArgumentNullException() public static method

public static ArgumentNullException ( IEnumerable parameters ) : IEnumerable
parameters IEnumerable
return IEnumerable
Example #1
0
        void AddCreatorDocs(CodeTypeDeclaration type, CodeMemberMethod method, int w, int n)
        {
            var tp   = Types.GetTypeParameter(w, n);
            var idx  = XmlDocs.GetIndex(tp);
            var fold = type.GetMethods("Fold").First();

            method.Comments.AddDocs(
                XmlDocs.Param("value",
                              "  A <typeparamref name=\"" + tp + "\" /> containing the value",
                              "  to provide to the " + idx,
                              "  " + XmlDocs.See(DefaultNamespace, type, fold),
                              "  delegate."
                              ),
                XmlDocs.Summary(
                    "  Creates a " + XmlDocs.See(DefaultNamespace, type) + " instance which",
                    "  holds a <typeparamref name=\"" + tp + "\" /> value."
                    ),
                XmlDocs.Returns(
                    "  A " + XmlDocs.See(DefaultNamespace, type) + " instance which holds a ",
                    "  holds a <typeparamref name=\"" + tp + "\" /> value."
                    ),
                XmlDocs.Remarks(
                    "  <para>",
                    "   When",
                    "   " + XmlDocs.See(DefaultNamespace, type, fold),
                    "   is invoked,",
                    "   the returned " + XmlDocs.See(DefaultNamespace, type) + " instance",
                    "   will invoke the " + idx + " delegate",
                    "   for conversions.",
                    "  </para>"
                    ),
                XmlDocs.ArgumentNullException("value")
                );
        }
Example #2
0
 void AddFoldDocs(CodeTypeDeclaration type, CodeMemberMethod method, int n)
 {
     method.Comments.AddDocs(
         XmlDocs.TypeParam("TResult",
                           "  The type to convert the " + XmlDocs.See(DefaultNamespace, type) + " to."
                           ),
         GetFoldParametersDocs(type, n),
         XmlDocs.Summary(
             "  Converts a " + XmlDocs.See(DefaultNamespace, type) + " into a <typeparamref name=\"TResult\" /> value."
             ),
         XmlDocs.Returns(
             "  A <typeparamref name=\"TResult\" /> as generated by one",
             "  of the conversion delegate parameters."
             ),
         XmlDocs.Remarks(
             "  <para>",
             "   Converts a " + XmlDocs.See(DefaultNamespace, type) + " into a <typeparamref name=\"TResult\" />",
             "   by invoking one of the provided delegate parameters.",
             "  </para>",
             "  <para>",
             "   The parameter which is invoked is predicated upon the internal position of",
             "   the value held.  For example, if the internal value is in the first position ",
             "   (i.e. " + XmlDocs.See(DefaultNamespace, type, type.GetMethods(A(0)).First()),
             "   was used to create the " + XmlDocs.See(DefaultNamespace, type) + " instance), then",
             "   <paramref name=\"a\" /> (the first delegate parameter) will be invoked to",
             "   convert the <typeparamref name=\"T1\" /> into a ",
             "   <typeparamref name=\"TResult\" />.",
             "  </para>"
             ),
         XmlDocs.ArgumentNullException(Enumerable.Range(0, n).Select(v => a(v)))
         );
 }
Example #3
0
        static CodeMemberMethod RecFunc(int args)
        {
            var t = Types.Func(args);
            var m = new CodeMemberMethod()
            {
                Attributes = MemberAttributes.Static | MemberAttributes.Public,
                Name       = "RecFunc",
                ReturnType = t,
            };

            m.TypeParameters.AddRange(Types.GetTypeParameters(args, true).ToArray());
            var a = "lambda";

            m.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference("Func", t, t), a));
            m.Statements.ThrowWhenArgumentIsNull(a);
            var expr = AppendArgs(new StringBuilder(), args);

            expr.Append(" => lambda (RecFunc (lambda))");
            AppendArgs(expr, args);
            m.Statements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression(expr.ToString())));
            m.Comments.AddRange("From: http://blogs.msdn.com/madst/archive/2007/05/11/recursive-lambda-expressions.aspx");
            m.Comments.AddDocs(
                XmlDocs.TypeParams(m.TypeParameters, t),
                XmlDocs.Param("lambda", "The " + XmlDocs.See(t) + " to use."),
                XmlDocs.Summary("Creates a " + XmlDocs.See(t) + " delegate, which may be recursive."),
                XmlDocs.Returns("Returns a " + XmlDocs.See(t) + " which (eventually) invokes <paramref name=\"lambda\"/>."),
                XmlDocs.ArgumentNullException("lambda"),
                XmlDocs.Remarks(
                    "<para>",
                    "  The following example makes use of a recursive lambda:",
                    "</para>",
                    "<code lang=\"C#\">",
                    "  Func<int, int> factorial = Lambda.RecFunc<int, int> (".Replace("<", "&lt;"),
                    "      fac => x => x == 0 ? 1 : x * fac (x-1));",
                    "  Console.WriteLine (factorial (5));  // prints \"120\"",
                    "</code>"
                    )
                );
            return(m);
        }