Exemplo n.º 1
0
		public MapRelationBase(
			Type         slave,
			MapIndex     slaveIndex,
			MapIndex     masterIndex,
			string       containerName)
		{
			if (slave == null)
				throw new ArgumentNullException("slave");

			if (masterIndex.Fields.Length == 0)
				throw new MappingException("Master index length can not be 0.");

			if ( slaveIndex.Fields.Length == 0)
				throw new MappingException("Slave index length can not be 0.");

			if (masterIndex.Fields.Length != slaveIndex.Fields.Length)
				throw new MappingException("Master and slave indexes do not match.");

			if (string.IsNullOrEmpty(containerName))
				throw new MappingException("Master container field name is wrong.");
			
			_slave           = slave;
			_masterIndex     = masterIndex;
			_slaveIndex      = slaveIndex;
			_containerName   = containerName;
		}
Exemplo n.º 2
0
 public static Dictionary <CompoundValue, T> DictionaryToDictionary <T>(
     IDictionary sourceDictionary,
     MapIndex index,
     params object[] parameters)
 {
     return(_defaultSchema.MapDictionaryToDictionary <T>(sourceDictionary, index, parameters));
 }
Exemplo n.º 3
0
 public static Dictionary <CompoundValue, T> DataTableToDictionary <T>(
     DataTable sourceTable,
     MapIndex index,
     params object[] parameters)
 {
     return(_defaultSchema.MapDataTableToDictionary <T>(sourceTable, index, parameters));
 }
Exemplo n.º 4
0
 public static Dictionary <CompoundValue, T> DataReaderToDictionary <T>(
     IDataReader dataReader,
     MapIndex index,
     params object[] parameters)
 {
     return(_defaultSchema.MapDataReaderToDictionary <T>(dataReader, index, parameters));
 }
Exemplo n.º 5
0
 public static Dictionary <CompoundValue, T> ListToDictionary <T>(
     ICollection sourceList,
     MapIndex index,
     params object[] parameters)
 {
     return(_defaultSchema.MapListToDictionary <T>(sourceList, index, parameters));
 }
Exemplo n.º 6
0
 public static IDictionary DictionaryToDictionary(
     IDictionary sourceDictionary,
     MapIndex index,
     Type destObjectType,
     params object[] parameters)
 {
     return(_defaultSchema.MapDictionaryToDictionary(sourceDictionary, index, destObjectType, parameters));
 }
Exemplo n.º 7
0
 public static IDictionary DataReaderToDictionary(
     IDataReader dataReader,
     MapIndex index,
     Type destObjectType,
     params object[] parameters)
 {
     return(_defaultSchema.MapDataReaderToDictionary(dataReader, index, destObjectType, parameters));
 }
Exemplo n.º 8
0
 public static IDictionary ListToDictionary(
     ICollection sourceList,
     MapIndex index,
     Type destObjectType,
     params object[] parameters)
 {
     return(_defaultSchema.MapListToDictionary(sourceList, index, destObjectType, parameters));
 }
Exemplo n.º 9
0
 public static Hashtable DataTableToDictionary(
     DataTable sourceTable,
     MapIndex index,
     Type destObjectType,
     params object[] parameters)
 {
     return(_defaultSchema.MapDataTableToDictionary(sourceTable, index, destObjectType, parameters));
 }
Exemplo n.º 10
0
 public MapRelation(
     MapResultSet slaveResultSet,
     MapIndex slaveIndex,
     MapIndex masterIndex,
     string containerName)
     : base(slaveResultSet.ObjectType, slaveIndex, masterIndex, containerName)
 {
     _slaveResultSet = slaveResultSet;
 }
Exemplo n.º 11
0
		public MapRelation(
			MapResultSet slaveResultSet,
			MapIndex     slaveIndex,
			MapIndex     masterIndex,
			string       containerName)
			: base(slaveResultSet.ObjectType, slaveIndex, masterIndex, containerName)
		{
			_slaveResultSet  = slaveResultSet;
		}
Exemplo n.º 12
0
		public void AddRelation(
			MapResultSet slaveResultSet,
			MapIndex     slaveIndex,
			MapIndex     masterIndex,
			string       containerName)
		{
			if (_relationList == null)
				_relationList = new List<MapRelation>();

			_relationList.Add(new MapRelation(slaveResultSet, slaveIndex, masterIndex, containerName));
		}
Exemplo n.º 13
0
 public MapNextResult(
     Type type,
     MapIndex slaveIndex,
     MapIndex masterIndex,
     string containerName,
     params MapNextResult[] nextResults)
 {
     _objectType    = type;
     _slaveIndex    = slaveIndex;
     _masterIndex   = masterIndex;
     _containerName = containerName;
     _nextResults   = nextResults;
 }
Exemplo n.º 14
0
        public void AddRelation(
            MapResultSet slaveResultSet,
            MapIndex slaveIndex,
            MapIndex masterIndex,
            string containerName)
        {
            if (_relationList == null)
            {
                _relationList = new List <MapRelation>();
            }

            _relationList.Add(new MapRelation(slaveResultSet, slaveIndex, masterIndex, containerName));
        }
Exemplo n.º 15
0
		public MapNextResult(
			Type     type,
			MapIndex slaveIndex,
			MapIndex masterIndex,
			string   containerName,
			params MapNextResult[] nextResults)
		{
			_objectType    = type;
			_slaveIndex    = slaveIndex;
			_masterIndex   = masterIndex;
			_containerName = containerName;
			_nextResults   = nextResults;
		}
		public DictionaryIndexListMapper(
			IDictionary  dic,
			MapIndex     index,
			ObjectMapper objectMapper)
		{
			_dic    = dic;
			_mapper = objectMapper;

			_fields = new NameOrIndexParameter[index.Fields.Length];
			_fromSource = new bool[index.Fields.Length];

			for (int i = 0; i < _fields.Length; i++)
			{
				bool fromSource = index.Fields[i].ByName && index.Fields[i].Name[0] == '@';

				_fields[i]     = fromSource? index.Fields[i].Name.Substring(1): index.Fields[i];
				_fromSource[i] = fromSource;
				_isFromSource  = _isFromSource ||  fromSource;
				_isFromDest    = _isFromDest   || !fromSource;
			}
		}
Exemplo n.º 17
0
        public DictionaryIndexListMapper(
            IDictionary dic,
            MapIndex index,
            ObjectMapper objectMapper)
        {
            _dic    = dic;
            _mapper = objectMapper;

            _fields     = new NameOrIndexParameter[index.Fields.Length];
            _fromSource = new bool[index.Fields.Length];

            for (int i = 0; i < _fields.Length; i++)
            {
                bool fromSource = index.Fields[i].ByName && index.Fields[i].Name[0] == '@';

                _fields[i]     = fromSource? index.Fields[i].Name.Substring(1): index.Fields[i];
                _fromSource[i] = fromSource;
                _isFromSource  = _isFromSource || fromSource;
                _isFromDest    = _isFromDest || !fromSource;
            }
        }
Exemplo n.º 18
0
        public MapRelationBase(
            Type slave,
            MapIndex slaveIndex,
            MapIndex masterIndex,
            string containerName)
        {
            if (slave == null)
            {
                throw new ArgumentNullException("slave");
            }

            if (masterIndex.Fields.Length == 0)
            {
                throw new MappingException("Master index length can not be 0.");
            }

            if (slaveIndex.Fields.Length == 0)
            {
                throw new MappingException("Slave index length can not be 0.");
            }

            if (masterIndex.Fields.Length != slaveIndex.Fields.Length)
            {
                throw new MappingException("Master and slave indexes do not match.");
            }

            if (string.IsNullOrEmpty(containerName))
            {
                throw new MappingException("Master container field name is wrong.");
            }

            _slave         = slave;
            _masterIndex   = masterIndex;
            _slaveIndex    = slaveIndex;
            _containerName = containerName;
        }
Exemplo n.º 19
0
        public Hashtable GetIndex(MappingSchema ms, MapIndex masterIndex)
        {
            string    indexId   = masterIndex.ID;
            Hashtable indexHash = null;

            if (_indexies.TryGetValue(indexId, out indexHash))
            {
                return(indexHash);
            }

            ObjectMapper    masterMapper = ms.GetObjectMapper(ObjectType);
            List <MapIndex> createIndex  = new List <MapIndex>();

            indexHash = new Hashtable();

            foreach (object o in List)
            {
                object key = masterIndex.GetValueOrIndex(masterMapper, o);

                if (ms.IsNull(key))
                {
                    continue;
                }

                ArrayList matches = (ArrayList)indexHash[key];

                if (matches == null)
                {
                    indexHash[key] = matches = new ArrayList();
                }

                matches.Add(o);
            }

            return(indexHash);
        }
Exemplo n.º 20
0
        public IDictionary <object, IList> GetIndex(MappingSchema ms, MapIndex masterIndex)
        {
            var indexId = masterIndex.ID;

            IDictionary <object, IList> indexHash;

            if (_indexies.TryGetValue(indexId, out indexHash))
            {
                return(indexHash);
            }

            var masterMapper = ms.GetObjectMapper(ObjectType);

            indexHash = new Dictionary <object, IList>();

            foreach (var o in List)
            {
                var key = masterIndex.GetValueOrIndex(masterMapper, o);

                if (ms.IsNull(key))
                {
                    continue;
                }

                IList matches;

                if (!indexHash.TryGetValue(key, out matches))
                {
                    indexHash.Add(key, matches = new List <object>());
                }

                matches.Add(o);
            }

            return(indexHash);
        }
Exemplo n.º 21
0
		public  IDictionary<object,IList> GetIndex(MappingSchema ms, MapIndex masterIndex)
		{
			var indexId = masterIndex.ID;

			IDictionary<object,IList> indexHash;

			if (_indexies.TryGetValue(indexId, out indexHash))
				return indexHash;

			var masterMapper = ms.GetObjectMapper(ObjectType);

			indexHash = new Dictionary<object, IList>();

			foreach (var o in List)
			{
				var key = masterIndex.GetValueOrIndex(masterMapper, o);

				if (ms.IsNull(key))
					continue;

				IList matches;

				if (!indexHash.TryGetValue(key, out matches))
					indexHash.Add(key, matches = new List<object>());

				matches.Add(o);
			}

			return indexHash;
		}