private void ValidateProperty(PropertyInfo propertyInfo) { RaiseException.WhenFalse(propertyInfo.CanWrite, "Property {0}.{1} must have setter defined!", propertyInfo.DeclaringType.FullName, propertyInfo.Name); }
public DataRowReader(string path) { RaiseException.WhenTrue(path == null, "Trying create FileSystemRecordReader with null path"); RaiseException.WhenTrue(path.Length == 0, "Trying create FileSystemRecordReader with empty path"); this.path = path; }
public string Save(Anuidade a) { ArgumentsValidator.RaiseExceptionOfInvalidArguments( RaiseException.IfTrue(a.Exercicio == 0, "Exercício não informado") ); Anuidade _a = new Anuidade { AnuidadeId = a.AnuidadeId, Exercicio = a.Exercicio, DtVencimento = a.DtVencimento, DtInicioVigencia = a.DtInicioVigencia, DtTerminoVigencia = a.DtTerminoVigencia, CobrancaLiberada = a.CobrancaLiberada, DtCobrancaLiberada = a.DtCobrancaLiberada, DtCadastro = a.DtCadastro, Ativo = a.Ativo }; try { if (_a.AnuidadeId == 0) { return(_anuidadeService.Insert(_a)); } else { return(_anuidadeService.Update(a.AnuidadeId, _a)); } } catch (Exception ex) { throw ex; } }
public DataRow(string[] fragments) { RaiseException.WhenTrue(fragments == null, "fragments must not be null!"); RaiseException.WhenTrue(fragments.Length == 0, "fragments must not be empty!"); this.fragments = fragments; }
public TypeBlueprint(Type t) { RaiseException.WhenTrue(null == t, "t cannot be null!"); _type = t; _elements = new List <ITypeElement>(); }
public QueryBuilder Select(string fieldName) { RaiseException.WhenTrue(fieldName == null, "fieldName cannot be null!"); RaiseException.WhenTrue(fieldName.Length == 0, "fieldName cannot be empty!"); filters.Add(new FieldFilter(fieldName)); return(this); }
public static string GetConnectionString() { var connectionString = ConfigurationManager.ConnectionStrings["Log_ConnectionString"]?.ConnectionString; RaiseException.IfNullOrEmpty(connectionString, "Chave 'Log_ConnectionString' não definida no CONNECTIONSTRINGS. Verifique seu WebConfig ou AppConfig.", true); return(connectionString); }
public string RessetPasswordByEMail(string email) { ArgumentsValidator.RaiseExceptionOfInvalidArguments( RaiseException.IfNotEmail(email, "Atenção: E-Mail inválido") ); return(_userProfileService.RessetPasswordByEMail(email)); }
public static string GetConnectionString(string key) { var connectionString = ConfigurationManager.ConnectionStrings[key]?.ConnectionString; RaiseException.IfNullOrEmpty(connectionString, $"Chave {key} Não definida no ConnectionStrings. Verifique seu WebConfig ou AppSettings", true); return(connectionString); }
public static string GetKeyAppSettings(string key) { var value = ConfigurationManager.AppSettings[key]; RaiseException.IfNullOrEmpty(value, $"Chave '{key}' não definida no APPSETTINGS. Verifique seu WebConfig ou AppConfig.", true); return(value); }
public HeaderAlias(string name, string alias) { RaiseException.WhenTrue(name == null, "name must not be null!"); RaiseException.WhenTrue(alias == null, "alias must not be null!"); this.name = name; this.alias = alias; }
public QueryBuilder From(string path) { RaiseException.WhenTrue(path == null, "path cannot be null!"); RaiseException.WhenTrue(path.Length == 0, "path cannot be empty!"); fromPath = path; return(this); }
public DataRowFilterReader(IDataRowReader underlyingReader, string[] headerFilter) { RaiseException.WhenTrue(underlyingReader == null, "underlyingReader must not be null!"); RaiseException.WhenTrue(headerFilter == null, "headerFilter must not be null!"); RaiseException.WhenTrue(headerFilter.Length == 0, "headerFilter must not be empty!"); this.underlyingReader = underlyingReader; this.headerFilter = headerFilter; }
public UserProfile LoginUser(UserProfileLogin userProfileLogin) { ArgumentsValidator.RaiseExceptionOfInvalidArguments( RaiseException.IfNotEmail(userProfileLogin.EMail, "Atenção: E-Mail inválido"), RaiseException.IfNullOrEmpty(userProfileLogin.PasswordHash, "Atenção: Senha inválida") ); return(_userProfileService.LoginUser(userProfileLogin)); }
public UserProfile Login(string email, string password) { ArgumentsValidator.RaiseExceptionOfInvalidArguments( RaiseException.IfNotEmail(email, "Atenção: E-Mail inválido"), RaiseException.IfNullOrEmpty(password, "Atenção: Senha inválida") ); return(_userProfileService.Login(email, password)); }
public DataRowFilter(IDataRow underlyingRecord, int[] activeIndices) { RaiseException.WhenTrue(underlyingRecord == null, "underlyingRecord must not be null!"); RaiseException.WhenTrue(activeIndices == null, "activeIndices must not be null!"); RaiseException.WhenTrue(activeIndices.Length == 0, "activeIndices must not be empty!"); this.underlyingRecord = underlyingRecord; this.activeIndices = activeIndices; }
public HeaderAliasDataRowReader(IDataRowReader underlyingReader, HeaderAlias[] aliases) { RaiseException.WhenTrue(underlyingReader == null, "underlyingReader must not be null!"); RaiseException.WhenTrue(aliases == null, "aliases must not be null!"); RaiseException.WhenTrue(aliases.Length == 0, "aliases must not be empty!"); this.underlyingReader = underlyingReader; this.aliases = aliases; }
public void ObterListaDeMensagensDasExcecoes() { List <string> result = ArgumentsValidator.GetMessagesFromExceptions( RaiseException.IfNull(null, "object is required"), RaiseException.IfNotEmail("email_invalid", "email invalid") ); Assert.IsNotNull(result, "object required"); Assert.IsTrue(result.Count == 2, "There should be two exceptions"); }
public void Open() { RaiseException.WhenTrue(IsActive(), "Trying to open stream that is opened already! Path: {0}", path); streamReader = new StreamReader(path); csvReader = new CSVReader(streamReader, CSVFile.CSV.DEFAULT_DELIMITER, CSVFile.CSV.DEFAULT_QUALIFIER, true); headers = csvReader.Headers; nextLine = csvReader.NextLine(); }
public void ObterListaDeExecoesSemLancar() { List <Exception> result = ArgumentsValidator.GetExceptionList( RaiseException.IfNull(null, "object is required"), RaiseException.IfNotEmail("email_invalid", "email invalid") ); Assert.IsNotNull(result, "object required"); Assert.IsTrue(result.Count == 2, "There should be two exceptions"); }
public void InjectTo(object o) { ITypeBlueprint blueprint = DIBlueprintRepository.Get(o.GetType()); ITypeElement typeElement = FindElementByType(blueprint, targetValue.GetType()); RaiseException.WhenTrue(typeElement == null, "Blueprint '{0}' has no AutoInject field/property assignable from '{1}'!", blueprint.Type, targetValue.GetType()); typeElement.SetValue(o, targetValue); }
public QueryBuilder SelectAs(string fieldName, string fieldNameAlias) { RaiseException.WhenTrue(fieldName == null, "fieldName cannot be null!"); RaiseException.WhenTrue(fieldName.Length == 0, "fieldName cannot be empty!"); RaiseException.WhenTrue(fieldNameAlias == null, "fieldNameAlias cannot be null!"); RaiseException.WhenTrue(fieldNameAlias.Length == 0, "fieldNameAlias cannot be empty!"); aliases.Add(new FieldAlias(fieldName, fieldNameAlias)); return(this); }
public IDataRow ReadNext() { RaiseException.WhenTrue(nextLine == null, "Trying to read past end of stream! Path: {0}", path); IDataRow current = new DataRow(nextLine); nextLine = csvReader.NextLine(); return(current); }
public void LancarExcecaoIndividual() { try { RaiseException.IfNotNull(null, "object is required", true); } catch (Exception ex) { Assert.AreEqual(ex.Message, "object is required", "is expected value not null"); } }
public void InjectTo(object o) { ITypeBlueprint blueprint = DIBlueprintRepository.Get(o.GetType()); ITypeElement typeElement = FindElementByName(blueprint); RaiseException.WhenTrue(typeElement == null, "Blueprint '{0}' has no AutoInject field/property with name '{1}'!", blueprint.Type, name); RaiseException.WhenFalse(targetValue == null || typeElement.ElementType.IsAssignableFrom(targetValue.GetType()), "Element '{0}' in blueprint '{1}' is not assignable from {2}", name, blueprint.Type, targetValue.GetType()); typeElement.SetValue(o, targetValue); }
public ITypeElement this[string name] { get { ITypeElement element = FindByName(name); RaiseException.WhenTrue(null == element, "Field {0} cannot be found in type {1}!", name, _type.FullName); return(element); } }
public void Close() { RaiseException.WhenFalse(IsActive(), "Trying to close stream that is closed already! Path: {0}", path); streamReader.Dispose(); streamReader = null; csvReader = null; headers = null; nextLine = null; }
public string Save(Isencao i) { ArgumentsValidator.RaiseExceptionOfInvalidArguments( RaiseException.IfNullOrEmpty(i.Descricao, "Descrição não informada"), RaiseException.IfTrue(i.DtAta == DateTime.MinValue, "Data não informada"), RaiseException.IfNull(i.DtAta, "Data não informada - Nula"), RaiseException.IfTrue(i.AnoEvento == 0, "Ano da Isencão não informada") ); if (i.TipoIsencao.Equals("1")) { ArgumentsValidator.RaiseExceptionOfInvalidArguments( RaiseException.IfTrue(i.EventoId == 0, "Evento não informado"), RaiseException.IfNull(i.EventoId, "Evento não informado") ); } if (i.TipoIsencao.Equals("2")) { ArgumentsValidator.RaiseExceptionOfInvalidArguments( RaiseException.IfTrue(i.AnuidadeId == 0, "Anuidade não informada"), RaiseException.IfNull(i.AnuidadeId, "Anuidade não informada") ); } Isencao _i = new Isencao { IsencaoId = i.IsencaoId, AnuidadeId = i.AnuidadeId, EventoId = i.EventoId, Descricao = i.Descricao, DtAta = i.DtAta, AnoEvento = i.AnoEvento, TipoIsencao = i.TipoIsencao, Ativo = i.Ativo }; try { if (_i.IsencaoId == 0) { return(_isencaoService.Insert(_i)); } else { return(_isencaoService.Update(i.IsencaoId, _i)); } } catch (Exception ex) { throw ex; } }
private static int[] RemaActiveIndices(string[] headers, string[] headerFilter) { int[] indices = new int[headerFilter.Length]; for (int i = 0; i < headerFilter.Length; ++i) { indices[i] = headers.IndexOf(headerFilter[i]); RaiseException.WhenTrue(indices[i] == -1, "Cannot find index for '{0}' header!", headerFilter[i]); } return(indices); }
public void LancarUnicaExcecaoComMensagensDoGrupoDeExcecoes() { try { ArgumentsValidator.RaiseExceptionOfInvalidArguments( RaiseException.IfNull(null, "object is required"), RaiseException.IfNotEmail("email_invalid", "email invalid") ); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains("object is required") && ex.Message.Contains("email invalid"), "There should be two exceptions"); } }