Esempio n. 1
0
        public HttpSession(string id)
        {
            MyValidator.ThrowIfNullOrEmpty(id, nameof(id));

            this.Id     = id;
            this.values = new Dictionary <string, object>();
        }
Esempio n. 2
0
 public override void Validate(MyValidator validator)
 {
     //base.Validate(validator);
     validator.AssertError(Neurons > 0, this, "Number of neurons should be > 0");
     validator.AssertError(Input != null, this, "Neural network node \"" + this.Name + "\" has no input.");
     validator.AssertWarning(Connection != ConnectionType.NOT_SET, this, "ConnectionType not set for " + this);
 }
Esempio n. 3
0
        public void Add(string key, object value)
        {
            MyValidator.ThrowIfNullOrEmpty(key, nameof(key));
            MyValidator.ThrowIfNull(value, nameof(value));

            this.values[key] = value;
        }
Esempio n. 4
0
 public virtual void Validate(MyValidator validator)
 {
     for (int i = 0; i < InputBranches; i++)
     {
         validator.AssertError(GetAbstractInput(i) != null, this, "No input available");
     }
 }
        private void Button_Registrar_Click(object sender, RoutedEventArgs e)
        {
            var MyTuple = MyValidator.TryValidateObject(newCiudad);

            if (MyTuple.Item1)
            {
                if (!isUpdate)
                {
                    isRegistered = true;
                    MessageBox.Show($"{newCiudad.Nombre} registrado");
                }
                else
                {
                    MessageBox.Show($"{newCiudad.Nombre} actualizado");
                }

                this.Close();
            }
            else
            {
                string Messages = "";
                foreach (var x in MyTuple.Item2)
                {
                    Messages += x.ErrorMessage + "\n";
                }

                MessageBox.Show(Messages);
            }
        }
Esempio n. 6
0
        public void AddUrlParameter(string key, string value)
        {
            MyValidator.ThrowIfNullOrEmpty(key, nameof(key));
            MyValidator.ThrowIfNullOrEmpty(value, nameof(value));

            this.UrlParameters[key] = value;
        }
Esempio n. 7
0
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (!ParamsChanged)
            {
                validator.AssertError(Layers.Count > 0, this, "The network has no layers.");

                validator.AssertError(DataInput != null, this, "No input available.");
                if (DataInput != null)
                {
                    validator.AssertError(DataInput.Count > 0, this, "Input connected but empty.");
                    validator.AssertWarning(DataInput.ColumnHint > 1, this, "The Data input columnHint is 1.");
                    uint total = InputWidth * InputHeight * InputsCount * ForwardSamplesPerStep;
                    validator.AssertError(DataInput.Count == total, this, "DataInput Count is " + DataInput.Count + ". Expected " + InputLayer.Output.ToString() + " = " + total + ".");
                }

                if (FBPropTask.NetworkMode == MyFeedForwardMode.TRAINING)
                {
                    validator.AssertError(LabelInput != null, this, "No label available.");
                    validator.AssertError(LastLayer != null, this, "Last layer is null.");
                    if (LabelInput != null && LastLayer != null)
                    {
                        validator.AssertError(LabelInput.Count == LastLayer.Output.Count * ForwardSamplesPerStep, this, "Current label dimension is " + LabelInput.Count + ". Expected " + ForwardSamplesPerStep + "x" + LastLayer.Output.Count + ".");
                    }
                }
            }
        }
 public override void Validate(MyValidator validator)
 {
     if (Mode == CombinationMode.MakePower)
     {
         base.Validate(validator);
     }
 }
        public override void Validate(MyValidator validator)
        {
            //base.Validate(validator);
            validator.AssertError(Controls != null, this, "No input available");

            if (Limits != null)
            {
                validator.AssertError(Limits.Count == 3, this, "Limit vector must be of a size 3 or nothing!");
            }

            if (Reset != null)
            {
                validator.AssertError(Reset.Count == 1, this, "Reset vector must be of a size 1 or nothing!");
            }

            if (Controls != null)
            {
                if (ELBOW_FIXED)
                {
                    validator.AssertError(Controls.Count >= 1, this, "Not enough controls (1 required)");
                }
                else
                {
                    validator.AssertError(Controls.Count >= 2, this, "Not enough controls (2 required)");
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Handler for operations with two arguments
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void CalculateTwoArguments(object sender, EventArgs e)
        {
            try
            {
                string InputOne = ValueOneInput.Text;
                string InputTwo = ValueTwoInput.Text;

                if (InputOne.Length == 0 || InputTwo.Length == 0)
                {
                    throw new Exception("Argument missing");
                }

                string senderName    = ((Button)sender).Name;
                string operationName = senderName.Replace("Button", "");

                double firstValue  = MyValidator.ValidateAndConvertToDouble(ValueOneInput.Text);
                double secondValue = MyValidator.ValidateAndConvertToDouble(ValueTwoInput.Text);

                ITwoArgumentsCalculator Calculator = TwoArgumentsFactory.CreateCalculator(operationName);
                var calculateResult = Calculator.Calculate(firstValue, secondValue);

                OutputField.Text = calculateResult.ToString();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Error");
            }
        }
Esempio n. 11
0
        public ValidationForm(MainForm mainForm, MyValidator validator)
        {
            InitializeComponent();
            Validator = validator;

            m_mainForm = mainForm;
        }
Esempio n. 12
0
 public override void Validate(MyValidator validator)
 {
     validator.AssertError(!(BoxPlot.Enabled && WindowLength != 1 && CalculateFor != CalculateForEnum.AllElements), this,
                           "BoxPlot with WindowLength other than 1 can be used with CalculateFor = 'AllElements' option only");
     validator.AssertError(!(BoxPlot.Enabled && CalculateFor == CalculateForEnum.WholeMatrix && Input.Count < 5), this,
                           "BoxPlot recieves too small input to get reasonable output");
 }
        private void Guardar_Click(object sender, RoutedEventArgs e)
        {
            var MyTuple = MyValidator.TryValidateObject(newUnidadVehicular);

            if (MyTuple.Item1)
            {
                if (!isUpdate)
                {
                    if (MessageBox.Show("La Placa ingresada es correcta? (luego no se podrá modificar)"
                                        , "Confirmación", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        isRegistered = true;
                        this.Close();
                    }
                }
                else
                {
                    isUpdated = true;
                    this.Close();
                }
            }
            else
            {
                string Messages = "";
                foreach (var x in MyTuple.Item2)
                {
                    Messages += x.ErrorMessage + "\n";
                }

                MessageBox.Show(Messages);
            }
        }
Esempio n. 14
0
        public void Add(string key, string value)
        {
            MyValidator.ThrowIfNullOrEmpty(key, nameof(key));
            MyValidator.ThrowIfNullOrEmpty(value, nameof(value));

            this.Add(new HttpCookie(key, value));
        }
Esempio n. 15
0
 public override void Validate(MyValidator validator)
 {
     //base.Validate(validator); /// base checking
     validator.AssertError(Patches != null, this, "No input available");
     validator.AssertError(Desc != null, this, "No input available");
     validator.AssertError(Mask != null, this, "No input available");
 }
Esempio n. 16
0
 public override void Validate(MyValidator validator)
 {
     ValidateRange(validator, HiddenVectorLength, HiddenVectorLengthMin, HiddenVectorLengthMax, "HiddenVectorLength");
     ValidateRange(validator, NumberOfColors, NumberOfColorsMin, NumberOfColorsMax, "NumberOfColors");
     ValidateRange(validator, NumberOfGuesses, NumberOfGuessesMin, NumberOfGuessesMax, "NumberOfGuesses");
     ValidateHiddenVectorUser(validator);
 }
Esempio n. 17
0
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
     validator.AssertError(DelayMemorySize > 0, this, "DelayMemorySize must be a positive integer.");
     validator.AssertError(ApproachValue.Factor <= 1 && ApproachValue.Factor > 0, this, "Factor must be greater then 0 and less or equal to 1.");
     validator.AssertError(ApproachValue.Delta >= 0, this, "Delta must be a positive integer or zero");
 }
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (UseCustomDataset)
            {
                try
                {
                    this.m_bitmaps      = LoadBitmaps(NumFrames, RootFolder, Search, Extension);
                    this.m_annotiations = LoadDatafile(AdditionalDataset);
                }
                catch (ArgumentOutOfRangeException e)
                {
                    validator.AddWarning(this, "Loading default dataset, cause: " + e.Message);
                    //UseDefaultBitmaps();
                }
                catch (IndexOutOfRangeException e)
                {
                    validator.AddWarning(this, "Loading the default dataset, cause: " + e.Message);
                    //UseDefaultBitmaps();
                }
                catch (Exception)
                {
                    validator.AddWarning(this, "Loading the default dataset, cause: could not read file(s)");
                    //UseDefaultBitmaps();
                }
            }
            else
            {
                UseDefaultBitmaps();
            }
        }
Esempio n. 19
0
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
     validator.AssertError(Input != null, this, "Input connection missing!");
     validator.AssertError(LENGTH > 0, this, "The length of encoded output have to be larger than 0!");
     validator.AssertError(ON_BITS_LENGTH < LENGTH, this, "The value ON_BITS_LENGTH should be smaller than LENGTH (around 2% of the LENGTH value is recomended)!");
 }
Esempio n. 20
0
        public ValidationForm(MainForm mainForm)
        {
            InitializeComponent();
            Validator = new MyValidator();

            m_mainForm = mainForm;
        }
Esempio n. 21
0
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);
            validator.AssertError(Input.Count != 0, this, "Zero input size is not allowed.");

            base.Validate(validator);
            validator.AssertError(Reward.Count != 0, this, "Zero reward size is not allowed.");
        }
Esempio n. 22
0
 public override void Validate(MyValidator validator)
 {
     //either there is no input, or the input shoud be a scalar
     if (InputNumber != null)
     {
         validator.AssertWarning(InputNumber.Count == 1, this, "There should be no input or the input should be a scalar. (Using just the first element out of " + InputNumber.Count + ".)");
     }
 }
Esempio n. 23
0
        public MySimulation(MyValidator validator)
        {
            AutoSaveInterval = 0;
            GlobalDataFolder = String.Empty;

            Validator            = validator;
            validator.Simulation = this;
        }
Esempio n. 24
0
        public ConnectionHandler(Socket client, IServerRouteConfig serverRouteConfig)
        {
            MyValidator.ThrowIfNull(client, nameof(client));
            MyValidator.ThrowIfNull(serverRouteConfig, nameof(serverRouteConfig));

            this.client            = client;
            this.serverRouteConfig = serverRouteConfig;
        }
Esempio n. 25
0
        public HttpHeader(string key, string value)
        {
            MyValidator.ThrowIfNullOrEmpty(key, nameof(key));
            MyValidator.ThrowIfNullOrEmpty(value, nameof(value));

            this.Key   = key;
            this.Value = value;
        }
Esempio n. 26
0
 public override void Validate(MyValidator validator)
 {
     base.Validate(validator);
     if (FirstInput != null && SecondInput != null)
     {
         validator.AssertError(FirstInput.Count == SecondInput.Count, this, "Operand sizes differ!");
     }
 }
Esempio n. 27
0
        //Validation rules
        public override void Validate(MyValidator validator)
        {
            validator.AssertError((InputHeight - FilterHeight + 2 * ZeroPadding) % VerticalStride == 0, this, "Filter doesn't fit vertically when striding.");

            validator.AssertError((InputWidth - FilterWidth + 2 * ZeroPadding) % HorizontalStride == 0, this, "Filter doesn't fit horizontally when striding.");

            validator.AssertInfo(ZeroPadding == (FilterWidth - 1) / 2 && ZeroPadding == (FilterHeight - 1) / 2, this, "Input and output might not have the same dimension. Set stride to 1 and zero padding to ((FilterSize - 1) / 2) to fix this.");
        }
Esempio n. 28
0
        public override void Validate(MyValidator validator)
        {
            ScriptCheckMethod      = null;
            ScriptShouldStopMethod = null;

            CSharpCodeProvider codeProvider = new CSharpCodeProvider();
            CompilerParameters parameters   = new CompilerParameters()
            {
                GenerateInMemory   = false,
                GenerateExecutable = false,
            };

            parameters.ReferencedAssemblies.Add("GoodAI.Platform.Core.dll");
            parameters.ReferencedAssemblies.Add("System.Core.dll");    //for LINQ support
            parameters.ReferencedAssemblies.Add("System.Runtime.dll"); //for LINQ support
            // TODO: load the xunit dll in Brain Simulator UI from the module directory.
            parameters.ReferencedAssemblies.Add("xunit.assert.dll");
            parameters.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);

            //Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
            //IEnumerable<Assembly> openTKAssemblies = loadedAssemblies.Where(x => x.ManifestModule.Name == "xunit.assert.dll");
            //if (openTKAssemblies.Count() > 0)
            //    parameters.ReferencedAssemblies.Add(openTKAssemblies.First().Location);

            CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, Script);

            if (results.Errors.HasErrors)
            {
                string message = "";

                foreach (CompilerError error in results.Errors)
                {
                    message += "Line " + error.Line + ": " + error.ErrorText + "\n";
                }

                validator.AddError(this, "Errors in compiled script:\n" + message);
                return;
            }
            else if (results.CompiledAssembly == null)
            {
                validator.AddError(this, "Compiled assembly is null.");
                return;
            }

            try
            {
                Type enclosingType = results.CompiledAssembly.GetType("Runtime.Script");

                ScriptCheckMethod = enclosingType.GetMethod("Check");
                validator.AssertError(ScriptCheckMethod != null, this, "Check() method not found in compiled script");

                ScriptShouldStopMethod = enclosingType.GetMethod("ShouldStop");  // optional, don't check for null
            }
            catch (Exception e)
            {
                validator.AddError(this, "Script analysis failed: " + e.GetType().Name + ": " + e.Message);
            }
        }
 public override void Validate(MyValidator validator)
 {
     validator.AssertError(ActionInput != null, this, "ActionInput must not be null");
     if (ActionInput != null)
     {
         validator.AssertError(ActionInput.Count == 6, this, "Size of ActionInput must be 6");
     }
     //base.Validate(validator);
 }
        public override void Validate(MyValidator validator)
        {
            base.Validate(validator);

            if (MotivationInput.Count != 1)
            {
                validator.AddError(this, "MotivationInput requires size of 1");
            }
        }