public static Dictionary <String, BaseTypeImpl> AsRuleData <T>(this T tObj) where T : class
        {
            var  result = new Dictionary <String, BaseTypeImpl>();
            Type tType  = typeof(T);

            PropertyInfo[] tProperties = tType.GetProperties();
            if (tProperties.Length != 0)
            {
                foreach (PropertyInfo property in tProperties)
                {
                    Type   propType     = property.PropertyType;
                    Object propOriValue = property.GetValue(tObj, null);
                    Object propValue    = propType.FullName == "System.String" ? "'" + Convert.ChangeType(propOriValue, typeof(String)) + "'" : propOriValue;
                    var    ruleValue    = new BaseTypeImpl(propValue, propType);
                    result.Add(property.Name, ruleValue);
                }
            }

            return(result);
        }
        public void Run()
        {
            Console.WriteLine("Start.");
            Dbg(
                Rule.Create()
                .DispatchWith(new Disp())
                .ThenWith(new NullDisp())
                .ExpressWith(new Expr())
                .OrWith(new Expr())
                .OrWith(new Expr())
                .AndWith(new Expr())
                .Evaluate(new List <BaseType>())
                );
            Console.WriteLine("Done.");

            Console.WriteLine("Start.");

            #region : Current State :

            // Correct use
            IWfEngine wfe = new WfEngine();
            ActionResponseViewModel result1 = wfe
                                              .WithAuditTrailUsername("Username")
                                              .WithApp("App")
                                              .WithDocNo("DocNo")
                                              .WithExecutor(new ApprovalUser())
                                              .UseSuperiorsConfigurator((wfm, pic) => new List <ApprovalUser>())
                                              .WithSegmentPersonInCharges(new List <ApprovalUser>())
                                              .WithSegmentActuals(new List <SegmentConditionActuals>())
                                              .WithApprovalLevelActuals(new List <ApprovalLevelConditionActuals>())
                                              .Start();

            ActionResponseViewModel result2 = wfe
                                              .WithAuditTrailUsername("Username")
                                              .WithApp("App")
                                              .WithDocNo("DocNo")
                                              .WithExecutor(new ApprovalUser())
                                              .WithPowerOfAttorneys(new List <PowerOfAttorney>())
                                              .Reject();

            // Abused
            ActionResponseViewModel result3 = wfe
                                              .WithAuditTrailUsername("Username")
                                              .WithApp("App")
                                              .WithDocNo("DocNo")
                                              .WithExecutor(new ApprovalUser())
                                              .UseSuperiorsConfigurator((wfman, pic) => new List <ApprovalUser>())
                                              .WithSegmentPersonInCharges(new List <ApprovalUser>())
                                              .WithSegmentActuals(new List <SegmentConditionActuals>())
                                              .WithApprovalLevelActuals(new List <ApprovalLevelConditionActuals>())
                                              .UsePowerOfAttorneyConfigurator(wfm => new List <PowerOfAttorney>())
                                              .Start();

            ActionResponseViewModel result4 = wfe
                                              .WithAuditTrailUsername("Username")
                                              .WithApp("App")
                                              .WithDocNo("DocNo")
                                              .WithExecutor(new ApprovalUser())
                                              .UseSuperiorsConfigurator((wfman, pic) => new List <ApprovalUser>())
                                              .WithSegmentPersonInCharges(new List <ApprovalUser>())
                                              .WithSegmentActuals(new List <SegmentConditionActuals>())
                                              .WithApprovalLevelActuals(new List <ApprovalLevelConditionActuals>())
                                              .UsePowerOfAttorneyConfigurator(wfm => new List <PowerOfAttorney>())
                                              .WithAdditionalApprovalLevelConditions(new List <WfApprovalLevelConditionViewModel>())
                                              .WithAdditionalSegmentConditions(new List <WfSegmentConditionViewModel>())
                                              .Approve();

            #endregion

            #region : New API :

            // Can't be abused
            IApprovalDocument       ad       = new ApprovalDocument();
            ActionResponseViewModel result21 = ad
                                               .WithAuditTrailUsername("Username")
                                               .WithApp("App")
                                               .WithDocNo("DocNo")
                                               .WithExecutor(new ApprovalUser())
                                               .UseSuperiorsConfigurator((wfm, pic) => new List <ApprovalUser>())
                                               .WithSegmentPersonInCharges(new List <ApprovalUser>())
                                               .WithSegmentActuals(new List <SegmentConditionActuals>())
                                               .WithApprovalLevelActuals(new List <ApprovalLevelConditionActuals>())
                                               .Create();

            IApprovalEngine         er       = new ApprovalEngine();
            ActionResponseViewModel result22 = er
                                               .Document()
                                               .WithAuditTrailUsername("Username")
                                               .WithApp("App")
                                               .WithDocNo("DocNo")
                                               .WithExecutor(new ApprovalUser())
                                               .UseSuperiorsConfigurator((wfm, pic) => new List <ApprovalUser>())
                                               .WithSegmentPersonInCharges(new List <ApprovalUser>())
                                               .WithSegmentActuals(new List <SegmentConditionActuals>())
                                               .WithApprovalLevelActuals(new List <ApprovalLevelConditionActuals>())
                                               .Create();

            ActionResponseViewModel result23 = er
                                               .Approval()
                                               .WithAuditTrailUsername("Username")
                                               .WithApp("App")
                                               .WithDocNo("DocNo")
                                               .WithExecutor(new ApprovalUser())
                                               .UseSuperiorsConfigurator((wfman, pic) => new List <ApprovalUser>())
                                               .WithSegmentPersonInCharges(new List <ApprovalUser>())
                                               .WithSegmentActuals(new List <SegmentConditionActuals>())
                                               .WithApprovalLevelActuals(new List <ApprovalLevelConditionActuals>())
                                               .UsePowerOfAttorneyConfigurator(wfm => new List <PowerOfAttorney>())
                                               .Approve();

            #endregion

            Console.WriteLine("Done.");

            Console.WriteLine(String.Empty);
            Dbg("Base Type",
                new {
                BaseType1 = BaseTypeImpl.Get("hello"),
                BaseType2 = BaseTypeImpl.Get("87246877"),
                BaseType3 = BaseTypeImpl.Get("hello9834789"),
                BaseType4 = BaseTypeImpl.Get("98ir739"),
                BaseType5 = BaseTypeImpl.Get("97983347.9479"),
                BaseType6 = BaseTypeImpl.Get("hello9873498.0934987"),

                AppvRule1 = new ApproverRule {
                    Id = "15", RegistrationNo = "08362549"
                }.AsRuleData(),
                AppvRule2 = new ApproverRule {
                    Id = "16", RegistrationNo = "07463528"
                }.AsRuleData(),
                AppvRule3 = new ApproverRule {
                    Id = "25", RegistrationNo = "06492649"
                }.AsRuleData()
            }
                );
        }