private void onDeserialized(StreamingContext streamingContext)
        {
            if (contentData.ContainsKey("validate"))
            {
                ValidationTest = DescriptsonLogicalAnd <TObject> .CreateFrom((JObject)contentData["validate"]);
            }
            else
            {
                ValidationTest = new DescriptsonTrueTest <TObject>();
            }

            if (!contentData.ContainsKey("calculate"))
            {
                calculations = new DescriptsonCalculatedProperty <TObject> [0];
            }
            else
            {
                calculations = contentData["calculate"].Cast <JProperty>().Select(jProperty =>
                {
                    var setupProperty = DescriptsonPropertyManager <TObject> .ParseWritePath(jProperty.Name);
                    var calculation   = DescriptsonCalculation.Make(typeof(TObject), setupProperty.Body.Type.GetGenericArguments()[1], (JArray)jProperty.Value);

                    return(new DescriptsonCalculatedProperty <TObject>(setupProperty.Compile(), calculation));
                })
                               .ToArray();
            }
        }
Example #2
0
 public DescriptsonConditional(IDescriptsonTest <TTarget> condition, IDescriptsonCalculation <TTarget, TResult> whenTrue, IDescriptsonCalculation <TTarget, TResult> whenFalse)
 {
     Condition = condition;
     WhenTrue  = whenTrue;
     WhenFalse = whenFalse;
 }
 public DescriptsonLogicalNot(IDescriptsonTest <TTarget> subExpression)
     : base(subExpression)
 {
 }