private SyncConfiguration GetCurrentConfigFromUI(bool applyVars = false)
        {
            SyncConfiguration config = new SyncConfiguration();
            Type type = config.GetType();

            FieldInfo[] properties = type.GetFields();

            foreach (FieldInfo property in properties)
            {
                if (property.Name.StartsWith("m_"))
                {
                    if (m_mapTextItems.ContainsKey(property.Name))
                    {
                        var v = m_mapTextItems[property.Name].Text;
                        v = applyVars ? RunImplementation.applyVariables(v, m_variables) : v;
                        property.SetValue(config, v);
                    }
                    else if (m_mapCheckItems.ContainsKey(property.Name))
                    {
                        property.SetValue(config, m_mapCheckItems[property.Name].Checked);
                    }
                    else
                    {
                        MessageBox.Show("unknown property:" + property.Name);
                    }
                }
            }

            return(config);
        }
        private void SetCurrentConfigToUI(SyncConfiguration config)
        {
            Type type = config.GetType();

            FieldInfo[] properties = type.GetFields();
            foreach (FieldInfo property in properties)
            {
                if (property.Name.StartsWith("m_"))
                {
                    if (m_mapTextItems.ContainsKey(property.Name))
                    {
                        m_mapTextItems[property.Name].Text = (string)property.GetValue(config);
                    }
                    else if (m_mapCheckItems.ContainsKey(property.Name))
                    {
                        m_mapCheckItems[property.Name].Checked = (bool)property.GetValue(config);
                    }
                    else
                    {
                        MessageBox.Show("unknown property:" + property.Name);
                    }
                }
            }
        }
        public static bool Validate(SyncConfiguration config)
        {
            if (!Directory.Exists(config.m_src) || !config.m_src.Contains("\\"))
            {
                if (!s_disableMessageBox)
                {
                    MessageBox.Show("Source dir does not exist");
                }

                return(false);
            }

            if (!Directory.Exists(config.m_destination) || !config.m_destination.Contains("\\"))
            {
                if (!s_disableMessageBox)
                {
                    MessageBox.Show("Dest dir does not exist");
                }

                return(false);
            }

            if (config.m_src.EndsWith("\\") || config.m_destination.EndsWith("\\"))
            {
                if (!s_disableMessageBox)
                {
                    MessageBox.Show("Directories should not end with a \\ character.");
                }

                return(false);
            }


            if (config.m_destination == config.m_src)
            {
                if (!s_disableMessageBox)
                {
                    MessageBox.Show("Src and destination should not be the same.");
                }

                return(false);
            }

            string tmpDest = (config.m_destination.ToLower() + "\\"), tmpSrc = (config.m_src.ToLower() + "\\");

            if (tmpDest.Contains(tmpSrc) || tmpSrc.Contains(tmpDest))
            {
                if (!s_disableMessageBox)
                {
                    MessageBox.Show("Src and destination should not intersect.");
                }

                return(false);
            }

            Type type = config.GetType();

            FieldInfo[] properties = type.GetFields();
            foreach (FieldInfo property in properties)
            {
                if (ShouldBeInt(property.Name))
                {
                    var str = (string)property.GetValue(config);
                    foreach (char c in str)
                    {
                        if (!"0123456789".Contains(c))
                        {
                            if (!s_disableMessageBox)
                            {
                                MessageBox.Show("in field " + property.Name + " needs to be a number, got " + str + " instead");
                            }
                            return(false);
                        }
                    }
                }
                else if (property.Name != "m_custom")
                {
                    var str = property.GetValue(config) as string;
                    if (str != null && str.Contains("\""))
                    {
                        if (!s_disableMessageBox)
                        {
                            MessageBox.Show("in field " + property.Name + " should not contain double-quote, got " + str + " instead");
                        }
                        return(false);
                    }
                }
            }

            return(true);
        }