/// <summary> /// Verifies that exceptionGenerator throws an exception of type expectedExceptionType. /// </summary> /// <param name="expectedExceptionType"></param> /// <param name="exceptionGenerator">A delegate that is expected to throw and exception of /// type expectedExceptionType.</param> /// <param name="message">The message to output if the verification fails.</param> /// <returns>true if exceptionGenerator through an exception of type expectedExceptionType else false.</returns> public bool VerifyException(Type expectedExceptionType, ExceptionGenerator exceptionGenerator, string message) { bool retValue = true; try { exceptionGenerator(); retValue &= Eval(false, (String.IsNullOrEmpty(message) ? String.Empty : (message + Environment.NewLine)) + "Err_05940iedz Expected exception of the type {0} to be thrown and nothing was thrown", expectedExceptionType); } catch (Exception exception) { retValue &= Eval <Type>(expectedExceptionType, exception.GetType(), (String.IsNullOrEmpty(message) ? String.Empty : (message + Environment.NewLine)) + "Err_38223oipwj Expected exception and actual exception differ. Expected {0}, got \n{1}", expectedExceptionType, exception); if (retValue && m_outputExceptionMessages) { OutputDebugInfo("{0} message: {1}" + Environment.NewLine, expectedExceptionType, exception.Message); } } return(retValue); }
/// <summary> /// Выполнить метод methodName у объекта /// </summary> /// <param name="obj">объект</param> /// <param name="methodName">имя метода</param> /// <param name="bindingFlags">условие поиска метода</param> /// <param name="args">аргументы выполняемого метода</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="Exception"></exception> /// <returns></returns> public static object GetMethodValue(this object obj, string methodName, BindingFlags bindingFlags, params object[] args) { if (obj == null) { ExceptionGenerator.Run <ArgumentNullException>("Аргумент \"obj\" равен null"); } if (String.IsNullOrEmpty(methodName)) { ExceptionGenerator.Run <ArgumentNullException>("Аргумент \"methodName\" равен null или пустой"); } Type type = obj.GetType(); try { MethodInfo methodInfo = null; methodInfo = type.GetMethod(methodName, bindingFlags); if (methodInfo == null) { ExceptionGenerator.Run <ArgumentNullException>("Метод \"{0}\" в объекте типа \"{1}\" не найдено по условиям поиска \"{2}\"", methodName, type, bindingFlags.ToString()); } return(methodInfo.Invoke(obj, args)); } catch (Exception ex) { throw ExceptionGenerator.Run(ex, "Ошибка при выполнения метода \"{0}\" объекте типа \"{1}\"", methodName, type); } }
/// <summary> /// проверяет наличия элемента в последовательности, у которого значение свойства /// , имя которого определено вторым аргументом метода /// , равно значение свойства объекта, определяемого первым аргументом /// </summary> /// <typeparam name="TItem">тип элемента</typeparam> /// <param name="originalItems">последовательность элементов</param> /// <param name="item">объект</param> /// <param name="propName">свойство по которому определяется наличие элемента в последовательности</param> /// <returns></returns> public static bool ContainsByFieldName <TItem>(this IEnumerable <TItem> originalItems, TItem item, string fieldName) { if (item == null) { ExceptionGenerator.Run <ArgumentNullException>("Объект не определен"); } if (String.IsNullOrEmpty(fieldName)) { ExceptionGenerator.Run <ArgumentNullException>("Имя поля не определено или пустое"); } var val = item.GetFlattenFieldValue(fieldName); if (val == null) { ExceptionGenerator.Run <NullReferenceException>("Поле \"{0}\" элемента не определено ", fieldName); } return(originalItems.Any(it => { var itVal = it.GetFlattenFieldValue(fieldName); return ObjectExtensions.IsEqual(val, itVal); })); }
/// <summary> /// Возвращает список свойства элементов типа TItemProp /// </summary> /// <typeparam name="FromType">тип элемента в последовательности</typeparam> /// <typeparam name="TItemProp">тип свойства</typeparam> /// <param name="originalItems">последовательность элементов</param> /// <param name="propName">имя свойства</param> /// <returns>список свойства элементов типа TItemField</returns> public static List <TItemProp> ToItemPropList <FromType, TItemProp>(this IEnumerable <FromType> originalItems, string propName) { var items = new List <TItemProp>(); if (!originalItems.Any()) { return(items); } var propValue = originalItems.ElementAt(0).GetFlattenPropertyValue(propName); if (!typeof(TItemProp).IsAssignableFrom(propValue.GetType())) { ExceptionGenerator.Run <InvalidCastException>("Свойство \"{0}\" должно реализовывать интерфейс (класс) \"{1}\"", propName, typeof(TItemProp)); } foreach (FromType item in originalItems) { var propVal = item.GetFlattenPropertyValue(propName); if (!(propVal is TItemProp)) { ExceptionGenerator.Run <InvalidCastException>("Свойство элемента типа \"{0}\" нельзя преобразовать в \"{1}\"", item.GetType(), typeof(TItemProp)); } items.Add((TItemProp)propVal); } return(items); }
public static void ThrowException() { var ex = ExceptionGenerator.GenerateException( () => ExceptionGenerator.LoopThenException(10, "inner exception test from error api")); throw new ErrorReportingApiTestException("error api exception test", ex); }
public void Db_ErrorsReportingService_LogExceptionAsync_WithInner() { using (ThreadScopedLifestyle.BeginScope(container)) { ErrorsReportingService service = container.GetInstance <ErrorsReportingService>(); try { ExceptionGenerator.ThrowsTwo(); } catch (Exception exception) { int?id = null; Assert.That(async() => { id = await service.LogExceptionAsync(this.dataSet.ApplicationsIds.ElementAt(0), exception, "ErrorType.Specific"); }, Throws.Nothing); Assert.IsNotNull(id); ErrorReportException ex = this.exceptionsSqlHelper.GetBy(id.Value); ErrorReportException innerEx = this.exceptionsSqlHelper.GetBy(ex.IdInnerException.Value); Assert.AreEqual("Two", ex.Message); Assert.AreEqual("One", innerEx.Message); } } }
public static bool ExistWord(this string actualString, string word, StringComparison stringComparisonMode, int startIndex = 0) { if (startIndex < 0 || startIndex > actualString.Length) { ExceptionGenerator.RunArgumentOutOfRangeException(startIndex, 0, actualString.Length); } int index = actualString.IndexOf(word, startIndex, stringComparisonMode); if (index >= 0) { if (index == 0 && word.Length == actualString.Length) { return(true); } if (index > 0 && index + word.Length < actualString.Length) { return(actualString[index - 1] == ' ' && actualString[index + word.Length] == ' '); } if (index > 0) { return(actualString[index - 1] == ' '); } if (index + word.Length < actualString.Length - 1) { return(actualString[index + word.Length] == ' '); } } return(false); }
static void Main() { // NOTE: Use of ElasticsearchJsonFormatter is optional (but recommended as it produces // 'idiomatic' json). If you don't want to take a dependency on // Serilog.Formatting.Elasticsearch package you can also use other json formatters // such as Serilog.Formatting.Json.JsonFormatter. // Console sink send logs to stdout which will then be read by logspout ILogger logger = new LoggerConfiguration() .Enrich.WithExceptionDetails() .WriteTo.Console(new ElasticsearchJsonFormatter()) .CreateLogger() .ForContext <Program>(); var customerGenerator = new CustomerGenerator(); var orderGenerator = new OrderGenerator(); var exceptionGenerator = new ExceptionGenerator(); while (true) { var customer = customerGenerator.Generate(); var order = orderGenerator.Generate(); logger.Information("{@customer} placed {@order}", customer, order); var exception = exceptionGenerator.Generate(); if (exception != null) { logger.Error(exception, "Problem with {@order} placed by {@customer}", order, customer); } Thread.Sleep(1000); } }
public void Db_ErrorsReportingService_LogExceptionAsync_WithInner() { using (IUnityContainer childContainer = this.container.CreateChildContainer()) { IErrorsReportingService service = childContainer.Resolve <IErrorsReportingService>(); try { ExceptionGenerator.ThrowsTwo(); } catch (Exception exception) { int?id = null; Assert.That(async() => { id = await service.LogExceptionAsync(this.dataSet.ApplicationsIds.ElementAt(0), exception, "ErrorType.Specific"); }, Throws.Nothing); Assert.IsNotNull(id); ErrorReportException ex = this.exceptionsSqlHelper.GetBy(id.Value); ErrorReportException innerEx = this.exceptionsSqlHelper.GetBy(ex.IdInnerException.Value); Assert.AreEqual("Two", ex.Message); Assert.AreEqual("One", innerEx.Message); } } }
/// <summary> /// Получить вложенный тип /// </summary> /// <param name="obj">объект, у которого получает вложенный тип</param> /// <param name="nestedTypeName">имя вложенного типа</param> /// <param name="bindingFlags">условие поиска вложенного типа</param> /// <returns>тип вложенного объекта</returns> public static Type GetNestedType(this object obj, string nestedTypeName, BindingFlags bindingFlags) { if (obj == null) { ExceptionGenerator.Run <NullReferenceException>("Аргумент \"obj\" равен null"); } if (String.IsNullOrEmpty(nestedTypeName)) { ExceptionGenerator.Run <ArgumentNullException>("Аргумент \"nestedTypeName\" равен null или пустой метода объекта типа {0}", obj.GetType()); } Type type = obj.GetType(); try { Type nestedType = type.GetNestedType(nestedTypeName, bindingFlags); return(nestedType); } catch (Exception ex) { throw ExceptionGenerator.Run(ex, "Ошибка при получении вложенного типа \"{0}\" объекта типа \"{1}\"", nestedTypeName, type); } }
/// <summary> /// Получить значение свойства propertyInfo у объекта /// </summary> /// <param name="obj">объект</param> /// <param name="propertyInfo">свойство</param> /// <param name="accessAttr">доступ к селектору свойства</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="Exception"></exception> /// <returns>значение свойства</returns> public static object GetPropertyValue(this object obj, PropertyInfo propertyInfo, AccessAttr accessAttr) { Type type = obj.GetType(); if (propertyInfo == null) { ExceptionGenerator.Run <ArgumentNullException>("Ошибка при получении значения свойства: свойство объекта типа \"{0}\" неопределено", type); } try { MethodInfo method = null; if (accessAttr == AccessAttr.All) { method = propertyInfo.GetGetMethod(); if (method == null) { method = propertyInfo.GetGetMethod(true); } return(method.Invoke(obj, null)); } method = propertyInfo.GetGetMethod(accessAttr == AccessAttr.NonPublic); return(method.Invoke(obj, null)); } catch (Exception ex) { throw ExceptionGenerator.Run(ex, "Ошибка при получении значения свойства \"{0}\" объекта типа \"{1}\"", propertyInfo.Name, type); } }
public virtual async Task <Blob> GetBlobReferenceAsync(string containerName, string blobId) { Utility.AssertNotNullOrEmpty(nameof(blobId), blobId); var retrieveBlobApiCallresult = await this.BlobsApiClient.GetBlobByIdAsync(blobId); if (false == retrieveBlobApiCallresult.ResponseMessage.IsSuccessStatusCode) { if (retrieveBlobApiCallresult.ResponseMessage.StatusCode == System.Net.HttpStatusCode.NotFound) { throw ExceptionGenerator.BlobNotFoundException(blobId); } else { throw ExceptionGenerator.GeneralFailureException(retrieveBlobApiCallresult.StringContent); } } var blobDTO = retrieveBlobApiCallresult.GetContent(); var container = await GetContainerReferenceAsync(containerName); var blob = new Blob(this, container, blobDTO.Id, blobDTO.OrigFileName, blobDTO.MimeType, blobDTO.SizeInBytes, blobDTO.DownloadRelativeUrl); return(blob); }
/// <summary> /// Возвращает список свойства элементов типа TItemField /// </summary> /// <typeparam name="FromType">тип элемента в последовательности</typeparam> /// <typeparam name="TItemField">тип свойства</typeparam> /// <param name="originalItems">последовательность элементов</param> /// <param name="propName">имя свойства</param> /// <returns>список свойства элементов типа TItemField</returns> public static List <TItemField> ToItemFieldList <FromType, TItemField>(this IEnumerable <FromType> originalItems, string fieldName) { var items = new List <TItemField>(); if (!originalItems.Any()) { return(items); } var fieldValue = originalItems.ElementAt(0).GetFlattenFieldValue(fieldName); if (!typeof(TItemField).IsAssignableFrom(fieldValue.GetType())) { ExceptionGenerator.Run <InvalidCastException>("Поле \"{0}\" должно реализовывать интерфейс (класс) \"{1}\"", fieldName, typeof(TItemField)); } foreach (FromType item in originalItems) { var fieldVal = item.GetFlattenFieldValue(fieldName); if (!(fieldVal is TItemField)) { ExceptionGenerator.Run <InvalidCastException>("Поле элемента типа \"{0}\" нельзя преобразовать в \"{1}\"", item.GetType(), typeof(TItemField)); } items.Add((TItemField)fieldVal); } return(items); }
/// <summary> /// Получить свойство определенного типа /// </summary> /// <param name="obj">объект</param> /// <param name="propertyName">имя свойства определенного типа</param> /// <param name="nestedType">тип определенного типа</param> /// <returns>объект-свойство</returns> public static PropertyInfo GetProperty(this object obj, string propertyName, Type nestedType) { if (obj == null) { ExceptionGenerator.Run <NullReferenceException>("Аргумент \"obj\" равен null"); } if (String.IsNullOrEmpty(propertyName)) { ExceptionGenerator.Run <ArgumentNullException>("Аргумент \"propertyName\" равен null или пустой метода объекта типа {0}", obj.GetType()); } if (nestedType == null) { ExceptionGenerator.Run <ArgumentNullException>("Аргумент \"nestedType\" равен null (имя свойства вложенного типа \"{0}\")", propertyName); } Type type = obj.GetType(); try { PropertyInfo propertyInfo = type.GetProperty(propertyName, nestedType); return(propertyInfo); } catch (Exception ex) { throw ExceptionGenerator.Run(ex, "Ошибка при получении значения свойства \"{0}\" объекта типа \"{1}\"", propertyName, type); } }
/// <summary> /// Получить поле fieldName у объекта /// </summary> /// <param name="obj">объект</param> /// <param name="fieldName">имя поля</param> /// <param name="bindingFlags">условие поиска поля</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="TargetException"></exception> /// <exception cref="Exception"></exception> /// <returns>значение поля</returns> public static FieldInfo GetField(this object obj, string fieldName, BindingFlags bindingFlags) { if (obj == null) { ExceptionGenerator.Run <NullReferenceException>("Аргумент \"obj\" равен null"); } if (String.IsNullOrEmpty(fieldName)) { ExceptionGenerator.Run <ArgumentNullException>("Аргумент \"fieldName\" равен null или пустой"); } Type type = obj.GetType(); try { FieldInfo fieldInfo = null; fieldInfo = type.GetField(fieldName, bindingFlags); return(fieldInfo); } catch (Exception ex) { throw ExceptionGenerator.Run(ex, "Ошибка при получении поля \"{0}\" объекта типа \"{1}\"", fieldName, type); } }
/// <summary> /// Преобразовывает числовое значение данного экземпляра в эквивалентное ему строковое представление с заданной точностью с отбрасыванием "пустых" нулей в конце числа /// </summary> /// <param name="value">значение</param> /// <param name="minNumberDecimalDigits">минимальное число цифр после запятой</param> /// <param name="numberDecimalDigits">число цифр после запятой</param> /// <returns></returns> public static string ToStr(this double value, int minNumberDecimalDigits, int numberDecimalDigits) { if (minNumberDecimalDigits < 0 || minNumberDecimalDigits > 99 || numberDecimalDigits < 0 || numberDecimalDigits > 99) { ExceptionGenerator.Run <ArgumentOutOfRangeException>("minNumberDecimalDigits \"{0}\", numberDecimalDigits = \"{1}\"", minNumberDecimalDigits, numberDecimalDigits); } if (minNumberDecimalDigits > numberDecimalDigits) { ExceptionGenerator.Run <ArgumentOutOfRangeException>("minNumberDecimalDigits \"{0}\" должно быть не больше, чем numberDecimalDigits = \"{1}\"", minNumberDecimalDigits, numberDecimalDigits); } if (value.IsEqual(Math.Floor(value))) { return(value.ToString(String.Format("F{0}", minNumberDecimalDigits))); } var temp_value = value; for (int i = minNumberDecimalDigits + 1; i < numberDecimalDigits; ++i) { temp_value = 10.0 * temp_value; if (temp_value.IsEqual(Math.Floor(temp_value))) { return(value.ToString(String.Format("F{0}", i))); } } return(value.ToString(String.Format("F{0}", numberDecimalDigits)));; }
/// <summary> /// Verifies that exceptionGenerator throws an exception of one of types in expectedExceptionTypes. /// </summary> /// <param name="expectedExceptionTypes">An array of the expected exception type that exceptionGenerator may throw.</param> /// <param name="exceptionGenerator">A delegate that is expected to throw and exception of /// one of the types in expectedExceptionTypes.</param> /// <returns>true if exceptionGenerator through an exception of one of types in /// expectedExceptionTypes else false.</returns> public bool VerifyException(Type[] expectedExceptionTypes, ExceptionGenerator exceptionGenerator, string message) { bool retValue = true; bool exceptionNotThrown = false; bool exceptionTypeInvalid = true; Type exceptionType = null; Exception exceptionInstance = null; try { exceptionGenerator(); exceptionNotThrown = true; } catch (Exception exception) { exceptionType = exception.GetType(); exceptionInstance = exception; for (int i = 0; i < expectedExceptionTypes.Length; ++i) { if (null != expectedExceptionTypes[i] && exceptionType == expectedExceptionTypes[i]) //null is not a valid exception type { exceptionTypeInvalid = false; } } } if (exceptionNotThrown || exceptionTypeInvalid) { System.Text.StringBuilder exceptionTypeNames = new System.Text.StringBuilder(); for (int i = 0; i < expectedExceptionTypes.Length; ++i) { if (null != expectedExceptionTypes[i]) { exceptionTypeNames.Append(expectedExceptionTypes[i].ToString()); exceptionTypeNames.Append(" "); } } if (exceptionNotThrown) { retValue &= Eval(false, (String.IsNullOrEmpty(message) ? String.Empty : (message + Environment.NewLine)) + "Err_51584ajied Expected exception of one of the following types to be thrown: {0} and nothing was thrown", exceptionTypeNames.ToString()); } else if (exceptionTypeInvalid) { retValue &= Eval(false, (String.IsNullOrEmpty(message) ? String.Empty : (message + Environment.NewLine)) + "Err_51584ajied Expected exception of one of the following types to be thrown: {0} and the following was thrown:\n {1}", exceptionTypeNames.ToString(), exceptionInstance.ToString()); } } return(retValue); }
public virtual async Task DeleteAsync(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var serviceResponse = await _containersApi.DeleteContainerAsync(this.Id); if (false == serviceResponse.IsSuccessStatusCode) { throw ExceptionGenerator.GeneralFailureException(serviceResponse.Content?.ToString()); } }
/// <summary> /// Преобразовывает числовое значение данного экземпляра в эквивалентное ему строковое представление с заданной точностью с отбрасыванием "пустых" нулей в конце числа /// </summary> /// <param name="value">значение</param> /// <param name="numberDecimalDigits">число цифр после запятой</param> /// <returns></returns> public static string ToStr(this double value, int numberDecimalDigits) { if (numberDecimalDigits < 0 || numberDecimalDigits > 99) { ExceptionGenerator.Run <ArgumentOutOfRangeException>("numberDecimalDigits = \"{1}\"", numberDecimalDigits); } return(value.ToStr(0, numberDecimalDigits)); }
public virtual async Task DeleteMetaDataAsync(string key, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var serviceResponse = await _metaDataApi.DeleteMetaDataAsync(this.Id, key); if (false == serviceResponse.IsSuccessStatusCode) { throw ExceptionGenerator.GeneralFailureException(serviceResponse.Content.ToString()); } }
/// <summary> /// Возвращает элемент последовательности по индексу. Если индекс выходит за диапазон последовательности, то выдает исключение /// </summary> /// <typeparam name="TItem">тип элемента</typeparam> /// <param name="originalItems">последовательность</param> /// <param name="index">индекс</param> /// <returns>элемент</returns> public static TItem Get <TItem>(this IEnumerable <TItem> originalItems, int index) { if (index < 0 || index >= originalItems.Count()) { ExceptionGenerator.Run <ArgumentOutOfRangeException>("Индекс \"{0}\" должен быть не меньше \"0\" и меньше \"{1}\"", index, originalItems.Count()); } return(originalItems.ElementAt(index)); }
private static void Check <TIdType>() { Type type = typeof(TIdType); if (type != typeof(string) && (!type.IsPrimitive || !type.IsValueType)) { ExceptionGenerator.Run <InvalidCastException>("Тип идентификатора \"{0}\" должен быть примитивным типом или типом значений или строковым", type); } }
public static void PrintException(Struct ex, string root) { string packageDirectory = Path.Combine(root, JavaConventionHelper.packageConvention(ex.Namespace.Name)); string exceptionDirectory = Path.Combine(packageDirectory, "exceptions"); Directory.CreateDirectory(exceptionDirectory); using (StreamWriter writer = new StreamWriter(Path.Combine(exceptionDirectory, ex.Name + ".java"))) { ExceptionGenerator javaGen = new ExceptionGenerator(); writer.WriteLine(javaGen.Generate(ex)); } }
/// <summary> /// Возвращает первый элемент, если элемент в последовательности найден /// </summary> /// <param name="originalItems">последовательность элементов</param> /// <param name="predicate">условие поиска</param> /// <returns>возвращает первый элемент, если элемент в последовательности найден</returns> public static object First(this IEnumerable originalItems, Func <object, bool> predicate) { foreach (var it in originalItems) { if (predicate(it)) { return(it); } } ExceptionGenerator.Run <InvalidOperationException>("Элемент не найден в последовательности"); return(null); }
public static void VerifyException(Type expectedExceptionType, ExceptionGenerator exceptionGenerator) { try { exceptionGenerator(); Assert.True(false, String.Format("Err_05940iedz Expected exception of the type {0} to be thrown and nothing was thrown", expectedExceptionType)); } catch (Exception exception) { Assert.Equal(expectedExceptionType, exception.GetType()); } }
public virtual async Task <IEnumerable <BlobContainer> > ListContainersAsync() { var containersResponse = await ContainersApiClient.ListContainersAsync(); if (!containersResponse.ResponseMessage.IsSuccessStatusCode) { throw ExceptionGenerator.GeneralFailureException(containersResponse.StringContent); } var conainersDTO = containersResponse.GetContent(); return(conainersDTO.Select(c => new BlobContainer(c.Name, c.Id, this))); }
/// <summary> /// Удалить единственный экземпляр класса. /// </summary> public static void Delete() { Debug.Assert(_instance != null, "_instance != null", "Ожидается, что _instance будет не null"); if (_instance == null) { ExceptionGenerator.Run <DuplicateNameException>("Ожидается, что _instance типа {0} будет null", typeof(T)); } InternalDelete(); }
public static TIdType Get <TIdType>(IBaseIDObject <TIdType> obj) { Check <TIdType>(); Type type = typeof(TIdType); TIdType id = default(TIdType); if (!type.TryConvert <TIdType>(obj.GetHashCode(), ref id)) { ExceptionGenerator.Run <InvalidCastException>("Невозможно преобразовать код хеш-значения в значение тип идентификатора \"{0}\"", type); } return(id); }
public static bool CharOutQuots(this string actualString, int index, ref int nextQuotParaIndex, int startIndex = 0) { if (index < 0 || index > actualString.Length) { ExceptionGenerator.RunArgumentOutOfRangeException(index, 0, actualString.Length); } if (startIndex < 0 || startIndex > actualString.Length) { ExceptionGenerator.RunArgumentOutOfRangeException(startIndex, 0, actualString.Length); } int quotIndex = actualString.IndexOf('\"', startIndex); if (quotIndex == -1) { return(true); } int quotIndexEnd = actualString.IndexOf('\"', quotIndex + 1); if (quotIndex > index) { nextQuotParaIndex = quotIndex; return(true); } while (quotIndexEnd > -1 && quotIndexEnd < index) { quotIndex = actualString.IndexOf('\"', quotIndexEnd + 1); if (quotIndex == -1) { break; } quotIndexEnd = actualString.IndexOf('\"', quotIndex + 1); } if (quotIndex > index) { nextQuotParaIndex = quotIndex; return(true); } if (quotIndexEnd < index) { nextQuotParaIndex = quotIndexEnd + 1; return(true); } if (quotIndexEnd > -1 && quotIndexEnd < index) { nextQuotParaIndex = quotIndexEnd + 1; } return(false); }
/// <summary> /// Получить значение свойства propertyName у объекта /// </summary> /// <param name="obj">объект</param> /// <param name="propertyName">имя свойства</param> /// <param name="bindingFlags">условие поиска свойства</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="Exception"></exception> /// <returns>значение свойства</returns> public static object GetPropertyValue(this object obj, string propertyName, BindingFlags bindingFlags) { Type type = obj.GetType(); PropertyInfo propertyInfo = obj.GetProperty(propertyName, bindingFlags); if (propertyInfo == null) { ExceptionGenerator.Run <NullReferenceException>("Ошибка при получении свойства с именем \"{0}\" объекта типа \"{1}\"", propertyName, type); } return(obj.GetPropertyValue(propertyInfo, AccessAttr.Public)); }
public BusinessUser(IDALActionManager DAL) { DALAccess = DAL; exceptionGenerator = new ExceptionGenerator(); }