Example #1
0
        public override void Parse(List <string> parts)
        {
            if (parts.Count < 5)
            {
                throw new ModScriptParserException("Expected at least 5 tokens");
            }

            ClassName      = parts[1];
            CollectionName = CleanHashString(parts[2]);
            FieldName      = parts[3];
            PropertyPath   = new List <string>();

            if (FieldName.Contains('['))
            {
                var split = FieldName.Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
                if (split[1] == "^")
                {
                    ArrayIndex = -1;
                }
                else
                {
                    ArrayIndex = int.Parse(split[1]);
                }
                FieldName = split[0];
            }

            FieldName = CleanHashString(FieldName);

            if (parts.Count > 5)
            {
                PropertyPath = parts.Skip(4).Take(parts.Count - 5).ToList();
                Value        = parts[^ 1];
Example #2
0
 internal string GetXPath(string nsPrefix)
 {
     if (XPath.IsNullOrWhiteSpace())
     {
         if (_defaultXPath.IsNullOrWhiteSpace())
         {
             if (nsPrefix.IsNullOrWhiteSpace())
             {
                 if (!FieldName.IsNullOrWhiteSpace())
                 {
                     _defaultXPath = $"{FieldName}|@{FieldName}";
                 }
                 else
                 {
                     _defaultXPath = $"{Name}|@{Name}";
                 }
             }
             else
             {
                 if (!FieldName.IsNullOrWhiteSpace())
                 {
                     if (FieldName.Contains(":"))
                     {
                         _defaultXPath = $"{FieldName}|@{FieldName}";
                     }
                     else
                     {
                         _defaultXPath = $"{FieldName}|@{FieldName}|{nsPrefix}:{FieldName}";
                     }
                 }
                 else
                 {
                     if (Name.Contains(":"))
                     {
                         _defaultXPath = $"{Name}|@{Name}";
                     }
                     else
                     {
                         _defaultXPath = $"{Name}|@{Name}|{nsPrefix}:{Name}";
                     }
                 }
             }
         }
         return(_defaultXPath);
     }
     else
     {
         return(XPath);
     }
 }
Example #3
0
        /// <summary>
        /// Builds the criteria.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <param name="dependencyCriterion">The dependency criterion.</param>
        public virtual void BuildCriteria(DetachedCriteria criteria, Junction dependencyCriterion)
        {
            if (criteria == null)
            {
                ThrowHelper.ThrowArgumentNullException("criteria");
            }

            if (FieldName.Contains(".") && !FieldName.ToLower().StartsWith("id."))
            {
                CreateDetachedCriteria(criteria, FieldName, dependencyCriterion);
            }
            else
            {
                string           fieldName = string.Empty;
                AssociationEntry e         = null;
                if (!FieldName.ToLower().Contains("id."))
                {
                    Dictionary <string, AssociationEntry> ascs = GetAssociations();
                    if (ascs.ContainsKey(FieldName))
                    {
                        e = ascs[FieldName];
                    }
                    else
                    {
                        e           = new AssociationEntry(FieldName, FieldName, string.Format("p{0}", Stopwatch.GetTimestamp().ToString()));
                        ascs[e.Key] = e;
                    }
                    fieldName = string.Format("{0}.{1}", criteria.Alias, e.Association);
                }
                else
                {
                    fieldName = string.IsNullOrEmpty(criteria.Alias) ? FieldName : string.Format("{0}.{1}", criteria.Alias, FieldName);
                }

                if (mCriterion == null)
                {
                    mCriterion = BuildCriterion(fieldName);
                }
                if (dependencyCriterion != null)
                {
                    dependencyCriterion.Add(mCriterion);
                }
                else
                {
                    criteria.Add(mCriterion);
                }
            }
        }
Example #4
0
 protected void uniqValue_Required_ServerValidate(object source, ServerValidateEventArgs args)
 {
     args.IsValid = true;
     if (ViewState[FieldName + "FieldClassName"] != null)
     {
         string realName = FieldName;
         if (FieldName.Contains("."))
         {
             realName = FieldName.Substring(FieldName.IndexOf(".") + 1);
         }
         MetaField field = MetaDataWrapper.GetMetaFieldByName(ViewState[FieldName + "FieldClassName"].ToString(), realName);
         if (!MetaObjectProperty.CheckUniqueValue(field, ObjectId, this.Value))
         {
             args.IsValid = false;
         }
     }
 }
Example #5
0
        public virtual int UpdateData(IEnumerable <T> valueList, params string[] FieldName)
        {
            if (valueList.Count <T>() == 0)
            {
                return(0);
            }
            PropertyInfo[]        properties = typeof(T).GetProperties();
            StringBuilder         builder    = new StringBuilder();
            int                   num        = 0;
            List <MySqlParameter> objList    = new List <MySqlParameter>();

            foreach (T local in valueList)
            {
                builder.Append("UPDATE " + this.Dal.TableName + " SET ");
                string       str  = "";
                PropertyInfo info = null;
                foreach (PropertyInfo info2 in properties)
                {
                    if (info2.Name.ToLower() != this.Dal.PrimaryKeyName.ToLower())
                    {
                        if ((info2.Name.ToLower() != "_id") && ((FieldName.Length == 0) || FieldName.Contains <string>(info2.Name)))
                        {
                            str = str + string.Format("{0}=?{1},", info2.Name, info2.Name + num);
                            objList.Add(new MySqlParameter("?" + info2.Name + num, info2.GetValue(local, null)));
                            num++;
                        }
                    }
                    else
                    {
                        info = info2;
                    }
                }
                builder.Append(str.TrimEndComma());
                builder.AppendFormat(" WHERE {0}=?{1};", this.Dal.PrimaryKeyName, this.Dal.PrimaryKeyName + num);
                objList.Add(new MySqlParameter("?" + this.Dal.PrimaryKeyName + num, info.GetValue(local, null)));
                num++;
            }
            return(this.Dal.ExecuteNonQuery(builder.ToString(), objList.ConvertListToArray <MySqlParameter>()));
        }