public static bool EqualsIgnoreCase(this string thisString, string text, bool trim)
        {
            if (trim)
            {
                thisString = ConvertUtilities.Nullify(thisString, true);
                text       = ConvertUtilities.Nullify(text, true);
            }

            if (thisString == null)
            {
                return(text == null);
            }

            if (text == null)
            {
                return(false);
            }

            if (thisString.Length != text.Length)
            {
                return(false);
            }

            return(string.Compare(thisString, text, StringComparison.OrdinalIgnoreCase) == 0);
        }
Exemple #2
0
        private void WB_Navigated(object sender, NavigationEventArgs e)
        {
            dynamic doc    = WB.Document;
            string  cookie = doc.Cookie;
            var     coll   = new NameValueCollectionCollection(cookie);

            Cookie = ConvertUtilities.Nullify(coll.GetValue <string>(Server.CookieName, null), true);
            if (Cookie != null)
            {
                DialogResult = true;
                Close();
            }
        }
Exemple #3
0
        public static string GetFormName(HttpContext context)
        {
            if (context == null)
            {
                return(null);
            }
            ;

            string formName = ConvertUtilities.Nullify(context.Request["form"], true);

            if (formName == null)
            {
                return(null);
            }

            return(formName.ToLowerInvariant());
        }
        static void Main()
        {
            _projectPath                    = CommandLineUtilities.GetArgument("path", (string)null) ?? CommandLineUtilities.GetArgument(0, (string)null);
            _schema                         = ConvertUtilities.Nullify(CommandLineUtilities.GetArgument("schema", (string)null) ?? CommandLineUtilities.GetArgument(1, (string)null), true);
            _changeTargetDirectory          = CommandLineUtilities.GetArgument("changeTargetDirectory", true);
            _disableNonPersistenceProducers = CommandLineUtilities.GetArgument("disableNonPersistenceProducers", true);

            // Load the model
            Project project = new Project();

            project.Entities.ListChanged += Entities_ListChanged; // Change schema as soon as the entity is loaded
            project.Load(_projectPath, ProjectLoadOptions.Default);

            // Update producer target directory
            if (!string.IsNullOrEmpty(_schema) && _changeTargetDirectory)
            {
                foreach (var producer in project.Producers)
                {
                    var sqlServerProducer = producer.Instance as SqlServerProducer;
                    if (sqlServerProducer != null)
                    {
                        sqlServerProducer.Production += SqlServerProducer_Production;
                    }

                    var databaseProducer = producer.Instance as DatabaseProducer;
                    if (databaseProducer != null)
                    {
                        databaseProducer.Production += DatabaseProducer_Production;
                    }
                }
            }

            // Generate code
            project.Producing += OnProjectProduction;
            ProductionOptions productionOptions = BuildProductionOptions(project);

            project.Produce(productionOptions);
            Console.WriteLine();
        }
Exemple #5
0
        public override System.Web.Security.MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            global::SoftFluent.Samples.GED.Security.User user = new global::SoftFluent.Samples.GED.Security.User();
            if (providerUserKey != null)
            {
                if (providerUserKey is System.Guid)
                {
                    user.Id = (System.Guid)providerUserKey;
                }
                else
                {
                    status = MembershipCreateStatus.InvalidProviderUserKey;
                    return(null);
                }
            }

            email = ConvertUtilities.Nullify(email, true);
            if ((email != null) && (email.Length > 256))
            {
                status = MembershipCreateStatus.InvalidEmail;
                return(null);
            }

            if ((email == null) && RequiresUniqueEmail)
            {
                status = MembershipCreateStatus.InvalidEmail;
                return(null);
            }
            user.Email = email;

            password = ConvertUtilities.Nullify(password, true);

            user.PasswordSalt = GenerateSalt();
            string encodedPassword = EncodePassword(password, user.PasswordSalt);

            if ((password == null) || (password.Length > 256))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }
            user.Password = encodedPassword;

            username = ConvertUtilities.Nullify(username, true);
            if ((username == null) || (username.Length > 256))
            {
                status = MembershipCreateStatus.InvalidUserName;
                return(null);
            }
            user.UserName = username;

            DateTime time = DateTime.UtcNow; time = new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second);


            user.IsLockedOut = false;

            user.LastLoginDate          = time;
            user.LastActivityDate       = time;
            user.LastPasswordChangeDate = time;
            user.LastLockoutDate        = DateTime.MinValue;



            if (password.Length < MinRequiredPasswordLength)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            int min = 0;

            for (int i = 0; i < password.Length; i++)
            {
                if (!char.IsLetterOrDigit(password, i))
                {
                    min++;
                }
            }
            if (min < MinRequiredNonAlphanumericCharacters)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            if ((!string.IsNullOrEmpty(PasswordStrengthRegularExpression)) &&
                (!Regex.IsMatch(password, PasswordStrengthRegularExpression)))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            ValidatePasswordEventArgs e = new ValidatePasswordEventArgs(username, password, true);

            OnValidatingPassword(e);
            if (e.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            try
            {
                user.Save();
            }
            catch (CodeFluent.Runtime.CodeFluentDuplicateException)
            {
                status = MembershipCreateStatus.DuplicateProviderUserKey;
                return(null);
            }

            status = MembershipCreateStatus.Success;
            return(MembershipUserFromUser(user));
        }