using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Telerik.Data
{
    public class DataRow
    {
        private readonly DataTable owner;
        private DynamicObject rowObject;

        protected internal DataRow(DataTable owner)
        {
            this.owner = owner;
        }

        public object this[string columnName]
        {
            get
            {
                return this.RowObject.GetValue<object>(columnName);
            }
            set
            {
                this.RowObject.SetValue(columnName, value);
            }
        }

        internal DynamicObject RowObject
        {
            get
            {
                this.EnsureRowObject();
                return this.rowObject; 
            }
        }

        private void EnsureRowObject()
        {
            if (this.rowObject == null)
            {
                this.rowObject = (DynamicObject) Activator.CreateInstance(this.owner.ElementType);
            }
        }
    }
}
