Пример #1
0
        public static void Update(BusinessObject obj)
        {
            if (Find(obj.ID) == null)
            {
                throw new NullReferenceException("Object with the specified ID does not exist in store");
            }

            _data[_data.BinarySearch(obj)] = obj;
        }
Пример #2
0
        public static void Insert(BusinessObject obj)
        {
            BusinessObject insertedObj = new BusinessObject(GetNextID()); ;


            PropertyInfo[] properties = obj.GetType().GetProperties();
            foreach (PropertyInfo prop in properties)
            {
                if (prop.Name != "ID")
                {
                    insertedObj.GetType().GetProperty(prop.Name).SetValue(insertedObj, prop.GetValue(obj, null), null);
                }
            }

            _data.Add(insertedObj);
        }