private static KhartaSource ToKhartaSource(Source fromSource)
        {
            KhartaSource khartaSource = new KhartaSource();
            Type         ks           = khartaSource.GetType();

            Type s = fromSource.GetType();
            IList <PropertyInfo> ksproperties = new List <PropertyInfo>(ks.GetProperties());
            IList <PropertyInfo> properties   = new List <PropertyInfo>(s.GetProperties());

            foreach (PropertyInfo prop in ksproperties)
            {
                if (prop.CanWrite)
                {
                    PropertyInfo sProp = s.GetProperty(prop.Name);
                    int          sourcePropertyIndex = properties.IndexOf(sProp);

                    if (sourcePropertyIndex > -1)
                    {
                        sProp = properties[sourcePropertyIndex];
                        if (sProp.CanRead)
                        {
                            var value = sProp.GetValue(fromSource);
                            prop.SetValue(khartaSource, value);
                        }
                    }
                }
            }
            return(khartaSource);
        }
        private static Source ToSource(KhartaSource fromKhartaSource)
        {
            Type   ks     = fromKhartaSource.GetType();
            Source source = new Source();
            Type   s      = source.GetType();
            IList <PropertyInfo> ksproperties = new List <PropertyInfo>(ks.GetProperties());
            IList <PropertyInfo> properties   = new List <PropertyInfo>(s.GetProperties());

            foreach (PropertyInfo prop in properties)
            {
                PropertyInfo sProp = ks.GetProperty(prop.Name);
                int          sourcePropertyIndex = ksproperties.IndexOf(sProp);
                if (sourcePropertyIndex > -1)
                {
                    sProp = properties[sourcePropertyIndex];

                    if (sProp.CanRead)
                    {
                        var value = sProp.GetValue(fromKhartaSource);
                        if (prop.CanWrite)
                        {
                            prop.SetValue(source, value);
                        }
                    }
                }
            }
            return(source);
        }