/// <summary>
 /// Test for string exists in EqTo, Contains, or StartWith string lists
 /// </summary>
 /// <param name="testStr">String to test</param>
 /// <returns>bool</returns>
 public bool NameFilter(string testStr)
 {
     testStr = testStr.ToUpper();
     return(EqualTo.Any(a => testStr.Equals(a)) ||
            StartWith.Any(a => testStr.StartsWith(a)) ||
            (Contain.Count(a => testStr.Contains(a)) > 0));
 }
Beispiel #2
0
 /// <summary>
 /// Clear PropertyFilter
 /// </summary>
 public void Clear()
 {
     EqualTo.Clear();
     StartWith.Clear();
     Contain.Clear();
     PropertySetsEqualTo.Clear();
 }
Beispiel #3
0
 /// <summary>
 /// Merge PropertyFilter
 /// </summary>
 /// <param name="mergeFilter">PropertyFilter to merge</param>
 public void Merge(PropertyFilter mergeFilter)
 {
     EqualTo             = EqualTo.Concat(mergeFilter.EqualTo.Where(s => !EqualTo.Contains(s))).ToList();
     StartWith           = StartWith.Concat(mergeFilter.StartWith.Where(s => !StartWith.Contains(s))).ToList();
     Contain             = Contain.Concat(mergeFilter.Contain.Where(s => !Contain.Contains(s))).ToList();
     PropertySetsEqualTo = PropertySetsEqualTo.Concat(mergeFilter.PropertySetsEqualTo.Where(s => !PropertySetsEqualTo.Contains(s))).ToList();
 }
Beispiel #4
0
        public void TestRuleStartWith()
        {
            SingleRule       rule   = new StartWith("ab");
            ValidationResult result = rule.Validate("abcd");

            Assert.IsTrue(result.IsValid);
        }
Beispiel #5
0
 /// <summary>
 /// Test for string exists in EqTo, Contains, or StartWith string lists
 /// </summary>
 /// <param name="testStr">String to test</param>
 /// <returns>bool</returns>
 public bool NameFilter(string testStr)
 {
     testStr = testStr.ToUpper();
     return((EqualTo.Where(a => testStr.Equals(a)).Count() > 0) ||
            (StartWith.Where(a => testStr.StartsWith(a)).Count() > 0) ||
            (Contain.Where(a => testStr.Contains(a)).Count() > 0)
            );
 }
        public void GivenJoeStartsWithTheNumber(int number)
        {
            var joe = cast.GetMathsWhiz("Joe");

            stage.ShineTheSpotlightOn(joe);

            Given(joe).WasAbleTo(StartWith.TheNumber(number));
        }
Beispiel #7
0
 /// <summary>
 /// Copy values from passed PropertyFilter
 /// </summary>
 /// <param name="copyFilter">PropertyFilter to copy</param>
 public void Copy(PropertyFilter copyFilter)
 {
     EqualTo.Clear();
     EqualTo = EqualTo.Concat(copyFilter.EqualTo).ToList();
     StartWith.Clear();
     StartWith = StartWith.Concat(copyFilter.StartWith).ToList();
     Contain.Clear();
     Contain = Contain.Concat(copyFilter.Contain).ToList();
     PropertySetsEqualTo.Clear();
     PropertySetsEqualTo = PropertySetsEqualTo.Concat(copyFilter.PropertySetsEqualTo).ToList();
 }
Beispiel #8
0
 public StringFilter ToUpper()
 {
     Equal        = Equal?.ToUpper();
     NotEqual     = NotEqual?.ToUpper();
     Contain      = Contain?.ToUpper();
     NotContain   = NotContain?.ToUpper();
     StartWith    = StartWith?.ToUpper();
     NotStartWith = NotStartWith?.ToUpper();
     EndWith      = EndWith?.ToUpper();
     NotEndWith   = NotEndWith?.ToUpper();
     return(this);
 }
        protected override void ExecuteStatement(ExecutionContext context)
        {
            //if (!context.User.CanCreate(DbObjectType.Sequence, SequenceName))
            //	throw new MissingPrivilegesException(context.Request.UserName(), SequenceName, Privileges.Create);

            if (context.DirectAccess.ObjectExists(SequenceName))
            {
                throw new StatementException(String.Format("An object named '{0}' already exists.", SequenceName));
            }

            if (context.DirectAccess.ObjectExists(DbObjectType.Sequence, SequenceName))
            {
                throw new StatementException(String.Format("The sequence '{0}' already exists.", SequenceName));
            }

            var startValue  = SqlNumber.Zero;
            var incrementBy = SqlNumber.One;
            var minValue    = SqlNumber.Zero;
            var maxValue    = new SqlNumber(Int64.MaxValue);
            var cache       = 16;
            var cycle       = Cycle;

            if (StartWith != null)
            {
                startValue = (SqlNumber)StartWith.EvaluateToConstant(context.Request, null).AsBigInt().Value;
            }
            if (IncrementBy != null)
            {
                incrementBy = (SqlNumber)IncrementBy.EvaluateToConstant(context.Request, null).AsBigInt().Value;
            }
            if (MinValue != null)
            {
                minValue = (SqlNumber)MinValue.EvaluateToConstant(context.Request, null).AsBigInt().Value;
            }
            if (MaxValue != null)
            {
                maxValue = (SqlNumber)MaxValue.EvaluateToConstant(context.Request, null).AsBigInt().Value;
            }

            if (minValue >= maxValue)
            {
                throw new InvalidOperationException("The minimum value cannot be more than the maximum.");
            }
            if (startValue < minValue ||
                startValue >= maxValue)
            {
                throw new InvalidOperationException("The start value cannot be out of the mim/max range.");
            }

            var seqInfo = new SequenceInfo(SequenceName, startValue, incrementBy, minValue, maxValue, cache, cycle);

            context.Request.Access().CreateObject(seqInfo);
        }
        /// <summary>
        /// Set Property Filters constructor via ConfigurationSection from configuration file
        /// </summary>
        /// <param name="section">ConfigurationSection from configuration file</param>
        public PropertyFilter(ConfigurationSection section) : this()
        {
            //initialize fields
            if (section == null)
            {
                return;
            }

            foreach (KeyValueConfigurationElement keyVal in ((AppSettingsSection)section).Settings)
            {
                if (string.IsNullOrEmpty(keyVal.Value))
                {
                    continue;
                }

                switch (keyVal.Key.ToUpper())
                {
                case "EQUALTO":
                    EqualTo.AddRange(keyVal.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
                    break;

                case "STARTWITH":
                    StartWith.AddRange(keyVal.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
                    break;

                case "CONTAIN":
                    Contain.AddRange(keyVal.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
                    break;

                case "PROPERTYSETSEQUALTO":
                    PropertySetsEqualTo.AddRange(keyVal.Value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
                    break;

                default:
#if DEBUG
                    Debug.WriteLine(string.Format("Invalid Key - {0}", keyVal.Key.ToUpper()));
#endif
                    break;
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Set Property Filters constructor
        /// </summary>
        /// <param name="equalTo">';' delimited string for property names to equal</param>
        /// <param name="startWith">';' delimited string for property names to start with</param>
        /// <param name="contain">';' delimited string for property names containing</param>
        /// <param name="pSetEqualTo">';' delimited string for Property Set names to equal</param>
        public PropertyFilter(string equalTo, string startWith, string contain, string pSetEqualTo) : this()
        {
            //Property names to exclude
            if (!string.IsNullOrEmpty(equalTo))
            {
                EqualTo.AddRange(equalTo.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
            }
            if (!string.IsNullOrEmpty(startWith))
            {
                StartWith.AddRange(startWith.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
            }
            if (!string.IsNullOrEmpty(contain))
            {
                Contain.AddRange(contain.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
            }

            //PropertySet names to exclude
            if (!string.IsNullOrEmpty(pSetEqualTo))
            {
                PropertySetsEqualTo.AddRange(pSetEqualTo.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => s.ToUpper()));
            }
        }
Beispiel #12
0
        public void TestStartWithFilter()
        {
            IFilter filter = new StartWith(AttributeNames.CN, "p");

            Assert.AreEqual("(cn=p*)", filter.BuildFilter());
        }
Beispiel #13
0
        public void GivenTheyStartWithANumber(int number)
        {
            var actor = stage.GetTheActorInTheSpotlight();

            Given(actor).WasAbleTo(StartWith.TheNumber(number));
        }
Beispiel #14
0
        public void GivenJoeStartsWithTheNumber(int number)
        {
            var mathias = stage.ShineTheSpotlightOn <Mathias>();

            Given(mathias).WasAbleTo(StartWith.TheNumber(number));
        }