/// <summary> /// 过滤 /// </summary> /// <param name="workbook">工作簿</param> /// <param name="context">过滤器上下文</param> /// <param name="options">导入选项配置</param> public override IWorkbook Filter(IWorkbook workbook, IFilterContext context, IImportOptions options) { var kvps = new List <KeyValuePair <int, string> >(); foreach (var sheet in workbook.Sheets) { foreach (var row in sheet.GetBody()) { if (!row.Valid && options.ValidateMode == ValidateMode.StopOnFirstFailure) { continue; } row.Cells.ForEach(cell => { var kvp = new KeyValuePair <int, string>(cell.ColumnIndex, cell.Value.ToString()); var attribute = cell.GetFilterAttribute <DuplicationAttribute>(context.TypeFilterInfo); if (attribute != null) { row.Valid(!kvps.Contains(kvp), cell, attribute.ErrorMsg); } kvps.Add(kvp); }); } } return(workbook); }
public override bool Filter(IFilterContext context, MemberInfo m) { bool isPublic; bool isProtected; switch (m.MemberType) { case MemberTypes.TypeInfo: return false; case MemberTypes.Constructor: ConstructorInfo ctor = (ConstructorInfo)m; isPublic = ctor.IsPublic; isProtected = ctor.IsFamily; break; case MemberTypes.Event: EventInfo eInfo = (EventInfo)m; MethodInfo emInfo = eInfo.GetAddMethod(nonPublic: true); isPublic = emInfo.IsPublic; isProtected = emInfo.IsFamily; break; case MemberTypes.Field: FieldInfo fInfo = (FieldInfo)m; isPublic = fInfo.IsPublic; isProtected = fInfo.IsFamily; break; case MemberTypes.Method: MethodInfo mInfo = (MethodInfo)m; isPublic = mInfo.IsPublic; isProtected = mInfo.IsFamily; break; case MemberTypes.Property: PropertyInfo pInfo = (PropertyInfo)m; isPublic = pInfo.CanRead && pInfo.GetGetMethod(true).IsPublic || pInfo.CanWrite && pInfo.GetSetMethod(true).IsPublic; isProtected = pInfo.CanRead && pInfo.GetGetMethod(true).IsFamily || pInfo.CanWrite && pInfo.GetSetMethod(true).IsFamily; break; case MemberTypes.NestedType: Type nestedType = (Type)m; isPublic = nestedType.IsNestedPublic; isProtected = nestedType.IsNestedFamily; break; default: throw new ArgumentException("Unknown member type: " + m.MemberType); } if (!isPublic && !isProtected) { Type ifType; isPublic = IsExplicitInterfaceImplementation(m, out ifType) && ifType.IsPublic; } if (m.ReflectedType.IsSealed && !isPublic) return true; if (!isPublic && !isProtected) return true; return false; }
protected override bool Filter(IFilterContext context, Type type) { if (type.IsGenericType && !type.IsGenericTypeDefinition) return false; return !this._regex.IsMatch(type.FullName); }
public override bool Filter(IFilterContext context, MemberInfo m) { if (m is MethodInfo) return ((MethodInfo)m).IsSpecialName && !m.Name.StartsWith("op_", StringComparison.Ordinal); return false; }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); context.FilterColumn = _child; JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast <JProperty>().OrderBy(c => { if (c.Value.Type == JTokenType.Object) { return(((JObject)c.Value)[_child]); } return((JObject)null); }, new FirebaseValueSorter())) { result.Add(ordered); } } return(result); }
public bool Filter(IFilterContext context, Asset asset) { Type t = asset.Target as Type; if (t != null) return Filter(context, t); return false; }
public bool Filter(IFilterContext context, Asset asset) { FieldInfo obj = asset.Target as FieldInfo; if (obj == null || !obj.DeclaringType.IsEnum) return false; return !(obj.IsStatic && obj.IsPublic); }
public override bool Filter(IFilterContext context, MemberInfo m) { Type t = m as Type; if (t != null && t.Name == "__DynamicallyInvokableAttribute") return true; return false; }
public bool Filter(IFilterContext context, AssetIdentifier asset) { MemberInfo mi = context.AssetResolver.Resolve(asset) as MemberInfo; if (mi != null) return Filter(context, mi); return false; }
public bool Filter(IFilterContext context, AssetIdentifier asset) { object obj = context.AssetResolver.Resolve(asset); if (!(obj is FieldInfo) || !((FieldInfo)obj).DeclaringType.IsEnum) return false; return !(((FieldInfo)obj).IsStatic && ((FieldInfo)obj).IsPublic); }
/// <summary> /// 过滤 /// </summary> /// <param name="workbook">工作簿</param> /// <param name="context">过滤器上下文</param> /// <param name="options">导入选项配置</param> public IWorkbook Filter(IWorkbook workbook, IFilterContext context, IImportOptions options) { foreach (var filter in Filters) { workbook = filter.Filter(workbook, context, options); } return(workbook); }
/// <summary> /// /// </summary> /// <typeparam name="TEntity"></typeparam> /// <returns></returns> public Expression <Func <TEntity, bool> > BuildFilterExpression <TEntity>(IDataFilter dataFilter, IFilterContext context) where TEntity : class { FilterContext = context; var filterexpression = BuildFilterExpression <TEntity>(context); var expression = filterexpression.Or(filterexpression.Equal(expr2 => dataFilter.IsEnabled(FilterType))); return(expression); }
public bool Filter(IFilterContext context, Asset asset) { MemberInfo mi = asset.Target as MemberInfo; if (mi != null) return Filter(context, mi); return false; }
public bool Filter(IFilterContext context, AssetIdentifier asset) { Type t = context.AssetResolver.Resolve(asset) as Type; if (t != null) return Filter(context, t); return false; }
public override bool Filter(IFilterContext context, MemberInfo m) { Type t = m as Type; if (t != null && t.Name.StartsWith("<PrivateImplementationDetails>{", StringComparison.Ordinal)) return true; return false; }
public JToken Apply(JToken filtered, IFilterContext context) { foreach (var child in filtered.Children().Skip(_limit).ToList()) { child.Remove(); } return(filtered); }
public JToken Apply(JToken filtered, IFilterContext context) { foreach (var child in filtered.Children().Skip(_limit).ToList()) { child.Remove(); } return filtered; }
public override bool Filter(IFilterContext context, MemberInfo m) { if (m is MethodInfo) { return(((MethodInfo)m).IsSpecialName && !m.Name.StartsWith("op_", StringComparison.Ordinal)); } return(false); }
public bool Filter(IFilterContext context, AssetIdentifier asset) { Type t = context.AssetResolver.Resolve(asset) as Type; if (t != null) { return(Filter(context, t)); } return(false); }
public bool Filter(IFilterContext context, AssetIdentifier asset) { object obj = context.AssetResolver.Resolve(asset); if (!(obj is FieldInfo) || !((FieldInfo)obj).DeclaringType.IsEnum) { return(false); } return(!(((FieldInfo)obj).IsStatic && ((FieldInfo)obj).IsPublic)); }
public override bool Filter(IFilterContext context, MemberInfo m) { Type t = m as Type; if (t != null && t.Name == "__DynamicallyInvokableAttribute") { return(true); } return(false); }
public override bool Filter(IFilterContext context, MemberInfo m) { Type t = m as Type; if (t != null && t.Name.StartsWith("<PrivateImplementationDetails>{", StringComparison.Ordinal)) { return(true); } return(false); }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); foreach (var child in filtered.Children().OrderBy(t => t.Path, new FirebaseKeySorter())) { result.Add(child); } return result; }
public override bool Filter(IFilterContext context, MemberInfo m) { IList<CustomAttributeData> data = m.GetCustomAttributesData(); foreach (CustomAttributeData attrData in data) { if (attrData.Constructor.DeclaringType.Equals(typeof(CompilerGeneratedAttribute))) return true; } return false; }
public bool Filter(IFilterContext context, AssetIdentifier asset) { MemberInfo mi = context.AssetResolver.Resolve(asset) as MemberInfo; if (mi != null) { return(Filter(context, mi)); } return(false); }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); foreach (var child in filtered.Children().OrderBy(t => t.Path, new FirebaseKeySorter())) { result.Add(child); } return(result); }
public JToken Apply(JToken filtered, IFilterContext context) { // if they have 6 and we want 2 then skip to index 4 (exclusive) int toIndex = filtered.Children().Count() - _limit; foreach (var child in filtered.Children().Take(toIndex).ToList()) { child.Remove(); } return filtered; }
public JToken Apply(JToken filtered, IFilterContext context) { // if they have 6 and we want 2 then skip to index 4 (exclusive) int toIndex = filtered.Children().Count() - _limit; foreach (var child in filtered.Children().Take(toIndex).ToList()) { child.Remove(); } return(filtered); }
private static void Discover(IAssetExplorer assetExplorer, Asset asset, List<Asset> ret, IFilterContext filter) { if (filter != null && filter.IsFiltered(asset)) return; ret.Add(asset); IEnumerable<Asset> childAssets = assetExplorer.GetChildren(asset); foreach (Asset childAsset in childAssets) Discover(assetExplorer, childAsset, ret, filter); }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast <JProperty>().SkipWhile(c => { if (c.Value == null || c.Value.Type == JTokenType.Null) { return(true); } if (c.Value.Type == JTokenType.Object) { var test = ((JObject)c.Value)[context.FilterColumn]; if (test is JProperty) { test = ((JProperty)test).Value; } if (test != null && test.Type != JTokenType.Null) { if (test.Type == JTokenType.String) { return(String.Compare(test.Value <string>(), _startingValue, StringComparison.Ordinal) < 0); } // non-nulls aren't skipped return(false); } // skip missing/null return(true); } // there was something - but not the right type return(false); })) { result.Add(ordered); } } return(result); }
public override bool Filter(IFilterContext context, MemberInfo m) { IList <CustomAttributeData> data = m.GetCustomAttributesData(); foreach (CustomAttributeData attrData in data) { if (attrData.Constructor.DeclaringType.Equals(typeof(CompilerGeneratedAttribute))) { return(true); } } return(false); }
public bool Filter(IFilterContext context, Asset asset) { if (asset.Type == AssetType.Type) { bool filtered = !_assetPrefix.StartsWith(asset.Id.AssetId.Substring(asset.Id.AssetId.IndexOf(':') + 1)); return filtered; } else if (asset.Type == AssetType.Namespace) { } return false; }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast<JProperty>().SkipWhile(c => { if (c.Value == null || c.Value.Type == JTokenType.Null) { return true; } if (c.Value.Type == JTokenType.Object) { var test = ((JObject) c.Value)[context.FilterColumn]; if (test is JProperty) { test = ((JProperty) test).Value; } if (test != null && test.Type != JTokenType.Null) { if (test.Type == JTokenType.String) { return String.Compare(test.Value<string>(), _startingValue, StringComparison.Ordinal) < 0; } // non-nulls aren't skipped return false; } // skip missing/null return true; } // there was something - but not the right type return false; })) { result.Add(ordered); } } return result; }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast <JProperty>().TakeWhile(c => { if (c.Value == null || c.Value.Type == JTokenType.Null) { return(true); } if (c.Value.Type == JTokenType.Object) { var test = ((JObject)c.Value)[context.FilterColumn]; if (test is JProperty) { test = ((JProperty)test).Value; } if (test != null && test.Type != JTokenType.Null) { if (test.Type == JTokenType.Float || test.Type == JTokenType.Integer) { return(test.Value <long>() <= _endingValue); } // non-nulls aren't skipped return(false); } // skip missing/null return(true); } // there was something - but not the right type return(false); })) { result.Add(ordered); } } return(result); }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast<JProperty>().TakeWhile(c => { if (c.Value == null || c.Value.Type == JTokenType.Null) { return true; } if (c.Value.Type == JTokenType.Object) { var test = ((JObject) c.Value)[context.FilterColumn]; if (test is JProperty) { test = ((JProperty) test).Value; } if (test != null && test.Type != JTokenType.Null) { if (test.Type == JTokenType.Float || test.Type == JTokenType.Integer) { return test.Value<long>() <= _endingValue; } // non-nulls aren't skipped return false; } // skip missing/null return true; } // there was something - but not the right type return false; })) { result.Add(ordered); } } return result; }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast <JProperty>().Where(c => { if (c.Value.Type == JTokenType.Object) { var test = c.Value[context.FilterColumn]; if (test != null) { if (test is JValue) { T val; try { val = test.Value <T>(); } catch (Exception) { return(false); } return(val.Equals(_value)); } return(false); } } return(false); })) { result.Add(ordered); } } return(result); }
/// <summary> /// 过滤 /// </summary> /// <param name="workbook">工作簿</param> /// <param name="context">过滤器上下文</param> /// <param name="options">导入选项配置</param> public override IWorkbook Filter(IWorkbook workbook, IFilterContext context, IImportOptions options) { foreach (var sheet in workbook.Sheets) { foreach (var row in sheet.GetBody()) { if (!row.Valid && options.ValidateMode == ValidateMode.StopOnFirstFailure) { continue; } row.Cells.ForEach(cell => { var attribute = cell.GetFilterAttribute <DateTimeAttribute>(context.TypeFilterInfo); if (attribute != null) { row.Valid(cell.IsDateTime(), cell, attribute.ErrorMsg); } }); } } return(workbook); }
/// <summary> /// 过滤 /// </summary> /// <param name="workbook">工作簿</param> /// <param name="context">过滤器上下文</param> /// <param name="options">导入选项配置</param> public override IWorkbook Filter(IWorkbook workbook, IFilterContext context, IImportOptions options) { foreach (var sheet in workbook.Sheets) { foreach (var row in sheet.GetBody()) { if (!row.Valid && options.ValidateMode == ValidateMode.StopOnFirstFailure) { continue; } row.Cells.ForEach(cell => { var attributes = cell.GetFilterAttributes <RegexAttribute>(context.TypeFilterInfo); if (attributes != null && attributes.Count > 0) { attributes.ForEach(x => row.Valid(Regex.IsMatch(cell.Value.ToString(), x.RegexString), cell, x.ErrorMsg)); } }); } } return(workbook); }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast<JProperty>().SkipWhile(c => { if (c.Value == null || c.Value.Type == JTokenType.Null) { return true; } return String.Compare(c.Path, _startingKey, StringComparison.Ordinal) < 0; })) { result.Add(ordered); } } return result; }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast<JProperty>().OrderBy(c => { if (c.Value.Type == JTokenType.Object) { return ((JObject) c.Value); } return (JObject) null; }, new FirebasePrioritySorter())) { result.Add(ordered); } } return result; }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast<JProperty>().OrderBy(c => { if (c.Value is JValue) { return c.Value; } return (JObject) null; }, new FirebaseValueSorter())) { result.Add(ordered); } } return result; }
public JToken Apply(JToken filtered, IFilterContext context) { JObject result = new JObject(); JObject obj = filtered as JObject; if (obj != null) { foreach (var ordered in filtered.Children().Cast <JProperty>().TakeWhile(c => { if (c.Value == null || c.Value.Type == JTokenType.Null) { return(true); } return(String.Compare(c.Path, _endingKey, StringComparison.Ordinal) <= 0); })) { result.Add(ordered); } } return(result); }
public FilterRepo(IFilterContext context) { _context = context; }
protected override bool Filter(IFilterContext context, Type t) { return !t.IsPublic && (!t.IsNested || !t.IsNestedPublic); }
protected override bool Filter(IFilterContext context, Type type) { return type.Name.StartsWith("<PrivateImplementationDetails>", StringComparison.Ordinal); }
public abstract bool Filter(IFilterContext context, MemberInfo m);
public bool IgnoreTarget(IFilterContext context) { return(IgnoreTarget(context as T)); }
public bool Filter(IFilterContext context, AssetIdentifier asset) { return(asset.AssetId.Equals("T:System.__ComObject", StringComparison.Ordinal)); }
public bool Filter(IFilterContext context, AssetIdentifier asset) { return(context.State == FilterState.Discovery && !this._regex.IsMatch(asset.AssetId.Substring(2))); }
/// <summary> /// /// </summary> /// <typeparam name="TEntity"></typeparam> /// <returns></returns> protected abstract Expression <Func <TEntity, bool> > BuildFilterExpression <TEntity>(IFilterContext context) where TEntity : class;
protected override bool Filter(IFilterContext context, Type t) { return(!t.IsPublic && (!t.IsNested || !t.IsNestedPublic)); }
protected abstract bool Filter(IFilterContext context, Type type);
public abstract bool Filter(IFilterContext context, MemberInfo m);
protected abstract bool Filter(IFilterContext context, Type type);
protected virtual List<Asset> DiscoverAssets(Asset assemblyAsset, IAssetExplorer assetExplorer, IFilterContext filterContext) { List<Asset> assets = new List<Asset>(); using (TraceSources.GeneratorSource.TraceActivity("Discovering assets")) { if (TraceSources.GeneratorSource.Switch.ShouldTrace(TraceEventType.Verbose)) { foreach (Asset asset in assetExplorer.Discover(assemblyAsset, filterContext)) { TraceSources.GeneratorSource.TraceVerbose(asset.Id); assets.Add(asset); } } else assets.AddRange(assetExplorer.Discover(assemblyAsset, filterContext)); } // remove all namespaces, they will be added through the HierarchyBuilder anyway so this is an easy way to prevent empty namespaces assets.RemoveAll(a => a.Type == AssetType.Namespace); return assets; }
public bool Filter(IFilterContext context, Asset asset) { return context.State == FilterState.Discovery && !this._regex.IsMatch(asset.Id.AssetId.Substring(2)); }
/// <summary> /// 过滤 /// </summary> /// <param name="workbook">工作簿</param> /// <param name="context">过滤器上下文</param> /// <param name="options">导入选项配置</param> public abstract IWorkbook Filter(IWorkbook workbook, IFilterContext context, IImportOptions options);
public bool Filter(IFilterContext context, Asset asset) { return asset.Id.AssetId.Equals("T:System.__ComObject", StringComparison.Ordinal); }
private bool IsFiltered(IFilterContext filterContext, AssetIdentifier typeAsset) { bool filtered = false; foreach (IAssetFilter filter in this.AssetFilters) { if (filter.Filter(filterContext, typeAsset)) { filtered = true; TraceSources.GeneratorSource.TraceEvent(TraceEventType.Verbose, 0, "{0} - Filtered by {1}", typeAsset.AssetId, filter); break; } } return filtered; }
public static IEnumerable<Asset> Discover(this IAssetExplorer assetExplorer, Asset root, IFilterContext filter) { List<Asset> ret = new List<Asset>(); Discover(assetExplorer, root, ret, filter); return ret; }