Exemplo n.º 1
0
        public override bool Equals(DatItem other)
        {
            // If we don't have a DiskArea, return false
            if (ItemType != other.ItemType)
            {
                return(false);
            }

            // Otherwise, treat it as a DiskArea
            DiskArea newOther = other as DiskArea;

            // If the DiskArea information matches
            return(Name == newOther.Name);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Replace fields from another item
        /// </summary>
        /// <param name="item">DatItem to pull new information from</param>
        /// <param name="fields">List of Fields representing what should be updated</param>
        public override void ReplaceFields(DatItem item, List <Field> fields)
        {
            // Replace common fields first
            base.ReplaceFields(item, fields);

            // If we don't have a DiskArea to replace from, ignore specific fields
            if (item.ItemType != ItemType.DiskArea)
            {
                return;
            }

            // Cast for easier access
            DiskArea newItem = item as DiskArea;

            // Replace the fields
            if (fields.Contains(Field.DatItem_AreaName))
            {
                Name = newItem.Name;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Replace fields from another item
        /// </summary>
        /// <param name="item">DatItem to pull new information from</param>
        /// <param name="fields">List of Fields representing what should be updated</param>
        public override void ReplaceFields(DatItem item, List <Field> fields)
        {
            // Replace common fields first
            base.ReplaceFields(item, fields);

            // If we don't have a Disk to replace from, ignore specific fields
            if (item.ItemType != ItemType.Disk)
            {
                return;
            }

            // Cast for easier access
            Disk newItem = item as Disk;

            // Replace the fields

            #region Common

            if (fields.Contains(Field.DatItem_Name))
            {
                Name = newItem.Name;
            }

            if (fields.Contains(Field.DatItem_MD5))
            {
                if (string.IsNullOrEmpty(MD5) && !string.IsNullOrEmpty(newItem.MD5))
                {
                    MD5 = newItem.MD5;
                }
            }

            if (fields.Contains(Field.DatItem_SHA1))
            {
                if (string.IsNullOrEmpty(SHA1) && !string.IsNullOrEmpty(newItem.SHA1))
                {
                    SHA1 = newItem.SHA1;
                }
            }

            if (fields.Contains(Field.DatItem_Merge))
            {
                MergeTag = newItem.MergeTag;
            }

            if (fields.Contains(Field.DatItem_Region))
            {
                Region = newItem.Region;
            }

            if (fields.Contains(Field.DatItem_Index))
            {
                Index = newItem.Index;
            }

            if (fields.Contains(Field.DatItem_Writable))
            {
                Writable = newItem.Writable;
            }

            if (fields.Contains(Field.DatItem_Status))
            {
                ItemStatus = newItem.ItemStatus;
            }

            if (fields.Contains(Field.DatItem_Optional))
            {
                Optional = newItem.Optional;
            }

            #endregion

            #region SoftwareList

            if (DiskAreaSpecified && newItem.DiskAreaSpecified)
            {
                DiskArea.ReplaceFields(newItem.DiskArea, fields);
            }

            if (PartSpecified && newItem.PartSpecified)
            {
                Part.ReplaceFields(newItem.Part, fields);
            }

            #endregion
        }
Exemplo n.º 4
0
        /// <summary>
        /// Remove fields from the DatItem
        /// </summary>
        /// <param name="fields">List of Fields to remove</param>
        public override void RemoveFields(List <Field> fields)
        {
            // Remove common fields first
            base.RemoveFields(fields);

            // Remove the fields

            #region Common

            if (fields.Contains(Field.DatItem_Name))
            {
                Name = null;
            }

            if (fields.Contains(Field.DatItem_MD5))
            {
                MD5 = null;
            }

            if (fields.Contains(Field.DatItem_SHA1))
            {
                SHA1 = null;
            }

            if (fields.Contains(Field.DatItem_Merge))
            {
                MergeTag = null;
            }

            if (fields.Contains(Field.DatItem_Region))
            {
                Region = null;
            }

            if (fields.Contains(Field.DatItem_Index))
            {
                Index = null;
            }

            if (fields.Contains(Field.DatItem_Writable))
            {
                Writable = null;
            }

            if (fields.Contains(Field.DatItem_Status))
            {
                ItemStatus = ItemStatus.NULL;
            }

            if (fields.Contains(Field.DatItem_Optional))
            {
                Optional = null;
            }

            #endregion

            #region SoftwareList

            if (DiskAreaSpecified)
            {
                DiskArea.RemoveFields(fields);
            }

            if (PartSpecified)
            {
                Part.RemoveFields(fields);
            }

            #endregion
        }
Exemplo n.º 5
0
        /// <summary>
        /// Check to see if a DatItem passes the filter
        /// </summary>
        /// <param name="filter">Filter to check against</param>
        /// <param name="sub">True if this is a subitem, false otherwise</param>
        /// <returns>True if the item passed the filter, false otherwise</returns>
        public override bool PassesFilter(Filter filter, bool sub = false)
        {
            // Check common fields first
            if (!base.PassesFilter(filter, sub))
            {
                return(false);
            }

            #region Common

            // Filter on item name
            if (!filter.PassStringFilter(filter.DatItem_Name, Name))
            {
                return(false);
            }

            // Filter on MD5
            if (!filter.PassStringFilter(filter.DatItem_MD5, MD5))
            {
                return(false);
            }

            // Filter on SHA-1
            if (!filter.PassStringFilter(filter.DatItem_SHA1, SHA1))
            {
                return(false);
            }

            // Filter on merge tag
            if (!filter.PassStringFilter(filter.DatItem_Merge, MergeTag))
            {
                return(false);
            }

            // Filter on region
            if (!filter.PassStringFilter(filter.DatItem_Region, Region))
            {
                return(false);
            }

            // Filter on index
            if (!filter.PassStringFilter(filter.DatItem_Index, Index))
            {
                return(false);
            }

            // Filter on writable
            if (!filter.PassBoolFilter(filter.DatItem_Writable, Writable))
            {
                return(false);
            }

            // Filter on status
            if (filter.DatItem_Status.MatchesPositive(ItemStatus.NULL, ItemStatus) == false)
            {
                return(false);
            }
            if (filter.DatItem_Status.MatchesNegative(ItemStatus.NULL, ItemStatus) == true)
            {
                return(false);
            }

            // Filter on optional
            if (!filter.PassBoolFilter(filter.DatItem_Optional, Optional))
            {
                return(false);
            }

            #endregion

            #region SoftwareList

            // Filter on DiskArea
            if (DiskAreaSpecified)
            {
                if (!DiskArea.PassesFilter(filter, true))
                {
                    return(false);
                }
            }

            // Filter on Part
            if (PartSpecified)
            {
                if (!Part.PassesFilter(filter, true))
                {
                    return(false);
                }
            }

            #endregion

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Set fields with given values
        /// </summary>
        /// <param name="mappings">Mappings dictionary</param>
        public override void SetFields(Dictionary <Field, string> mappings)
        {
            // Set base fields
            base.SetFields(mappings);

            // Handle Disk-specific fields
            if (mappings.Keys.Contains(Field.DatItem_Name))
            {
                Name = mappings[Field.DatItem_Name];
            }

            if (mappings.Keys.Contains(Field.DatItem_MD5))
            {
                MD5 = mappings[Field.DatItem_MD5];
            }

            if (mappings.Keys.Contains(Field.DatItem_SHA1))
            {
                SHA1 = mappings[Field.DatItem_SHA1];
            }

            if (mappings.Keys.Contains(Field.DatItem_Merge))
            {
                MergeTag = mappings[Field.DatItem_Merge];
            }

            if (mappings.Keys.Contains(Field.DatItem_Region))
            {
                Region = mappings[Field.DatItem_Region];
            }

            if (mappings.Keys.Contains(Field.DatItem_Index))
            {
                Index = mappings[Field.DatItem_Index];
            }

            if (mappings.Keys.Contains(Field.DatItem_Writable))
            {
                Writable = mappings[Field.DatItem_Writable].AsYesNo();
            }

            if (mappings.Keys.Contains(Field.DatItem_Status))
            {
                ItemStatus = mappings[Field.DatItem_Status].AsItemStatus();
            }

            if (mappings.Keys.Contains(Field.DatItem_Optional))
            {
                Optional = mappings[Field.DatItem_Optional].AsYesNo();
            }

            // Handle DiskArea-specific fields
            if (DiskArea == null)
            {
                DiskArea = new DiskArea();
            }

            DiskArea.SetFields(mappings);

            // Handle Part-specific fields
            if (Part == null)
            {
                Part = new Part();
            }

            Part.SetFields(mappings);
        }