public static SettingName GetSettingName([NotNull] this LambdaExpression lambdaExpression, [CanBeNull] string instance = null) { var smartSettingAttribute = lambdaExpression.GetCustomAttribute <SmartSettingAttribute>(); var hasCustomName = !string.IsNullOrEmpty(smartSettingAttribute?.Name); if (hasCustomName) { return(new SettingName(smartSettingAttribute.Name)); } var classType = ClassTypeFinder.FindClassType(lambdaExpression, true) ?? throw ("UnsupportedSettingExpressionException", "Member's declaring type could not be determined.").ToDynamicException();; return(new SettingName(lambdaExpression.MemberExpression().Member.Name) { Namespace = classType.Namespace, Type = classType.Name, Instance = instance }); }