Esempio n. 1
0
        public CluePrinterOperation([NotNull] string config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Config = JsonConvert.DeserializeObject <ClueConfiguration>(config);

            var maxCode = 1;
            var digits  = Config.Digits;

            while (digits > 0)
            {
                maxCode *= 10;
                digits--;
            }
            MaxCode = maxCode - 1;

            foreach (var signDefinition in Config.SignDefinitions)
            {
                if (signDefinition.Code > MaxCode)
                {
                    throw new PluginConfigurationIncorrectException($"Code {signDefinition.Code} is too large. Should be less than {MaxCode}");
                }
                if (UsedCodes.Contains(signDefinition.Code))
                {
                    throw new PluginConfigurationIncorrectException($"Code {signDefinition.Code} is duplicated");
                }
                UsedCodes.Add(signDefinition.Code);
            }
        }
Esempio n. 2
0
        public void SetConfiguration(IPluginConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Config = config.GetConfiguration <ClueConfiguration>();
        }
        public ShowDetectiveConfiguration(string config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Config = JsonConvert.DeserializeObject <ClueConfiguration>(config);
        }