public void ValidateCreateHelpMessage()
        {
            Type          t = typeof(AggregateNumbers);
            bool          includeDateStamp = true;
            HelpException hex = ArgumentCollection.CreateHelpMessage(t, includeDateStamp);

            Assert.IsNotNull(hex.Message);
            Assert.IsTrue(hex.Message.Length > 0);
        }
示例#2
0
        /// <summary>
        /// Calls the corresponding Submit function, but waits for the cluster to Finish, Fail, or be Canceled. If the final state is
        /// Finished, returns silently. Otherwise, it throws and Exception. For a description of the other parameters, see Submit().
        /// *** NOTE: ONLY WORKS WITH V2 CLUSTERS. ****
        /// </summary>
        public static ClusterSubmitterArgs SubmitAndWait(ArgumentCollection argumentCollection, int maxSubmitAfterTasksFail = 0)
        {
            if (argumentCollection.PeekOptional <string>("cluster", "help").Equals("help", StringComparison.CurrentCultureIgnoreCase))
            {
                Console.WriteLine("");
                Console.WriteLine(ArgumentCollection.CreateHelpMessage(typeof(ClusterSubmitterArgs), includeDateStamp: false));
                return(null);
            }

            ClusterSubmitterArgs clusterArgs = new ClusterSubmitterArgs(argumentCollection);

            SubmitAndWait(clusterArgs, argumentCollection, maxSubmitAfterTasksFail);
            return(clusterArgs);
        }
示例#3
0
        /// <summary>
        /// Will parse s into T, provided T has a Parse(string) or TryParse(string s, out T t) method defined, or is one of the magical
        /// special cases we've implemented (including ICollection (comma delimited), Nullable and Enums).
        /// </summary>
        /// <typeparam name="T">T</typeparam>
        /// <param name="s">s</param>
        /// <param name="t">t</param>
        /// <returns>bool</returns>
        public static bool TryParse <T>(string s, out T t)
        {
            Type type = typeof(T);

            if ((String.IsNullOrEmpty(s)) || (s.Equals("null", StringComparison.CurrentCultureIgnoreCase) && type.IsClass))
            {
                t = default(T);  // return null
                return(true);
            }

            s = s.Trim();
            if (s.Equals("help", StringComparison.CurrentCultureIgnoreCase))
            {
                throw ArgumentCollection.GetHelpOnKnownSubtypes(type);
            }

            if (s.Equals("help!", StringComparison.CurrentCultureIgnoreCase))
            {
                throw ArgumentCollection.CreateHelpMessage(type);
            }

            if (s is T)
            {
                return(StringTryParse(s, out t));
            }

            if (type.IsEnum)
            {
                return(EnumTryParse(s, out t));
            }

            if (type.IsGenericType)
            {
                if (type.ParseAsCollection())
                {
                    return(CollectionsTryParse(s, out t));
                }
                else if (type.Name.StartsWith("Nullable"))
                {
                    return(NullableTryParse(s, out t));
                }
            }

            return(GenericTryParse(s, out t));
        }
示例#4
0
        /// <summary>
        /// Will parse s into T, provided T has a Parse(string) or TryParse(string s, out T t) method defined, or is one of the magical
        /// special cases we've implemented (including ICollection (comma delimited), Nullable and Enums).
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="s"></param>
        /// <returns></returns>
        public static bool TryParse <T>(string s, out T t)
        {
            s = s.Trim();
            Type type = typeof(T);

            if (s.Equals("help", StringComparison.CurrentCultureIgnoreCase))
            {
                throw ArgumentCollection.GetHelpOnKnownSubtypes(type);
            }
            else if (s.Equals("help!", StringComparison.CurrentCultureIgnoreCase))
            {
                throw ArgumentCollection.CreateHelpMessage(type);
            }
            else if (s.Equals("null", StringComparison.CurrentCultureIgnoreCase) && type.IsClass)
            {
                t = default(T);  // return null
                return(true);
            }
            else if (s is T)
            {
                return(StringTryParse(s, out t));
            }
            else if (type.IsEnum)
            {
                return(EnumTryParse(s, out t));
            }
            else if (type.IsGenericType)
            {
                //if (type.FindInterfaces(Module.FilterTypeNameIgnoreCase, "ICollection*").Length > 0)
                if (type.ParseAsCollection())
                {
                    return(CollectionsTryParse(s, out t));
                }
                else if (type.Name.StartsWith("Nullable"))
                {
                    return(NullableTryParse(s, out t));
                }
            }

            return(GenericTryParse(s, out t));
        }