Esempio n. 1
0
        private Document GetNewDocument(IDictionarySerializable entity)
        {
            IDictionary <string, object> datas = entity.DictSerialize();

            var document = new Document();

            foreach (string key in datas.Keys)
            {
                {
                    if (datas[key] is IDictionary <string, object> )
                    {
                        document[key] = new Document(datas[key] as IDictionary <string, object>);
                    }
                    else if (datas[key] is List <IDictionary <string, object> > )
                    {
                        var items = datas[key] as List <IDictionary <string, object> >;
                        document[key] = items.Select(d => new Document(d)).ToList();
                    }
                    else
                    {
                        document[key] = datas[key];
                    }
                }
            }

            return(document);
        }
Esempio n. 2
0
        private void inpc_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == this.Path)
            {
                var value = propInfo.GetValue(this.inpc, new object[0]) as ListCollectionView;
                if (value != null)
                {
                    var data = value.SourceCollection;

                    if (data != null)
                    {
                        var su = data.GetEnumerator();
                        this.control.Columns.Clear();
                        var res = su.MoveNext();
                        if (res == true)
                        {
                            IDictionarySerializable dict = su.Current as IDictionarySerializable;

                            if (dict != null)
                            {
                                foreach (var item in dict.DictSerialize(Scenario.Binding))
                                {
                                    this.control.Columns.Add(new Column {
                                        Title = item.Key, FieldName = item.Key
                                    });
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public static bool Contains(this IDictionarySerializable value, string content)
        {
            IDictionary <string, object> dataItems = value.DictSerialize(Scenario.Search);

            return
                (dataItems.Where(d => d.Value != null).Select(item => item.Value.ToString()).Where(info => info != null).
                 Any(info => info.Contains(content)));
        }
Esempio n. 4
0
        /// <summary>
        ///     Get all digital type Column names;
        /// </summary>
        /// <param name="dat"></param>
        /// <returns></returns>
        public static List <string> GetNumbricKeys(this IDictionarySerializable dat)
        {
            var items      = dat.DictSerialize();
            var allColumns =
                items.Where(d => AttributeHelper.IsNumeric(d.Value) || AttributeHelper.IsFloat(d.Value)).Select(
                    d => d.Key).ToList();

            return(allColumns);
        }
Esempio n. 5
0
        public virtual void ReadConfig(string path = null)
        {
            if (path == null)
            {
                path = SavePath;
            }
            IFileConnector json = FileConnector.SmartGetExport(path);

            json.FileName = path;
            IDictionarySerializable da = json.ReadFile().FirstOrDefault();

            DictDeserialize(da.DictSerialize());
        }
Esempio n. 6
0
        private bool NeedConfig(IDictionarySerializable item)
        {
            var config = item.DictSerialize();
            var keys   = new[] { "Type", "Group", "Column", "NewColumn" };

            foreach (var k in config.DataItems)
            {
                if (keys.Contains(k.Key))
                {
                    continue;
                }
                if (k.Value == null || k.Value.ToString() == "")
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 7
0
        public void UpdateDocument(IDictionarySerializable data, Document document)
        {
            IDictionary <string, object> datas = data.DictSerialize();

            foreach (string key in datas.Keys)
            {
                if (datas[key] is IDictionary <string, object> )
                {
                    document[key] = new Document(datas[key] as IDictionary <string, object>);
                }
                else if (datas[key] is List <IDictionary <string, object> > )
                {
                    var items = datas[key] as List <IDictionary <string, object> >;
                    document[key] = items.Select(d => new Document(d)).ToList();
                }
                else
                {
                    document[key] = datas[key];
                }
            }
        }
Esempio n. 8
0
        public static bool IsEqual(this IDictionarySerializable value, IDictionary <string, object> content)
        {
            IDictionary <string, object> dic1 = value.DictSerialize();

            foreach (var o in dic1)
            {
                object res;
                if (content.TryGetValue(o.Key, out res))
                {
                    if (res != o.Value)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 9
0
 public static List <string> GetKeys(this IDictionarySerializable dat)
 {
     return(dat.DictSerialize().Keys.ToList());
 }
Esempio n. 10
0
 public static void DictCopyTo(
     this IDictionarySerializable source, IDictionarySerializable dest, Scenario scenario = Scenario.Database)
 {
     dest.DictDeserialize(source.DictSerialize(scenario), scenario);
 }