コード例 #1
0
        public CodeItem(IDecoderItem item)
        {
            TkDebug.AssertArgumentNull(item, "item", null);

            Value = item.Value;
            Name  = item.Name;
        }
コード例 #2
0
ファイル: ObjectContainer.cs プロジェクト: madiantech/tkcore
        public void Decode(IEnumerable <IFieldInfoEx> fields)
        {
            if (fields == null)
            {
                return;
            }
            var decodeFields = from item in fields
                               where item.Decoder != null && item.Decoder.Type != DecoderType.None
                               select item;

            if (Decoder == null)
            {
                Decoder = new ObjectDecoderContainer();
            }
            foreach (var item in decodeFields)
            {
                IDecoder coder = GetDecoder(item.Decoder);
                if (coder != null)
                {
                    IDecoderItem decodeItem = coder.Decode(
                        MainObject.MemberValue(item.NickName).ConvertToString());
                    if (decodeItem != null)
                    {
                        Decoder.Add(item.NickName, decodeItem);
                    }
                }
            }
        }
コード例 #3
0
ファイル: BaseDbEasySearch.cs プロジェクト: madiantech/tkcore
        public override IDecoderItem[] SearchByName(string name, params object[] args)
        {
            TkDbContext context;
            bool        createContext;

            GetContext(args, out context, out createContext);

            try
            {
                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, NameField, name);
                DataTable     table   = FetchRows(context, fDataSet, builder, 2);
                if (table == null || table.Rows.Count == 0)
                {
                    return(null);
                }
                IDecoderItem[]       result  = new IDecoderItem[table.Rows.Count];
                int                  index   = 0;
                DataColumnCollection columns = table.Columns;
                foreach (DataRow row in table.Rows)
                {
                    result[index++] = new DataRowDecoderItem(columns, row,
                                                             DecoderConst.CODE_NICK_NAME, fExpression, fDisplayExpression);
                }

                return(result);
            }
            finally
            {
                if (createContext)
                {
                    context.Dispose();
                }
            }
        }
コード例 #4
0
 public IDecoderItem this[string nickName]
 {
     get
     {
         IDecoderItem result = ObjectUtil.TryGetValue(fDictionary, nickName);
         return(result);
     }
 }
コード例 #5
0
        public void Add(string nickName, IDecoderItem item)
        {
            TkDebug.AssertArgumentNullOrEmpty(nickName, "nickName", this);

            if (item == null)
            {
                return;
            }

            fDictionary[nickName] = item;
        }
コード例 #6
0
        public MultipleDecodeItem(string code, IDecoder decoder, params object[] args)
        {
            fDecodeData = new MultipleDecoderData();
            QuoteStringList list  = QuoteStringList.FromString(code);
            var             items = list.CreateEnumerable();

            foreach (string item in items)
            {
                IDecoderItem dItem = decoder.Decode(item, args);
                fDecodeData.AddItem(dItem);
            }
            Name        = fDecodeData.ToJson();
            DisplayName = Name;
        }
コード例 #7
0
        public void AddItem(IDecoderItem item)
        {
            if (item == null)
            {
                return;
            }

            CodeItem codeItem = item as CodeItem;

            if (codeItem == null)
            {
                codeItem = new CodeItem(item);
            }
            Data.Add(codeItem);
        }
コード例 #8
0
        public void AddData(IDecoderItem row, IEnumerable <DecoderAdditionInfo> infos)
        {
            if (row == null || infos == null)
            {
                return;
            }

            foreach (var info in infos)
            {
                try
                {
                    string columnName = info.DecoderNickName;
                    string value      = row[columnName].ToString();
                    AdditionData.Add(columnName, value);
                }
                catch
                {
                }
            }
        }
コード例 #9
0
ファイル: EasySearch.cs プロジェクト: madiantech/tkcore
        public EasySearchErrorType CheckName(string name, ref string value, params object[] args)
        {
            if (!string.IsNullOrEmpty(value))
            {
                IDecoderItem item = Decode(value, args);
                // YJC 2012.9.21修改,此处为适应IE提交自动删除空格的问题
                //DataRow row = FindByKey(selector, tableName, value);
                if (item == null || SafeTrim(item.Name) != SafeTrim(name))
                {
                    value = string.Empty;
                    return(EasySearchErrorType.NotExist);
                }
                else
                {
                    return(EasySearchErrorType.None);
                }
            }
            if (string.IsNullOrEmpty(value))
            {
                IDecoderItem[] result = SearchByName(name, args);
                if (result == null || result.Length == 0)
                {
                    value = string.Empty;
                    return(EasySearchErrorType.NotExist);
                }
                switch (result.Length)
                {
                case 1:
                    value = result[0].Value;
                    return(EasySearchErrorType.None);

                default:
                    value = string.Empty;
                    return(EasySearchErrorType.VariousTwo);
                }
            }
            value = string.Empty;
            return(EasySearchErrorType.NotExist);
        }
コード例 #10
0
 internal DataRowDecoderItem(IDecoderItem item)
 {
     Value       = item.Value;
     Name        = item.Name;
     DisplayName = item.DisplayName;
 }