- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
/// <summary>
/// Сохраняет элементы справочника
/// </summary>
public IEnumerable SaveBookElements(IList elements) {
IList result = null;
try {
if (elements != null && elements.Count > 0) {
if (elements.GetType().GetGenericArguments().Length == 1 && elements[0].GetType() != elements.GetType().GetGenericArguments()[0]) {
var mi = typeof(BooksWorker).GetMethod("SaveTypedBookElements", BindingFlags.NonPublic | BindingFlags.Instance)
.MakeGenericMethod(new[] { elements[0].GetType() });
var casted = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(new[] { elements[0].GetType() }));
foreach (var t in elements) {
casted.Add(t);
}
result = mi.Invoke(this, new object[] { casted }) as IList;
}
}
}
catch (Exception ex) {
throw new ApplicationException("Ошибка!", ex);
}
return result;
}
TarasB 31.03.2011 10:56 # +6
> throw new ApplicationException("Ошибка!", ex);
Ошибка... эх...
guest 01.04.2011 15:22 # 0