Esempio n. 1
0
 protected override RuleImp VisitRuleElement(EmptyRule info)
 {
     return(new EmptyRuleImp
     {
         Name = info.Name
     });
 }
Esempio n. 2
0
        public string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false)
        {
            if (null == attribute)
            {
                throw new ArgumentNullException("attribute");
            }

            EmptyRule emptyRule = canBeEmpty ? EmptyRule.CanBeEmpty : EmptyRule.CanBeWhitespaceOnly;
            string    value     = this.GetAttributeValue(sourceLineNumbers, attribute, emptyRule);

            if (String.IsNullOrEmpty(value) && canBeEmpty)
            {
                return(String.Empty);
            }
            else if (!String.IsNullOrEmpty(value))
            {
                // If the value starts and ends with braces or parenthesis, accept that and strip them off.
                if ((value.StartsWith("{", StringComparison.Ordinal) && value.EndsWith("}", StringComparison.Ordinal)) ||
                    (value.StartsWith("(", StringComparison.Ordinal) && value.EndsWith(")", StringComparison.Ordinal)))
                {
                    value = value.Substring(1, value.Length - 2);
                }

                if (generatable && "*".Equals(value, StringComparison.Ordinal))
                {
                    return(value);
                }

                if (ParseHelper.PutGuidHere.IsMatch(value))
                {
                    this.Messaging.Write(ErrorMessages.ExampleGuid(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
                    return(CompilerConstants.IllegalGuid);
                }
                else if (value.StartsWith("!(loc", StringComparison.Ordinal) || value.StartsWith("$(loc", StringComparison.Ordinal) || value.StartsWith("!(wix", StringComparison.Ordinal))
                {
                    return(value);
                }
                else if (Guid.TryParse(value, out var guid))
                {
                    var uppercaseGuid = guid.ToString().ToUpperInvariant();

                    // TODO: This used to be a pedantic error, what should it be now?
                    //if (uppercaseGuid != value)
                    //{
                    //    this.Messaging.Write(WixErrors.GuidContainsLowercaseLetters(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
                    //}

                    return(String.Concat("{", uppercaseGuid, "}"));
                }
                else
                {
                    this.Messaging.Write(ErrorMessages.IllegalGuidValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
                }
            }

            return(CompilerConstants.IllegalGuid);
        }
        public void Validar(Clientes cliente)
        {
            EmptyRule emptyRule = new EmptyRule();

            emptyRule.IsEmpty(cliente.RutCliente, "Rut Cliente");
            emptyRule.IsEmpty(cliente.Usuario, "Usuario");
            emptyRule.IsEmpty(cliente.Password, "Contraseña");
            emptyRule.IsEmpty(cliente.NombreCliente, "Nombre Cliente");
            emptyRule.IsEmpty(cliente.Direccion, "Dirección");
            emptyRule.IsEmpty(cliente.Telefono.ToString(), "Telefono");
        }
Esempio n. 4
0
        public void create(UsuarioEntity user)
        {
            EmptyRule empty = new EmptyRule();

            empty.isEmpty("Nombre Usuario", user.User);
            empty.isEmpty("Password", user.Password);
            MaxLengthRule maxLength = new MaxLengthRule();

            maxLength.isValid("Nombre Usuario", user.User, 40);
            maxLength.isValid("Password", user.Password, 80);
        }
Esempio n. 5
0
        public void autentication(string user, string pass)
        {
            EmptyRule empty = new EmptyRule();

            empty.isEmpty("USER", user);
            empty.isEmpty("PASS", pass);
            UserDAO dao = new UserDAOImpl();

            if (!dao.autentication(user, pass))
            {
                throw new BusinessException(
                          "USUARIO O CONTRASEÑA INVALIDO");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// This is a specific evaluation data generation method used to create
        /// - 2 sets of data (one set with only one homogeneous criterion with 4 dimensions, one set with 2 homogeneous and 2 heterogeous matching criteria, each with 4 dimensions)
        /// - each set in three variations (data distribution uniformly (all values 0..1 have same possibility, gausian values between 0..1, and only extreme values (0,1))
        /// - the 6 combinations of sets (S) and variances (V) are all generated 100 times for 500 participants
        /// - automatically named and stored
        ///
        /// Data created with this method has been used to compare the different matchers implemented in namespace GroupAL.Matcher, e.g. to be published in
        /// Konert, J.: Interactive Multimedia Learning: Using Social Media for Peer Education in Single-Player Educational Games (accepted for publication). Technische Universität Darmstadt, Germany 2014.
        /// </summary>
        private void generateDummyParticipants()
        {
            IParticipantReaderWriter tw = new TextFileParticipantReaderWriter();

            for (int i = 0; i < 2; i++)
            {// 2 sets
                int numhet = 1;
                int dimhet = 4;
                int numhom = 0;
                int dimhom = 4;
                if (i == 1)
                {
                    numhet = 2;
                    numhom = 2;
                }
                for (int j = 0; j < 3; j++)
                {// 3 variations
                    IRule           rule   = new EmptyRule();
                    IValueGenerator valgen = new UniformValueGenerator();
                    if (j == 1)
                    {
                        valgen = new GaussianValueGenerator();
                    }
                    if (j == 2)
                    {
                        rule = new TeamMakerRule(); // builds 1 and 0 (extreme) values. Only ~one~ 1 for heterogeneous criteria, several 1s for homogeneous criteria
                    }
                    for (int k = 1; k <= 100; k++)  // number of rounds to do it. (100 evaluation runs)
                    {
                        String filename = ".\\data\\GroupALParticipantsSet" + (i + 1) + "V" + (j + 1) + "_" + k + ".csv";
                        //String filename = "GroupALParticipantsN"+amount+"Het"+numHet+"Dim"+hetDim+"Hom"+numHom+"Dim"+homDim+".csv";
                        // set here number of participants (500)
                        ParticipantGenerator gen = new ParticipantGenerator(500, numhet, dimhet, numhom, dimhom, valgen, rule, tw, filename);
                    }
                }
            }
        }
Esempio n. 7
0
 public string GetAttributeValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule = EmptyRule.CanBeWhitespaceOnly)
 {
     return(Common.GetAttributeValue(this.Messaging, sourceLineNumbers, attribute, emptyRule));
 }
Esempio n. 8
0
        /// <summary>
        /// Get an attribute value.
        /// </summary>
        /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
        /// <param name="attribute">The attribute containing the value to get.</param>
        /// <param name="emptyRule">A rule for the contents of the value. If the contents do not follow the rule, an error is thrown.</param>
        /// <param name="messageHandler">A delegate that receives error messages.</param>
        /// <returns>The attribute's value.</returns>
        internal static string GetAttributeValue(IMessaging messaging, SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule)
        {
            var value = attribute.Value;

            if ((emptyRule == EmptyRule.MustHaveNonWhitespaceCharacters && String.IsNullOrEmpty(value.Trim())) ||
                (emptyRule == EmptyRule.CanBeWhitespaceOnly && String.IsNullOrEmpty(value)))
            {
                messaging.Write(ErrorMessages.IllegalEmptyAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName));
                return(String.Empty);
            }

            return(value);
        }
Esempio n. 9
0
        internal static string GetAttributeValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule, Action <MessageEventArgs> messageHandler)
        {
            string value = attribute.Value;

            if ((emptyRule == EmptyRule.MustHaveNonWhitespaceCharacters && String.IsNullOrEmpty(value.Trim())) ||
                (emptyRule == EmptyRule.CanBeWhitespaceOnly && String.IsNullOrEmpty(value)))
            {
                if (null != messageHandler)
                {
                    messageHandler(WixErrors.IllegalEmptyAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName));
                }

                return(String.Empty);
            }

            return(value);
        }
Esempio n. 10
0
        internal static string GetAttributeValue(SourceLineNumber sourceLineNumbers, XmlAttribute attribute, EmptyRule emptyRule, Action <MessageEventArgs> messageHandler)
        {
            if (null == attribute)
            {
                throw new ArgumentNullException("attribute");
            }

            if ((emptyRule == EmptyRule.MustHaveNonWhitespaceCharacters && String.IsNullOrEmpty(attribute.Value.Trim())) ||
                (emptyRule == EmptyRule.CanBeWhitespaceOnly && String.IsNullOrEmpty(attribute.Value)))
            {
                if (null != messageHandler)
                {
                    messageHandler(WixErrors.IllegalEmptyAttributeValue(sourceLineNumbers, attribute.OwnerElement.Name, attribute.Name));
                }

                return(String.Empty);
            }

            return(attribute.Value);
        }
Esempio n. 11
0
File: Common.cs Progetto: zooba/wix3
        internal static string GetAttributeValue(SourceLineNumberCollection sourceLineNumbers, XmlAttribute attribute, EmptyRule emptyRule, Action<MessageEventArgs> messageHandler)
        {
            if (null == attribute)
            {
                throw new ArgumentNullException("attribute");
            }

            if ((emptyRule == EmptyRule.MustHaveNonWhitespaceCharacters && String.IsNullOrEmpty(attribute.Value.Trim())) ||
                (emptyRule == EmptyRule.CanBeWhitespaceOnly && String.IsNullOrEmpty(attribute.Value)))
            {
                if (null != messageHandler)
                {
                    messageHandler(WixErrors.IllegalEmptyAttributeValue(sourceLineNumbers, attribute.OwnerElement.Name, attribute.Name));
                }

                return String.Empty;
            }

            return attribute.Value;
        }
Esempio n. 12
0
 public string GetAttributeValue(SourceLineNumberCollection sourceLineNumbers, XmlAttribute attribute, EmptyRule emptyRule)
 {
     return Common.GetAttributeValue(sourceLineNumbers, attribute, emptyRule, this.OnMessage);
 }
Esempio n. 13
0
 protected virtual TR VisitRuleElement(EmptyRule info)
 {
     throw new NotSupportedException();
 }
Esempio n. 14
0
 internal Rule GetRule(ElementType result)
 {
     return((Rule)Activator.CreateInstance(EmptyRule.GetType(),
                                           result, FirstElementType, SecondElementType));
 }