public void Set(MainParentClass Child)
        {
            this.Enabled           = true;
            buttonCreate.BackColor = Default;

            if (Child is null)
            {
                buttonCreate.Text = "Добавить";
            }
            else
            {
                buttonCreate.Text = "Сохранить";
            }
        }
Exemplo n.º 2
0
        public static T InheritanceClone <T>(MainParentClass From, T To) where T : MainParentClass
        {
            if (!(To is null) & !(From is null))
            {
                var Properties_From    = From.GetType().GetProperties().ToList();
                var PropertiesToRemove = typeof(MainParentClass).GetProperties().ToList();

                foreach (var Property in PropertiesToRemove)
                {
                    int Index = Properties_From.FindIndex(x => x.Name == Property.Name);

                    if (Index > -1)
                    {
                        Properties_From.RemoveAt(Index);
                    }
                }

                {
                    int Index = Properties_From.FindIndex(x => x.Name == "UpdateObject_Original");

                    if (Index > -1)
                    {
                        Properties_From.RemoveAt(Index);
                    }
                }

                var Properties_To = To.GetType().GetProperties().ToList();

                foreach (var Property in Properties_From)
                {
                    var Finded = Properties_To.FirstOrDefault(x => x.Name == Property.Name);

                    if (!(Finded is null))
                    {
                        try
                        {
                            var GetValue = Property.GetValue(From);
                            Finded.SetValue(To, GetValue);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }

            return(To);
        }
        public MainParentClass Set(MainParentClass Before, MainParentClass SettedStruct, bool Exported, out TimeSpan TimeOnSetted)
        {
            DateTime TimeOnSetted_Start = DateTime.Now;
            TimeSpan MainParentClass_Changes_ToChanged_Time  = default;
            TimeSpan CollectedChangesToExport_ToChanged_Time = default;
            TimeSpan Set_MainParentClass_ToChanged_Time      = default;
            TimeSpan Before_ToChanged_Time = default;
            bool     IsClient = false;

            if (SettedStruct is null ? false : MainParentClass.ToFindTypeRecord(SettedStruct, out TimeSpan TimeS, out MainParentClass FindedObject))
            { // From Client
                IsChanged = true;
                IsClient  = true;

                if (CollectedChangesToExport is null)
                {
                    CollectedChangesToExport = (MainParentClass)SettedStruct.Clone();
                    MainParentClass.ToChanged(CollectedChangesToExport, CollectedChangesToExport, out CollectedChangesToExport_ToChanged_Time, true, out string Exception);
                }
                else
                {
                    MainParentClass.ToChanged((MainParentClass)SettedStruct.Clone(), CollectedChangesToExport, out MainParentClass_Changes_ToChanged_Time, true, out string Exception);

                    if (!string.IsNullOrEmpty(Exception))
                    {
                    }
                }

                if (!(Before is null))
                {
                    MainParentClass.ToChanged(SettedStruct, Before, out Before_ToChanged_Time, false, out string Exception);

                    if (!string.IsNullOrEmpty(Exception))
                    {
                    }
                }
            }