public RuleSet Create(RuleSetType type)
 {
     return(type switch
     {
         RuleSetType.Standard => GetStandardRuleSet(),
         RuleSetType.EasyReproduction => GetEasyReproductionRuleSet(),
         _ => throw new Exception()
     });
 public SimulationConfiguration(int maximumGenerations, int animationDelay, GridType gridType, RuleSetType ruleSetType, int height, int width)
 {
     MaximumGenerations = maximumGenerations;
     AnimationDelay     = animationDelay;
     GridType           = gridType;
     RuleSetType        = ruleSetType;
     Height             = height;
     Width = width;
 }
Пример #3
0
        public void ReturnsExpectedRuleSetForRuleSetTypeEnum(RuleSetType ruleSetType, Type expectedType)
        {
            _ruleSetsProvider.GetRuleSets().Returns(new Dictionary <RuleSetType, IRuleSet>()
            {
                { RuleSetType.Default, new DefaultRuleSet() },
                { RuleSetType.Relaxed, new RelaxedRuleSet() }
            });

            var ruleSetFactory = new RuleSetFactory(_ruleSetsProvider);

            var ruleSet = ruleSetFactory.GetRuleSet(ruleSetType);

            ruleSet.ShouldBeOfType(expectedType);
        }
        public string GetSummary(RuleSetType ruleSetType)
        {
            var scheduledFlightSummary = _summaryBuilder.BuildSummary(FlightRoute, Aircraft, Passengers);

            var scheduledFlightContext = new ScheduledFlightContext()
            {
                Aircraft               = Aircraft,
                FlightRoute            = FlightRoute,
                RuleSetType            = ruleSetType,
                ScheduledFlightSummary = scheduledFlightSummary
            };

            return(_summaryOutputGenerator.GenerateOutput(scheduledFlightContext));
        }
Пример #5
0
        /// <summary>
        /// Use this call to retrieve a list of rules of a given type
        /// </summary>
        /// <param name="type">The rule type.</param>
        /// <returns>A list of rules of the requested type</returns>
        public List <RuleHeaderBasic> GetRulesByType(RuleSetType type)
        {
            var response = GetResponse("RulesEngine/GetRulesByType", "type=" + type.ToString() + "", "POST");

            return(JsonFormatter.ConvertFromJson <List <RuleHeaderBasic> >(response));
        }
Пример #6
0
 public static RuleHeaderBasic CreateNewDraft(String ruleName, RuleSetType type, Guid ApiToken, String ApiServer)
 {
     return(Newtonsoft.Json.JsonConvert.DeserializeObject <RuleHeaderBasic>(Factory.GetResponse("RulesEngine/CreateNewDraft", "ruleName=" + ruleName + "&type=" + type + "", ApiToken, ApiServer), new JsonSerializerSettings {
         NullValueHandling = NullValueHandling.Ignore
     }));
 }
Пример #7
0
 public static List <String> GetOptions(String fieldName, RuleSetType type, String key, Guid ApiToken, String ApiServer)
 {
     return(Newtonsoft.Json.JsonConvert.DeserializeObject <List <String> >(Factory.GetResponse("RulesEngine/GetOptions", "fieldName=" + fieldName + "&type=" + type + "&key=" + key + "", ApiToken, ApiServer), new JsonSerializerSettings {
         NullValueHandling = NullValueHandling.Ignore
     }));
 }
Пример #8
0
 public static List<MultiKeyOptionResponse> GetMultiKeyOptions(RuleSetType type, List<String> fieldNames, String ApiToken, String ApiServer)
 {
     return Newtonsoft.Json.JsonConvert.DeserializeObject<List<MultiKeyOptionResponse>>(Factory.GetResponse("RulesEngine/GetMultiKeyOptions", "type=" + Newtonsoft.Json.JsonConvert.SerializeObject(type) + "&fieldNames=" + Newtonsoft.Json.JsonConvert.SerializeObject(fieldNames) + "", ApiToken, ApiServer), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
 }
Пример #9
0
 public static RuleHeaderBasic CreateNewDraft(String ruleName, RuleSetType type, String ApiToken, String ApiServer)
 {
     return Newtonsoft.Json.JsonConvert.DeserializeObject<RuleHeaderBasic>(Factory.GetResponse("RulesEngine/CreateNewDraft", "ruleName=" + ruleName + "&type=" + Newtonsoft.Json.JsonConvert.SerializeObject(type) + "", ApiToken, ApiServer), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
 }
Пример #10
0
 public static List <RuleHeaderBasic> GetRulesByType(RuleSetType type, String ApiToken, String ApiServer)
 {
     return(Newtonsoft.Json.JsonConvert.DeserializeObject <List <RuleHeaderBasic> >(Factory.GetResponse("RulesEngine/GetRulesByType", "type=" + Newtonsoft.Json.JsonConvert.SerializeObject(type, serializerSettings) + "", ApiToken, ApiServer), new JsonSerializerSettings {
         NullValueHandling = NullValueHandling.Ignore
     }));
 }
Пример #11
0
 public static List <FieldDescriptor> GetEvaluationFields(RuleSetType type, String ApiToken, String ApiServer)
 {
     return(Newtonsoft.Json.JsonConvert.DeserializeObject <List <FieldDescriptor> >(Factory.GetResponse("RulesEngine/GetEvaluationFields", "type=" + Newtonsoft.Json.JsonConvert.SerializeObject(type, serializerSettings) + "", ApiToken, ApiServer), new JsonSerializerSettings {
         NullValueHandling = NullValueHandling.Ignore
     }));
 }
Пример #12
0
 public ScheduledFlightContext()
 {
     RuleSetType = RuleSetType.Default;
 }
Пример #13
0
        /// <summary>
        /// Use this call to retrieve a list of valid action types for the rule type
        /// </summary>
        /// <param name="type">The rule type.</param>
        /// <returns>Valid action types</returns>
        public List <ActionTypeDescriptor> GetActionTypes(RuleSetType type)
        {
            var response = GetResponse("RulesEngine/GetActionTypes", "type=" + type.ToString() + "");

            return(JsonFormatter.ConvertFromJson <List <ActionTypeDescriptor> >(response));
        }
Пример #14
0
        /// <summary>
        /// Use this call to get a list of valid options for a given set of fields (and, if relevant, keys).
        /// </summary>
        /// <param name="type">The rule type.</param>
        /// <param name="fieldKeys">A list of fields and optionally keys.</param>
        /// <returns>A list of valid options grouped by Field/Key</returns>
        public List <MultiOptionResponse> GetMultiOptions(RuleSetType type, List <FieldKeys> fieldKeys)
        {
            var response = GetResponse("RulesEngine/GetMultiOptions", "type=" + type.ToString() + "&fieldKeys=" + JsonFormatter.ConvertToJson(fieldKeys) + "");

            return(JsonFormatter.ConvertFromJson <List <MultiOptionResponse> >(response));
        }
Пример #15
0
 public IRuleSet GetRuleSet(RuleSetType ruleSetType)
 {
     return(_ruleSets[ruleSetType]);
 }
Пример #16
0
 public static List<String> GetOptions(String fieldName, RuleSetType type, String key, String ApiToken, String ApiServer)
 {
     return Newtonsoft.Json.JsonConvert.DeserializeObject<List<String>>(Factory.GetResponse("RulesEngine/GetOptions", "fieldName=" + fieldName + "&type=" + Newtonsoft.Json.JsonConvert.SerializeObject(type) + "&key=" + key + "", ApiToken, ApiServer), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
 }
Пример #17
0
 public static List<RuleHeaderBasic> GetRulesByType(RuleSetType type, String ApiToken, String ApiServer)
 {
     return Newtonsoft.Json.JsonConvert.DeserializeObject<List<RuleHeaderBasic>>(Factory.GetResponse("RulesEngine/GetRulesByType", "type=" + Newtonsoft.Json.JsonConvert.SerializeObject(type) + "", ApiToken, ApiServer), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
 }
Пример #18
0
        /// <summary>
        /// Use this call to create a new draft rule of a specified type.
        /// </summary>
        /// <param name="ruleName">The name for the new draft.</param>
        /// <param name="type">The rule type.</param>
        /// <returns>The rule header.</returns>
        public RuleHeaderBasic CreateNewDraft(String ruleName, RuleSetType type)
        {
            var response = GetResponse("RulesEngine/CreateNewDraft", "ruleName=" + System.Net.WebUtility.UrlEncode(ruleName) + "&type=" + type.ToString() + "", "POST");

            return(JsonFormatter.ConvertFromJson <RuleHeaderBasic>(response));
        }
Пример #19
0
 public static List<FieldDescriptor> GetEvaluationFields(RuleSetType type, String ApiToken, String ApiServer)
 {
     return Newtonsoft.Json.JsonConvert.DeserializeObject<List<FieldDescriptor>>(Factory.GetResponse("RulesEngine/GetEvaluationFields", "type=" + Newtonsoft.Json.JsonConvert.SerializeObject(type) + "", ApiToken, ApiServer), new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
 }
Пример #20
0
        /// <summary>
        /// Use this call to get a list of valid evaluation fields for a given rule type.
        /// </summary>
        /// <param name="type">The rule type.</param>
        /// <returns>Returns a list of evaluation available fields.</returns>
        public List <FieldDescriptor> GetEvaluationFields(RuleSetType type)
        {
            var response = GetResponse("RulesEngine/GetEvaluationFields", "type=" + type.ToString() + "", "POST");

            return(JsonFormatter.ConvertFromJson <List <FieldDescriptor> >(response));
        }
Пример #21
0
 public static List <MultiOptionResponse> GetMultiOptions(RuleSetType type, List <FieldKeys> fieldKeys, Guid ApiToken, String ApiServer)
 {
     return(Newtonsoft.Json.JsonConvert.DeserializeObject <List <MultiOptionResponse> >(Factory.GetResponse("RulesEngine/GetMultiOptions", "type=" + type + "&fieldKeys=" + Newtonsoft.Json.JsonConvert.SerializeObject(fieldKeys, serializerSettings) + "", ApiToken, ApiServer), new JsonSerializerSettings {
         NullValueHandling = NullValueHandling.Ignore
     }));
 }
Пример #22
0
        /// <summary>
        /// Use this call to get a list of valid options for a given set of fields (and, if relevant, keys).
        /// </summary>
        /// <param name="type">The rule type.</param>
        /// <param name="fieldKeys">A list of fields and optionally keys.</param>
        /// <returns>A list of valid options grouped by Field/Key</returns>
        public List <MultiOptionResponse> GetMultiOptions(RuleSetType type, List <FieldKeys> fieldKeys)
        {
            var response = GetResponse("RulesEngine/GetMultiOptions", "type=" + type.ToString() + "&fieldKeys=" + System.Net.WebUtility.UrlEncode(JsonFormatter.ConvertToJson(fieldKeys)) + "", "POST");

            return(JsonFormatter.ConvertFromJson <List <MultiOptionResponse> >(response));
        }
Пример #23
0
 public static RulesFields GetRequiredFieldsByType(RuleSetType type, Guid ApiToken, String ApiServer)
 {
     return(Newtonsoft.Json.JsonConvert.DeserializeObject <RulesFields>(Factory.GetResponse("RulesEngine/GetRequiredFieldsByType", "type=" + type + "", ApiToken, ApiServer), new JsonSerializerSettings {
         NullValueHandling = NullValueHandling.Ignore
     }));
 }
Пример #24
0
        /// <summary>
        /// Use this call to get a list of valid options for a given field (and, if relevant, key).
        /// </summary>
        /// <param name="fieldName">The field name.</param>
        /// <param name="type">The rule type.</param>
        /// <param name="key">The key (optional).</param>
        /// <returns>Returns a list of options.</returns>
        public List <String> GetOptions(String fieldName, RuleSetType type, String key)
        {
            var response = GetResponse("RulesEngine/GetOptions", "fieldName=" + System.Net.WebUtility.UrlEncode(fieldName) + "&type=" + type.ToString() + "&key=" + System.Net.WebUtility.UrlEncode(key) + "", "POST");

            return(JsonFormatter.ConvertFromJson <List <String> >(response));
        }
Пример #25
0
 public static List <ActionTypeDescriptor> GetActionTypes(RuleSetType type, Guid ApiToken, String ApiServer)
 {
     return(Newtonsoft.Json.JsonConvert.DeserializeObject <List <ActionTypeDescriptor> >(Factory.GetResponse("RulesEngine/GetActionTypes", "type=" + type + "", ApiToken, ApiServer), new JsonSerializerSettings {
         NullValueHandling = NullValueHandling.Ignore
     }));
 }
Пример #26
0
        /// <summary>
        /// Use this call to get a list of fields and keys used by a given rule type
        /// </summary>
        /// <param name="type">The rule type.</param>
        /// <returns>A object containing a list of fields for enabled rules</returns>
        public RulesFields GetRequiredFieldsByType(RuleSetType type)
        {
            var response = GetResponse("RulesEngine/GetRequiredFieldsByType", "type=" + type.ToString() + "", "POST");

            return(JsonFormatter.ConvertFromJson <RulesFields>(response));
        }