Example #1
0
		public void SetSingleValue(object value, IDataHolder holder)
		{
			for (var i = 0; i < FieldList.Count; i++)
			{
				var dataField = FieldList[i];
				// set value
				dataField.Set(holder, value);
			}
		}
Example #2
0
 public InputDataInTables(IDataHolder dataHolder)
 {
     InitializeComponent();
     var varNamelst = new List<string>();
     for (int i = 0; i < dataHolder.AllVariables.Length; i++)
     {
         varNamelst.Add("Переменная " + (i + 1));
     }
     gridViewVariables.DataSource = dataHolder.AllVariables.GetDataTableFromMatrix(varNamelst.ToArray());
     var funcNamelst = new List<string>();
     for (int i = 0; i < dataHolder.Y.Length; i++)
     {
         funcNamelst.Add("Функция " + (i + 1));
     }
     gridViewFunctions.DataSource =
         dataHolder.Y.GetDataTableFromMatrix(funcNamelst.ToArray());
 }
Example #3
0
		void Write(BinaryWriter writer, IDataHolder holder)
		{
			for (var i = 0; i < m_persistors.Length; i++)
			{
				var persistor = m_persistors[i];
				try
				{
					var val = m_fields[i].Accessor.Get(holder);
					persistor.Write(writer, val);
				}
				catch (Exception e)
				{
					throw new DataHolderException(e, "Failed to write DataHolder \"{0}\" (Persistor #{1} {2} for: {3}).",
						holder, i, persistor, m_fields[i]);
				}
			}
		}
Example #4
0
 public void Set(IDataHolder obj, object value)
 {
     //throw new DataHolderException("Proxy field is not settable.");
 }
Example #5
0
 public object Get(IDataHolder obj)
 {
     return Field.Accessor.Get(obj);
 }
 // TODO: Fix up default values
 internal void SetDefaults(object id, IDataHolder holder)
 {
     if (id is object[])
     {
         var ids = (object[])id;
         for (var i = 0; i < PrimaryColumns.Length; i++)
         {
             var col = PrimaryColumns[i].DataColumn;
             col.SetSingleValue(ids[i], holder);
         }
     }
     else
     {
         PrimaryColumns[0].DataColumn.SetSingleValue(id, holder);
     }
 }
Example #7
0
 public object GetTargetObject(IDataHolder rootObject)
 {
     return m_ArrayField.GetTargetObject(rootObject);
 }
Example #8
0
 public void Set(IDataHolder obj, object value)
 {
     var targetObj = GetTargetObject(obj);
     m_accessor.Set(targetObj, value);
     if (targetObj.GetType().IsValueType)
     {
         var parent = m_parent;
         object parentTarget;
         while (parent != null)
         {
             parentTarget = parent.GetTargetObject(obj);
             parent.Accessor.Set(parentTarget, targetObj);
             targetObj = parentTarget;
             parent = parent.Parent;
             if (!parentTarget.GetType().IsValueType)
             {
                 break;
             }
         }
     }
 }
Example #9
0
 public object Get(IDataHolder obj)
 {
     var targetObj = GetTargetObject(obj);
     return m_accessor.Get(targetObj);
 }
Example #10
0
 public void Set(IDataHolder obj, object value)
 {
     var targetObj = m_ArrayField.GetTargetObject(obj);
     m_ArrayField.Set(targetObj, m_Index, value);
 }
Example #11
0
 public object Get(IDataHolder obj)
 {
     var targetObj = m_ArrayField.GetTargetObject(obj);
     return m_ArrayField.Get(targetObj, m_Index);
 }
Example #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="rootObject"></param>
        /// <returns></returns>
        public object GetTargetObject(IDataHolder rootObject)
        {
            if (m_parent == null)
            {
                return rootObject;
            }

            var targetObj = m_parent.GetTargetObject(rootObject);

            var obj = m_parent.Accessor.Get(targetObj);
            if (obj == null)
            {
                obj = m_parent.Producer.Produce();
                m_parent.Accessor.Set(rootObject, obj);
            }
            return obj;
        }