Exemplo n.º 1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Require != false)
            {
                hash ^= Require.GetHashCode();
            }
            if (TypeOverride.Length != 0)
            {
                hash ^= TypeOverride.GetHashCode();
            }
            if (Ignore != false)
            {
                hash ^= Ignore.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 2
0
        private TPredicate AndMultipleValues(Ignore ignores, Comparison comparison, ICollection values)
        {
            if (values == null || values.Count == 0)
            {
                return(default(TPredicate));
            }

            ArrayList items = new ArrayList(values);

            TPredicate columnPredicate = default(TPredicate);

            if (!IgnoreCondition(items[0], ignores))
            {
                columnPredicate = Create(this, comparison, items[0]);
            }

            for (int i = 1; i < items.Count; i++)
            {
                if (!IgnoreCondition(items[i], ignores))
                {
                    columnPredicate.And(Create(this, comparison, items[i]));
                }
            }

            return(columnPredicate);
        }
Exemplo n.º 3
0
 public override int Transform([NotNull] GlobalContext globalContext, [NotNull] ConfigureOptions configureOptions,
                               Ignore Ignore, [NotNull][ItemNotNull] IEnumerable <Dependency> dependencies,
                               [NotNull] List <Dependency> transformedDependencies)
 {
     if (!configureOptions.OrderedActions.Any())
     {
         Log.WriteWarning($"No actions configured for {GetType().Name}");
     }
     else
     {
         foreach (var d in dependencies)
         {
             DependencyAction firstMatchingAction = configureOptions.OrderedActions.FirstOrDefault(a => a.IsMatch(d));
             if (firstMatchingAction == null)
             {
                 Log.WriteWarning("No match in actions for dependency " + d);
             }
             else
             {
                 if (firstMatchingAction.Apply(d))
                 {
                     transformedDependencies.Add(d);
                 }
             }
         }
     }
     return(Program.OK_RESULT);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 添加表格。
        /// </summary>
        /// <param name="entity">模型实例。</param>
        /// <param name="ignore">操作方法。</param>
        /// <param name="selections">选项字符串。</param>
        /// <returns>返回字符串构建实例。</returns>
        protected IndentedStringBuilder NewBuilder(IEntityType entity, Ignore ignore, string selections = null)
        {
            var builder = new IndentedStringBuilder();
            Func <string, string, IndentedStringBuilder> append = (prefix, suffix) =>
            {
                builder.Append(prefix).Append(" ");
                builder.Append(Model.GetTable(entity.ClrType));
                builder.Append(suffix);
                return(builder);
            };

            switch (ignore)
            {
            case Ignore.Insert:
                return(append("INSERT INTO", null));

            case Ignore.List:
                selections = selections ?? "*";
                return(append($"SELECT {selections} FROM", " "));

            case Ignore.Update:
                return(append("UPDATE", " SET "));
            }
            return(append("DELETE FROM", " "));
        }
Exemplo n.º 5
0
        private void GitBasedTest(string gitignore, string[] files)
        {
            // setup gitignore
            gitFixture.AddTrackedFileToRepo(".gitignore", gitignore);

            // add untracked files to filesystem
            files.ToList().ForEach(file =>
            {
                if (file.EndsWith("/"))
                {
                    // create directory
                    gitFixture.AddUntrackedDirToRepo(file);
                }
                else
                {
                    gitFixture.AddUntrackedFileToRepo(file);
                }
            });

            // get results of git
            var gitUntrackedFiles = gitFixture.GetUntrackedFiles().Select(se => se.FilePath).ToList();

            // setup ignore
            var ignore = new Ignore();

            ignore.Add(gitignore.Split("\n"));

            // get results of ignore
            var ignoreFilteredFiles = ignore.Filter(files);

            Assert.Equal(gitUntrackedFiles.OrderBy(a => a), ignoreFilteredFiles.OrderBy(a => a));
        }
Exemplo n.º 6
0
        private TPredicate AndMultipleValues(Ignore ignores, Comparison comparison, object value1, object value2, object value3)
        {
            bool ignoreFirst  = IgnoreCondition(value1, ignores);
            bool ignoreSecond = IgnoreCondition(value2, ignores);
            bool ignoreThird  = IgnoreCondition(value3, ignores);

            if (!ignoreFirst)
            {
                TPredicate columnPredicate = Create(this, comparison, value1);
                if (!ignoreSecond)
                {
                    columnPredicate.And(Create(this, comparison, value2));
                }
                if (!ignoreThird)
                {
                    columnPredicate.And(Create(this, comparison, value3));
                }
                return(columnPredicate);
            }

            if (!ignoreSecond)
            {
                TPredicate columnPredicate = Create(this, comparison, value2);
                if (!ignoreThird)
                {
                    columnPredicate.And(Create(this, comparison, value3));
                }
                return(columnPredicate);
            }

            return(!ignoreThird?Create(this, comparison, value3) : default(TPredicate));
        }
        private string CreateUser()
        {
            var scenario = this.feature.Scenario("Create a user");

            this.users.Create(new Login("*****@*****.**"))
            .InStep(scenario.Step("Create new user"))
            .ShouldBe(ApiConventionFor.CreateResource())
            .ShouldBe(
                this.EqualToPattern("/Patterns/S02_E01_CreateUser.json")
                .Ignore(Ignore.ResponseLocationHeader())
                .Ignore(Ignore.ResponseBody("user.id"))
                .Expected("Manual: User is created and its details are returned"))
            .ReadUserId(out var id)
            .ReadCreatedUserLocationUrl(out var location);

            this.users.GetUserBy(location)
            .InStep(scenario.Step("Get created user pointed by \"Location\" header"))
            .ShouldBe(ApiConventionFor.GetSingleResource())
            .ShouldBe(
                this.EqualToPattern("/Patterns/S02_E02_GetCreatedUserByLocation.json")
                .Ignore(Ignore.RequestMethod())
                .Ignore(Ignore.ResponseBody("user.id"))
                .Expected("Manual: User details are returned"));

            return(id);
        }
        public void Serialize_ShouldKeepReading_GivenAdditionalComplexProperty(string json)
        {
            var context = new Context <Ignore>(Ignore.Random());

            var result = JsonSerializer.Deserialize <Ignore>(json, context.Options);

            Assert.Equal(0, result.Ignored);
        }
Exemplo n.º 9
0
 public void NoExceptionThrownReturnString()
 {
     Assert.DoesNotThrow(() =>
     {
         var result = Ignore.AllExceptions(() => "Hello World");
         Assert.That(result, Is.EqualTo("Hello World"));
     });
 }
Exemplo n.º 10
0
 internal bool Enabled(ProjectColumn column)
 {
     if (Ignore?.Any(i => i == column.Name) == true)
     {
         return(false);
     }
     return(Select is null || (Select.Length == 1 && Select[0] == "*") || Select.Any(i => i == column.Name));
 }
Exemplo n.º 11
0
 /// <summary>
 /// 设置选择列。
 /// </summary>
 /// <param name="ignore">忽略属性。</param>
 /// <returns>返回当前查询实例对象。</returns>
 public IQueryable <TModel> Select(Ignore ignore)
 {
     if (ignore == Ignore.None)
     {
         return(Select());
     }
     _fields.AddRange(Entity.FindProperties(ignore).Select(p => Delimit(p.Name)));
     return(this);
 }
Exemplo n.º 12
0
        public TPredicate IsBetween(object lowValue, object highValue, Ignore ignores)
        {
            if (IgnoreCondition(lowValue, ignores) || IgnoreCondition(highValue, ignores))
            {
                return(default(TPredicate));
            }

            return(Create(this, lowValue, highValue));
        }
Exemplo n.º 13
0
        public static bool Validation(PropertyInfo sPropertyInfo, PropertyInfo dPropertyInfo)
        {
            bool   result   = false;
            Ignore attr     = (Ignore)Attribute.GetCustomAttribute(sPropertyInfo, typeof(Ignore), false);
            var    isIgnore = attr?.isIgnore ?? false;

            result = sPropertyInfo.Name == dPropertyInfo.Name && sPropertyInfo.PropertyType == dPropertyInfo.PropertyType && !isIgnore;

            return(result);
        }
Exemplo n.º 14
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Ignore.GetHashCode();
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FullPath != null ? FullPath.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemplo n.º 15
0
 public SetIgnore(Ignore ignore) { _ignore = ignore; }
Exemplo n.º 16
0
 protected Ignore GetIgnore(XElement ignoreElement)
 {
     var ignore = new Ignore();
     LoadAttributes(ignore, ignoreElement);
     return ignore;
 }
Exemplo n.º 17
0
        public void IgnoreMember_Property_DoesNotConsider()
        {
            var value1 = new Ignore { Ignored = 2, Considered = 4 };
            var value2 = new Ignore { Ignored = 3, Considered = 4 };

            Assert.IsTrue(value1.Equals(value2));
        }