public AbstractObject(InitContext init)
			{
				if (init.MemberParameters != null && init.MemberParameters.Length == 1)
					Field = (int)init.MemberParameters[0];
				else
					Field = 77;
			}
			public void BeginMapping(InitContext initContext)
			{
				Int22 = (int)initContext.Parameters[1];

				if (Int22 == 66)
					initContext.StopMapping = true;
			}
			public InnerObject(InitContext init)
			{
				if (init.MemberParameters != null && init.MemberParameters.Length == 1)
					Field = (int)init.MemberParameters[0];
				else
					Field = 44;
			}
			public Object1(InitContext initContext)
			{
				if (initContext != null)
					Int11 = (int)initContext.Parameters[0];

				if (Int11 == 77)
					initContext.StopMapping = true;
			}
		object IMapDataDestinationList.GetNextObject(InitContext initContext)
		{
			DataRow row = _table.NewRow();

			_mapper.DataRow = row;
			_table.Rows.Add(row);

			return row;
		}
		public virtual void EndMapping(InitContext initContext)
		{
			AddObject();

			ISupportMapping sm = _dic as ISupportMapping;

			if (sm != null)
				sm.EndMapping(initContext);
		}
				public object CreateInstance(TypeAccessor typeAccessor, InitContext context)
				{
					int id = context.DataSource.GetInt32(context.SourceObject,
						context.DataSource.GetOrdinal("PersonId"));
					
					context.ObjectMapper = context.MappingSchema.GetObjectMapper(Factory.GetType(id));

					return context.ObjectMapper.TypeAccessor.CreateInstance(context);
				}
			public SimpleObject(InitContext context)
			{
				if (context.Parameters != null)
				{
					Assert.AreEqual(2, context.Parameters.Length);
					Assert.AreEqual("123", context.Parameters[0]);
					Assert.AreEqual("456", context.Parameters[1]);
				}
			}
		void IMapDataDestinationList.EndMapping(InitContext initContext)
		{
			AddCurrent();

			ISupportMapping sm = _list as ISupportMapping;

			if (sm != null)
				sm.EndMapping(initContext);
		}
		bool IMapDataSourceList.SetNextDataSource(InitContext initContext)
		{
			if (_currentItem >= _list.Count)
				return false;

			initContext.SourceObject = _list[_currentItem];
			_currentItem++;

			return true;
		}
		public virtual void InitMapping(InitContext initContext)
		{
			var sm = _dic as ISupportMapping;

			if (sm != null)
			{
				sm.BeginMapping(initContext);

				if (_mapper != initContext.ObjectMapper)
					_mapper = initContext.ObjectMapper;
			}
		}
		void IMapDataDestinationList.InitMapping(InitContext initContext)
		{
			ISupportMapping sm = _list as ISupportMapping;

			if (sm != null)
			{
				sm.BeginMapping(initContext);

				if (initContext.ObjectMapper != null && _mapper != initContext.ObjectMapper)
					_mapper = initContext.ObjectMapper;
			}
		}
		public void Test2()
		{
			TestObject2 o = (TestObject2)TypeAccessor.CreateInstance(typeof(TestObject2));
			Assert.AreEqual(10, o.Value);

			o = (TestObject2)TypeAccessor.CreateInstance(typeof(TestObject2), null);
			Assert.AreEqual(10, o.Value);

			InitContext ic = new InitContext();
			ic.Parameters = new object[] { 30 };
			o = (TestObject2)TypeAccessor.CreateInstance(typeof(TestObject2), ic);
			Assert.AreEqual(10, o.Value);
		}
		public virtual object GetNextObject(InitContext initContext)
		{
			AddObject();

			_indexValue = new object[_fields.Length];

			if (_isFromSource)
				for (int i = 0; i < _fields.Length; i++)
					if (_fromSource[i])
						_indexValue[i] = _fields[i].ByName ?
							initContext.DataSource.GetValue( initContext.SourceObject, _fields[i].Name) :
							initContext.DataSource.GetValue( initContext.SourceObject, _fields[i].Index);

			return _newObject = _mapper.CreateInstance(initContext);
		}
		bool IMapDataSourceList.SetNextDataSource(InitContext initContext)
		{
			if (_currentRow >= _table.Rows.Count)
				return false;

			DataRow row = _table.Rows[_currentRow++];

			if (row.RowState == DataRowState.Deleted)
				return ((IMapDataSourceList)this).SetNextDataSource(initContext);

			_mapper.DataRow          = row;
			initContext.SourceObject = row;

			return true;
		}
		public virtual object GetNextObject(InitContext initContext)
		{
			AddObject();

			if (_fromSource)
			{
				_keyValue = _keyField.ByName ? 
					initContext.DataSource.GetValue(initContext.SourceObject, _keyField.Name) :
					initContext.DataSource.GetValue(initContext.SourceObject, _keyField.Index);

				if (Common.Configuration.TrimDictionaryKey && _keyValue is string)
					_keyValue = _keyValue.ToString().TrimEnd(_trim);
			}

			return _newObject = _mapper.CreateInstance(initContext);
		}
		public virtual bool SetNextDataSource(InitContext initContext)
		{
			if (initContext == null) throw new ArgumentNullException("initContext");

			if (_enumerator.MoveNext() == false)
				return false;

			object sourceObject = _enumerator.Current;

			if (_objectType != sourceObject.GetType())
			{
				_objectType = sourceObject.GetType();
				initContext.DataSource = initContext.MappingSchema.GetObjectMapper(_objectType);
			}

			initContext.SourceObject = sourceObject;

			return true;
		}
				public object /*[a]*/CreateInstance(TypeAccessor typeAccessor, InitContext context)/*[/a]*/
				{
					// Get the object type indicator field.
					//
					object objectType = context.DataSource.GetValue(context.SourceObject, "PersonType");

					// Target ObjectMapper must be changed in order to provide correct mapping.
					//
					switch ((string)objectType)
					{
						case "D": /*[a]*/context.ObjectMapper = ObjectMapper<Doctor>. Instance;/*[/a]*/ break;
						case "P": /*[a]*/context.ObjectMapper = ObjectMapper<Patient>.Instance;/*[/a]*/ break;
					}

					// Create an object instance.
					// Do not call ObjectMapper.CreateInstance as it will lead to infinite recursion.
					//
					return context.ObjectMapper./*[a]*/TypeAccessor/*[/a]*/.CreateInstance(context);
				}
				public object CreateInstance(TypeAccessor typeAccessor, InitContext context)
				{
					Type t = typeAccessor.Type;

					ConstructorInfo[] ctis = t.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					ConstructorInfo   constructor = ctis[0];

					foreach (ConstructorInfo ci in ctis)
					{
						if (constructor.GetParameters().Length < ci.GetParameters().Length)
							constructor = ci;
					}
					
					ParameterInfo[] pis   = constructor.GetParameters();
					object[]        param = new object[pis.Length];

					for(int i = 0; i < pis.Length; i++)
					{
						ParameterInfo pi      = pis[i];
						Type          pType   = pi.ParameterType;
						string        pName   = pi.Name;
						int           ordinal = context.DataSource.GetOrdinal(pName);

						if (ordinal >= 0)
						{
							param[i] = context.MappingSchema.ConvertChangeType(
								context.DataSource.GetValue(context.SourceObject, ordinal),
								pType);
						}
						else
							param[i] = context.MappingSchema.GetDefaultValue(pType);
					}

					context.StopMapping = true;

					return constructor.Invoke(param);

				}
			public void BeginMapping(InitContext initContext)
			{
				Int22 = (int)initContext.Parameters[1];
			}
Exemple #21
0
 public static object CreateInstanceEx(Type type, InitContext context)
 {
     return(GetAccessor(type).CreateInstance(context));
 }
 public override object CreateInstance(InitContext context)
 {
     return CreateInstance();
 }
		public virtual void EndMapping(InitContext initContext)
		{
		}
Exemple #24
0
 public object CreateInstanceEx(InitContext context)
 {
     return(_objectFactory != null?_objectFactory.CreateInstance(this, context) : CreateInstance(context));
 }
		public virtual void InitMapping(InitContext initContext)
		{
			_enumerator.Reset();
		}
Exemple #26
0
 public override object CreateInstance(InitContext context)
 {
     return(_createInstanceInit(context));
 }
			public Object5(InitContext initContext)
			{
				Int11 = (int)initContext.Parameters[0];
			}
			public TestObject3(InitContext init)
			{
				Value = init == null || init.Parameters == null ? 20 : (int)init.Parameters[0];
			}
		public virtual bool SetNextDataSource(InitContext initContext)
		{
			return _mapper.DataReader.Read();
		}
		public virtual void InitMapping(InitContext initContext)
		{
			initContext.DataSource   = _mapper;
			initContext.SourceObject = _mapper.DataReader;
		}
			public void EndMapping(InitContext initContext)
			{
				Int44 = (int)initContext.Parameters[2];
			}
Exemple #32
0
 public static T CreateInstanceEx <T>(InitContext context)
 {
     return(TypeAccessor <T> .CreateInstance(context));
 }
Exemple #33
0
				public object CreateInstance(TypeAccessor typeAccessor, InitContext context)
				{
					if (context == null)
						throw new Exception("InitContext is null while mapping from DataReader!");

					return typeAccessor.CreateInstance();
				}
Exemple #34
0
 public virtual object CreateInstance(InitContext context)
 {
     return(CreateInstance());
 }
			protected TestObject4(InitContext init)
			{
				Value = init == null || init.Parameters == null ? 20 : (int)init.Parameters[0];
			}
Exemple #36
0
 public static T CreateInstanceEx(InitContext context)
 {
     return((T)_instance.CreateInstanceEx(context));
 }