Ejemplo n.º 1
0
 public RepositoryBase(
     IDataReaderAdapter dataReaderAdapter,
     IDataWriterAdapter dataWriterAdapter)
 {
     this.dataReaderAdapter = dataReaderAdapter;
     this.dataWriterAdapter = dataWriterAdapter;
 }
Ejemplo n.º 2
0
        public ObjectBuilderContext(Type resultType, IDataReaderAdapter dataReaderAdapter)
        {
            if (resultType == null)
            {
                throw new ArgumentNullException(nameof(resultType));
            }

            if (dataReaderAdapter == null)
            {
                throw new ArgumentNullException(nameof(dataReaderAdapter));
            }

            ResultType        = resultType;
            DataReaderAdapter = dataReaderAdapter;
        }
        private object CreateDictionaryObject(IDataReaderAdapter dataReaderAdapter)
        {
            var result = new Dictionary <string, object>();

            for (var i = 0; i < dataReaderAdapter.FieldCount; i++)
            {
                var value = dataReaderAdapter[i];
                if (value == DBNull.Value)
                {
                    value = null;
                }

                result[dataReaderAdapter.GetName(i)] = value;
            }

            return(result);
        }
Ejemplo n.º 4
0
        private object CreateDynamicObject(IDataReaderAdapter dataReaderAdapter)
        {
            var result           = new ExpandoObject();
            var dictionaryResult = (IDictionary <string, object>)result;

            for (var i = 0; i < dataReaderAdapter.FieldCount; i++)
            {
                var value = dataReaderAdapter[i];
                if (value == DBNull.Value)
                {
                    value = null;
                }

                dictionaryResult[dataReaderAdapter.GetName(i)] = value;
            }

            return(result);
        }
        private object CreateSingleInstance(IDataReaderAdapter dataReaderAdapter, Type instanceType)
        {
            var instance       = Activator.CreateInstance(instanceType);
            var typeProperties = instanceType.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            for (var i = 0; i < dataReaderAdapter.FieldCount; i++)
            {
                var columnName = dataReaderAdapter.GetName(i);
                var property   = GetPropertyInfo(typeProperties, columnName);

                if (property != null)
                {
                    var value          = dataReaderAdapter.GetValue(i);
                    var convertedValue = _objectConverter.ChangeType(property.PropertyType, value);
                    property.SetValue(instance, convertedValue, null);
                }
            }

            return(instance);
        }
Ejemplo n.º 6
0
            public bool AddTable(Guid organizationId, int departmentId, string tableName, ref ImportLog importLog, ref ImportCustomProperty importCustomProperty, IDataReaderAdapter tableReader)
            {
                bool result = false;

                if (_tables != null)
                {
                    if (!_tables.Contains(tableName))
                    {
                        ImportTable _table = new ImportTable(tableName, organizationId, departmentId, ref importLog, ref importCustomProperty, tableReader);
                        if (_table != null)
                        {
                            _tables.Add(tableName, _table);
                            result = true;
                        }
                    }
                }

                return result;
            }
Ejemplo n.º 7
0
            public ImportTable(string sheet_name, Guid organizationId,  int departmentId, ref ImportLog import_log, ref ImportCustomProperty import_custom_property, IDataReaderAdapter dataReaderAdapter)
            {
                _organizationId = organizationId;
                _departmentId = departmentId;

                _require_column_list = new ImportColumns();
                _require_column_list_all = new ImportColumns();
                _available_column_list = new ImportColumns();
                _custom_column_list = new ImportColumns();

                _reader = dataReaderAdapter;
                _log = import_log;

                _import_custom_property = import_custom_property;

                _sheet_name = sheet_name;

                _table = new DataTable();
            }