/// <summary>
 /// We ignore all properties as they, in the end, will only point to some computated state or other fields.
 /// Hence they do not provide information about the actual state of the object.
 /// </summary>
 public List<SanitiedFieldInfo> GetFields(Type type)
 {
   // we need all fields in order to get the private backing field of public properties
   var fields = new HarvestHelper().GetFields(type);
   var res = fields.Where(x => x.FieldInfo.IsPublic || x.FieldInfo.Name.EndsWith(HarvestHelper.BackingFieldSuffix));
   
   return res.ToList();
 }
예제 #2
0
        /// <summary>
        /// We ignore all properties as they, in the end, will only point to some computed state or other fields.
        /// Hence they do not provide information about the actual state of the object.
        /// </summary>
        public List <SanitiedFieldInfo> GetFields(Type type)
        {
            // we need all fields in order to get the private backing field of public properties
            var fields = new HarvestHelper().GetFields(type);
            var res    = fields.Where(x => x.FieldInfo.IsPublic || x.FieldInfo.Name.EndsWith(HarvestHelper.BackingFieldSuffix));

            return(res.ToList());
        }
예제 #3
0
        List <SanitiedFieldInfo> ExcludeOrFilterfields(Type type)
        {
            var fields = new HarvestHelper().GetFields(type);

            foreach (var implementation in selected)
            {
                fields = implementation.Filter(fields).ToList();
            }

            return(fields);
        }
예제 #4
0
        List <SanitiedFieldInfo> IncludeFields(Type type)
        {
            var result = new List <SanitiedFieldInfo>();
            var fields = new HarvestHelper().GetFields(type);

            foreach (var implementation in selected)
            {
                result.AddRange(implementation.Filter(fields));
            }

            return(result);
        }
        void ExcludeByTypeImplementation <TTarget>(params Type[] types)
        {
            PreConditionToAdd <TTarget>(Strategy.Excluder);
            var helper = new HarvestHelper();

            // we evaluate outside of the usage in the lambda to prevent multiple calls to GetFieldsAndProperties()
            var cachedList = new List <string>();

            foreach (var type in types)
            {
                cachedList.AddRange(helper.GetFieldsAndProperties(type).Select(x => x.SanitizedName));
            }
            excluders.Add(new Implementation(typeof(TTarget), x => x.Where(y => !cachedList.Contains(y.SanitizedName))));
        }
        void IncludeByTypeImplementation <TTarget>(params Type[] types)
        {
            PreConditionToAdd <TTarget>(Strategy.Includer);
            var helper = new HarvestHelper();

            // we evaluate outside of the usage in the lambda to prevent multiple calls to GetFieldsAndProperties()
            var cachedList = new List <SanitizedFieldInfo>();

            foreach (var type in types)
            {
                cachedList.AddRange(helper.GetFieldsAndProperties(type));
            }
            includers.Add(new Implementation(typeof(TTarget), x => cachedList));
        }
        /// <summary>
        /// Harvest only public fields and properties.
        /// </summary>
        public List <SanitiedFieldInfo> GetFields(Type type)
        {
            var fields = new HarvestHelper().GetFieldsAndProperties(type);

            return(fields.Where(IsPublic).ToList());
        }
        /// <summary>
        /// Harvest only public fields and properties.
        /// </summary>
        public List<SanitizedFieldInfo> GetFields(Type type)
        {
            var fields = new HarvestHelper().GetFieldsAndProperties(type);

            return fields.Where(IsPublic).ToList();
        }