Пример #1
0
        internal void FastDelete(DBObject ob)
        {
            if (ob.IsDeleted)
            {
                return;
            }

            ob.IsTemporary = true;

            ob.OnDeleted();
        }
Пример #2
0
        internal void Delete(DBObject ob)
        {
            if (ob.IsDeleted)
            {
                return;
            }

            Collections[ob.ThisType].Delete(ob);

            ob.OnDeleted();

            PropertyInfo[] properties = ob.ThisType.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.SetProperty);

            //Remove Internal Reference
            foreach (PropertyInfo property in properties)
            {
                Association link = property.GetCustomAttribute <Association>();

                if (property.PropertyType.IsSubclassOf(typeof(DBObject)))
                {
                    if (link != null && link.Aggregate)
                    {
                        DBObject tempOb = (DBObject)property.GetValue(ob);

                        tempOb.Delete();
                        continue;
                    }

                    property.SetValue(ob, null);
                    continue;
                }

                if (!property.PropertyType.IsGenericType || property.PropertyType.GetGenericTypeDefinition() != typeof(DBBindingList <>))
                {
                    continue;
                }

                IBindingList list = (IBindingList)property.GetValue(ob);

                if (link != null && link.Aggregate)
                {
                    for (int i = list.Count - 1; i >= 0; i--)
                    {
                        ((DBObject)list[i]).Delete();
                    }
                    continue;
                }

                list.Clear();
            }
        }