/// <summary>
        /// Create an instance of the Dependency class and over-ride DatabasePackage default values, while using values provided for copy objects
        /// </summary>
        /// <param name="packageToCopyFrom">The package to copy the information from</param>
        /// <param name="deep">Set to true to copy list objects, false to use new lists</param>
        public Dependency(DatabasePackage packageToCopyFrom, bool deep) : base(packageToCopyFrom, deep)
        {
            InstallGroup = 2;
            PatchGroup   = 2;
            if (packageToCopyFrom is Dependency dep)
            {
                this.DatabasePackageLogic = new List <DatabaseLogic>();
                this.Dependencies         = new List <DatabaseLogic>();

                if (deep)
                {
                    foreach (DatabaseLogic logic in dep.Dependencies)
                    {
                        this.Dependencies.Add(DatabaseLogic.Copy(logic));
                    }
                }
            }
            else if (packageToCopyFrom is SelectablePackage sp)
            {
                this.Dependencies = new List <DatabaseLogic>();
                if (deep)
                {
                    foreach (DatabaseLogic logic in sp.Dependencies)
                    {
                        this.Dependencies.Add(DatabaseLogic.Copy(logic));
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Create an instance of the SelectablePackage class and over-ride DatabasePackage default values, while using values provided for copy objects
        /// </summary>
        /// <param name="packageToCopyFrom">The package to copy the information from</param>
        /// <param name="deep">Set to true to copy list objects, false to use new lists</param>
        public SelectablePackage(DatabasePackage packageToCopyFrom, bool deep) : base(packageToCopyFrom, deep)
        {
            InstallGroup = 4;
            PatchGroup   = 4;

            if (packageToCopyFrom is Dependency dep)
            {
                if (deep)
                {
                    foreach (DatabaseLogic file in dep.Dependencies)
                    {
                        this.Dependencies.Add(DatabaseLogic.Copy(file));
                    }
                }
            }
            else if (packageToCopyFrom is SelectablePackage sp)
            {
                this.Type    = sp.Type;
                this.Name    = "WRITE_NEW_NAME";
                this.Visible = sp.Visible;
                this.Size    = 0;

                this.UpdateComment = string.Empty;
                this.Description   = string.Empty;
                this.PopularMod    = false;
                this._Checked      = false;

                this.Level               = -2;
                this.UserFiles           = new List <UserFile>();
                this.Packages            = new List <SelectablePackage>();
                this.Medias              = new List <Media>();
                this.Dependencies        = new List <DatabaseLogic>();
                this.ConflictingPackages = string.Empty;
                this.ShowInSearchList    = sp.ShowInSearchList;

                if (deep)
                {
                    this.UpdateComment = sp.UpdateComment;
                    this.Description   = sp.Description;
                    this.PopularMod    = sp.PopularMod;
                    this._Checked      = sp._Checked;

                    foreach (UserFile file in this.UserFiles)
                    {
                        this.UserFiles.Add(UserFile.DeepCopy(file));
                    }

                    foreach (Media file in this.Medias)
                    {
                        this.Medias.Add(Media.Copy(file));
                    }

                    foreach (DatabaseLogic file in this.Dependencies)
                    {
                        this.Dependencies.Add(DatabaseLogic.Copy(file));
                    }
                }
            }
        }
 /// <summary>
 /// Creates an instance of the DatabasePackage class based on the provided DatabasePackage
 /// </summary>
 /// <param name="packageToCopy">The package to copy the information from</param>
 /// <param name="deep">Set to true to copy list objects, false to use new lists</param>
 public DatabasePackage(DatabasePackage packageToCopy, bool deep)
 {
     this.PackageName  = packageToCopy.PackageName;
     this.Version      = packageToCopy.Version;
     this.Timestamp    = packageToCopy.Timestamp;
     this.ZipFile      = packageToCopy.ZipFile;
     this.CRC          = packageToCopy.CRC;
     this.LogAtInstall = packageToCopy.LogAtInstall;
     this.Triggers     = packageToCopy.Triggers;
     this.DevURL       = packageToCopy.DevURL;
     this.InstallGroup = packageToCopy.InstallGroup;
     this.PatchGroup   = packageToCopy.PatchGroup;
     this.Maintainers  = packageToCopy.Maintainers;
     this.UID          = packageToCopy.UID;
     //don't call the property for enabled, just the internal field
     this._Enabled = packageToCopy._Enabled;
 }