示例#1
0
 private void OnTextPropertyChange(DependencyPropertyChangedEventArgs e)
 {
     if (DbTypeInfo == null)
     {
         return;
     }
     try
     {
         object v = DbTypeInfo.Parse(Text);
         SetValue(ValueProperty, v);
         SetIsError(false);
         string txt = DbTypeInfo?.ValueToString(Value);
         if (Text != txt)
         {
             SetValue(TextProperty, txt);
         }
     }
     catch
     {
         SetIsError(true);
     }
     TextChanged?.Invoke(this, e);
 }
示例#2
0
 private void InvalidateDbTypeInfo()
 {
     _dbTypeInfo = null;
 }
示例#3
0
        public QueryStore(TextReader reader)
        {
            StringBuilder buf = new StringBuilder();

            for (string s = reader.ReadLine(); s != null && s.StartsWith(ParamSeparator); s = reader.ReadLine())
            {
                buf.AppendLine(s);
            }
            _sql       = buf.ToString();
            Parameters = new ParameterStoreCollection();
            while (reader.Peek() != -1)
            {
                string pName = GetWord(reader, false);
                if (pName == null)
                {
                    break;
                }
                if (pName.StartsWith(ParamSeparator))
                {
                    return;
                }
                if (!pName.StartsWith("--"))
                {
                    throw new ApplicationException("パラメータ宣言が -- で開始されていません");
                }
                if (pName == "--")
                {
                    pName = GetWord(reader, false);
                }
                else
                {
                    pName = pName.Substring(2);
                }
                string s = GetWord(reader, false);
                if (s == null || s != ":")
                {
                    throw new ApplicationException(":が見つかりません");
                }
                string typeStr = GetWord(reader, false);
                s = GetWord(reader, false);
                if (s == null || s != "=")
                {
                    throw new ApplicationException("=が見つかりません");
                }
                string         val   = GetWord(reader, true);
                ParameterStore param = new ParameterStore(pName);
                DbTypeInfo     info  = DbTypeInfo.GetDbTypeInfo(typeStr);
                if (info == null)
                {
                    throw new ApplicationException(string.Format("不明な型です: {0}", typeStr));
                }
                param.DbType = info.DbType;
                if (string.IsNullOrEmpty(val) || string.Compare(val, "null", true) == 0)
                {
                    param.Value = DBNull.Value;
                }
                else
                {
                    val         = DequoteStr(val);
                    param.Value = info.Parse(val);
                }
                Parameters.Add(param);
            }
        }