Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 4.8 KB

File metadata and controls

65 lines (49 loc) · 4.8 KB

RulesEngine Class

Index > ExpressionPowerTools.Serialization > ExpressionPowerTools.Serialization.Rules > RulesEngine

Implementation of IRulesConfiguration .

public class RulesEngine : IRulesConfiguration, IRulesEngine

Inheritance ObjectRulesEngine

Implements IRulesConfiguration , IRulesEngine

Remarks

The rules engine is an opt-in engine for execution. By default, properties and fields are allowed. Methods and constructors are not allowed. The rules engine operates on a few principles.

Allowing or denying a type will allow or deny all children of that type. For example, although methods are denied by defeault, allowing a type will also allow access to methods. More specific rules override general. You can allow a type and then deny a method, for example. Rules defined on generic types are inherited by closed types by default. You can choose to specify a rule for the closed type. For example, you might allow IQueryable<out T> as a generic type but deny IQueryable<int>.

Use the chainable IRulesConfiguration interface to build the rules. By default they are "allow." You can use the explicitto reinforce this, or turn it into a.

Constructors

Ctor Description
RulesEngine() Initializes a new instance of the RulesEngine class.

Properties

Property Type Description
AllowAnonymousTypes Boolean Gets a value indicating whether anonymous types are allowed.
LoadingDefaults Boolean Gets or sets a value indicating whether defaults are being loaded.

Methods

Method Description
Void AddRule(ISerializationRule rule) Adds a rule to the engine.
IRulesConfiguration Allow() Allow the rule in queue.
IRulesConfiguration Deny() Deny the rule in queue.
IRulesConfiguration DenyAnonymousTypes() Use this rule to disallow anonymous types.
Boolean MemberIsAllowed(MemberInfo member) Check if a member is allowed.
IList<ValueTuple<String, Boolean>> Reset() Clears the ruleset.
Void ResetToDefaults() Reset to default rules.
Void Restore(IList<ValueTuple<String, Boolean>> ruleSet) Restores a rule set (used mainly for testing).
IRulesConfiguration RuleForConstructor(Action<MemberSelector<ConstructorInfo>> selector) Sets up a constructor rule.
IRulesConfiguration RuleForField(Action<MemberSelector<FieldInfo>> selector) Sets up a field rule.
IRulesConfiguration RuleForMethod(Action<MemberSelector<MethodInfo>> selector) Sets up a method rule.
IRulesConfiguration RuleForProperty(Action<MemberSelector<PropertyInfo>> selector) Sets up a property rule.
IRulesConfiguration RuleForType(Type type) Adds the rules for a type.

Generated Copyright Version
02/22/2021 21:59:57 (c) Copyright 2020 Jeremy Likness. 0.9.7-beta