コード例 #1
0
        public string CustomEmail(string tld = null, bool namesOnly = false)
        {
            if (emailLocalPartWheel == null)
            {
                emailLocalPartWheel = Incident.Utils.CreateWheel(new Dictionary<Func<string>, double> {
                        { () => Incident.Human.FirstName, 2 },
                        { () => string.Format("{0}.{1}", Incident.Human.FirstName, Incident.Human.LastName), 2 },
                        { () => string.Format("{0}{1}", Incident.Human.FirstName.Substring(0, 1), Incident.Human.LastName), 2 },
                        { () => Incident.Text.Word, 2 },
                        { () => Incident.Text.Word + Incident.Text.Word, 1 },
                        { () => string.Format("{0}.{1}", Incident.Text.Word, Incident.Text.Word), 1 }
                    });
            }

            if (emailLocalPartNamesOnlyWheel == null)
            {
                emailLocalPartNamesOnlyWheel = Incident.Utils.CreateWheel(new Dictionary<Func<string>, double> {
                        { () => Incident.Human.FirstName, 1 },
                        { () => string.Format("{0}.{1}", Incident.Human.FirstName, Incident.Human.LastName), 2 },
                        { () => string.Format("{0}{1}", Incident.Human.FirstName.Substring(0, 1), Incident.Human.LastName), 1 }
                    });
            }

            if (string.IsNullOrEmpty(tld))
                tld = StandardTLD;

            tld = tld.Where(c => char.IsLetterOrDigit(c)).StringJoin();

            var localPartSource = namesOnly ? emailLocalPartNamesOnlyWheel : emailLocalPartWheel;
            var domain = CustomDomain(tld, false);

            return string.Format("{0}@{1}", localPartSource.RandomElement(), domain).ToLower();
        }
コード例 #2
0
        public string CustomUrl(string protocol = "http", string extension = null)
        {
            if (customUrlExtensions == null)
            {
                customUrlExtensions = Incident.Utils.CreateWheel(new Dictionary<string, double> {
                        { "", 200 },
                        { "php", 80 }, { "html", 100 }, { "htm", 20 }, { "asp", 20 }, { "aspx", 40 }, { "cgi", 10 }, { "pl", 5 },
                        { "gif", 10 }, { "jpg", 25 }, { "png", 20 }, { "swf", 5 }, { "json", 5 }, { "js", 5 }, { "css", 5 }
                    });
            }

            if (customUrlWheel == null)
            {
                customUrlWheel = Incident.Utils.CreateWheel(new Dictionary<Func<string>, double> {
                        { () => Incident.Text.Word, 30 },
                        { () => string.Format("{0}/{1}", Incident.Text.Word, Incident.Text.Word), 8 },
                        { () => string.Format("{0}-{1}", Incident.Text.Word, Incident.Text.Word), 4 },
                        { () => string.Format("{0}/{1}",  Incident.Text.Word, Incident.Primitive.IntegerBetween(1, 1000)), 2 },
                        { () => string.Format("{0}/{1}/{2}", Incident.Text.Word, Incident.Text.Word, Incident.Primitive.IntegerBetween(1, 1000)), 1 },
                    });
            }

            extension = extension ?? customUrlExtensions.RandomElement;

            if (!extension.StartsWith(".") && !string.IsNullOrEmpty(extension))
                extension = "." + extension;

            return string.Format("{0}://{1}/{2}{3}", protocol, Domain, customUrlWheel.RandomElement(), extension);
        }
コード例 #3
0
        public string CustomDomain(string tld = null, bool includeWWW = true)
        {
            if (domainWheel == null)
            {
                // TODO: add company domain generation after implementing Incident.Business.Company

                domainWheel = Incident.Utils.CreateWheel(new Dictionary<Func<string>, double> {
                        { () => Incident.Text.Word, 3 },
                        { () => string.Format("{0}-{1}", Incident.Text.Word, Incident.Text.Word), 2 },
                        { () => string.Format("www.{0}", Incident.Text.Word), 6 },
                        { () => string.Format("{0}.{1}", Incident.Text.Word, Incident.Text.Word), 3 },
                        { () => Incident.Human.LastName, 2 },
                        { () => string.Format("{0}.{1}", Incident.Human.FirstName, Incident.Human.LastName), 1 },
                    });
            }

            if (string.IsNullOrEmpty(tld))
                tld = TLD;

            var domainName = domainWheel.RandomElement();

            if (!includeWWW && domainName.StartsWith("www."))
                domainName = domainName.Substring("www.".Length);

            return string.Format("{0}.{1}", domainName, tld).ToLower();
        }