Ejemplo n.º 1
0
        public static object Evaluate(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord, string defaultValue)
        {
            if (sourceRecord == null)
            {
                throw new ArgumentNullException("sourceRecord");
            }

            var sourceFieldValue = GetTranslatedFieldValue(sourceFieldName, sourceFieldTranslation, sourceRecord);

            if (sourceFieldValue == null || sourceFieldValue == DBNull.Value)
            {
                return(defaultValue);
            }
            else
            {
                return(sourceFieldValue);
            }
        }
Ejemplo n.º 2
0
        private static object GetTranslatedFieldValue(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord)
        {
            if (string.IsNullOrEmpty(sourceFieldName))
            {
                return(null);
            }

            var sourceFieldValue = sourceRecord[sourceFieldName];
            var translatedValue  = sourceFieldValue;

            if (sourceFieldTranslation != null)
            {
                try
                {
                    foreach (var func in sourceFieldTranslation.Functions)
                    {
                        translatedValue = func.Evaluate(translatedValue, sourceRecord);
                    }
                    return(translatedValue);
                }
                catch (Exception exc)
                {
                    throw new InvalidOperationException
                          (
                              string.Format
                              (
                                  Properties.Resources.ValueTranslationError,
                                  sourceFieldName,
                                  sourceFieldValue
                              ),
                              exc
                          );
                }
            }
            return(translatedValue);
        }
Ejemplo n.º 3
0
 public static object Evaluate(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord)
 {
     return(Evaluate(sourceFieldName, sourceFieldTranslation, sourceRecord, null));
 }