예제 #1
0
        public object GetValue(IMapDataSource source, object obj, int index)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            var value = Fields[index].ByName?
                        source.GetValue(obj, Fields[index].Name):
                        source.GetValue(obj, Fields[index].Index);

            if (value == null)
            {
                var objectMapper = source as ObjectMapper;

                if (objectMapper != null)
                {
                    var mm = Fields[index].ByName?
                             objectMapper[Fields[index].Name]: objectMapper[Fields[index].Index];

                    if (mm == null)
                    {
                        throw new MappingException(string.Format(Resources.MapIndex_BadField,
                                                                 objectMapper.TypeAccessor.OriginalType.Name, Fields[index]));
                    }
                }
            }

            return(value);
        }
예제 #2
0
		public object GetValue(IMapDataSource source, object obj, int index)
		{
			if (source == null)
				throw new ArgumentNullException("source");

			var value = Fields[index].ByName?
				source.GetValue(obj, Fields[index].Name):
				source.GetValue(obj, Fields[index].Index);

			if (value == null)
			{
				var objectMapper = source as ObjectMapper;

				if (objectMapper != null)
				{
					var mm = Fields[index].ByName?
						objectMapper[Fields[index].Name]: objectMapper[Fields[index].Index];

					if (mm == null)
						throw new MappingException(string.Format(Resources.MapIndex_BadField,
							objectMapper.TypeAccessor.OriginalType.Name, Fields[index]));
				}
			}

			return value;
		}
예제 #3
0
            public void Map(
                IMapDataSource source, object sourceObject, int sourceIndex,
                IMapDataDestination dest, object destObject, int destIndex)
            {
                dest.SetValue(destObject, destIndex, source.GetValue(sourceObject, sourceIndex));

                //object o = source.GetValue(sourceObject, sourceIndex);

                //if (o == null) dest.SetNull (destObject, destIndex);
                //else           dest.SetValue(destObject, destIndex, o);
            }
예제 #4
0
		public object GetValue(IMapDataSource source, object obj, int index)
		{
			object value = _fields[index].ByName ?
				source.GetValue(obj, _fields[index].Name) : source.GetValue(obj, _fields[index].Index);

			if (value == null)
			{
				ObjectMapper objectMapper = source as ObjectMapper;

				if (objectMapper != null)
				{
					MemberMapper mm = _fields[index].ByName ?
						objectMapper[_fields[index].Name] : objectMapper[_fields[index].Index];

					if (mm == null)
						throw new MappingException(string.Format("Type '{0}' does not contain field '{1}'.",
							objectMapper.TypeAccessor.OriginalType.Name, Fields[index]));
				}
			}

			return value;
		}
예제 #5
0
        public object GetValue(IMapDataSource source, object obj, int index)
        {
            object value = _fields[index].ByName ?
                           source.GetValue(obj, _fields[index].Name) : source.GetValue(obj, _fields[index].Index);

            if (value == null)
            {
                ObjectMapper objectMapper = source as ObjectMapper;

                if (objectMapper != null)
                {
                    MemberMapper mm = _fields[index].ByName ?
                                      objectMapper[_fields[index].Name] : objectMapper[_fields[index].Index];

                    if (mm == null)
                    {
                        throw new MappingException(string.Format("Type '{0}' does not contain field '{1}'.",
                                                                 objectMapper.TypeAccessor.OriginalType.Name, Fields[index]));
                    }
                }
            }

            return(value);
        }
예제 #6
0
			public void Map(
				IMapDataSource source, object sourceObject, int sourceIndex,
				IMapDataDestination dest, object destObject, int destIndex)
			{
				dest.SetValue(destObject, destIndex, source.GetValue(sourceObject, sourceIndex));

				//object o = source.GetValue(sourceObject, sourceIndex);

				//if (o == null) dest.SetNull (destObject, destIndex);
				//else           dest.SetValue(destObject, destIndex, o);
			}
예제 #7
0
 // Default setter.
 //
 public sealed class Default <V> : MB <V>     { public override V           From(IMapDataSource s, object o, int i)
                                                {
                                                    return((V)s.GetValue(o, i));
                                                }