Пример #1
0
        static DBTableStruct CreateColum(this DBTableStruct table, string name, object defaultvalue, bool autoincreasment = false, bool uniquekey = false)
        {
            if (table.Colums.ContainsKey(name))
            {
                throw new Exception(string.Format("already existed table colum {0}.", name));
            }
            DBColum Colum = table.Colums.GetOrAdd(name, DBColum.Create(name, defaultvalue, autoincreasment, uniquekey));

            if (OnCreateColum != null)
            {
                OnCreateColum.Invoke(table);
            }
            return(table);
        }
Пример #2
0
        static DBTableStruct CreateTable(this string name, bool crypted)
        {
            if (Manager.ContainsKey(name))
            {
                throw new Exception("already existed table.");
            }
            DBTableStruct table = DBTableStruct.Create(name, crypted);

            Manager.Add(name, table);
            if (OnCreateTable != null)
            {
                OnCreateTable.Invoke(table);
            }
            return(table);
        }
Пример #3
0
        public static DBTableStruct Create(string name, bool Crypted = false)
        {
            var table = new DBTableStruct()
            {
                Name             = name,
                CryptoGraphieKey = string.Empty,
                Colums           = new ConcurrentDictionary <string, DBColum>()
            };

            if (Crypted)
            {
                table.CryptoGraphieKey = CoreResolver.RandomizedCryptionKey(name);
            }
            return(table);
        }
Пример #4
0
        static async void OnCreateColumVoid(DBTableStruct table)
        {
            int maxValues = table.Colums.Values.OrderByDescending(p => p.Values.Count).FirstOrDefault().Values.Count;

            foreach (DBColum colum in table.Colums.Values.Where(p => p.Values.Count < maxValues))
            {
                int neededvalues = maxValues - colum.Values.Count;
                await Task.Run(() =>
                {
                    while (neededvalues > 0)
                    {
                        colum.Add(colum.DefaultValue);
                        --neededvalues;
                    }
                });
            }
        }
Пример #5
0
 static async void OnCreateTableVoid(DBTableStruct table)
 {
     await Task.Run(() => { });
 }