Exemplo n.º 1
0
        public static int AddItem(TestItem aTestItem, HeaderContent aHeaderContent, string aHeaderPath)
        {
            var nameToID            = aHeaderContent.NameToID;
            var sortedHeaderResults = aHeaderContent.SortedHeaderResults;

            var normalizedID = IDNormalizer.CopyNormalizeHexaID(aTestItem.ID);

            // Check Name Unique
            if (nameToID.ContainsKey(aTestItem.Name))
            {
                return(Constants.kDuplicateID);
            }

            // Check ID Unique
            var insertedItem = new HeaderItem {
                ID = normalizedID, Name = aTestItem.Name
            };

            var foundIndex = aHeaderContent.GetPosition(insertedItem.ID, aHeaderPath);

            if (foundIndex == Constants.kDuplicateID)
            {
                return(foundIndex);
            }

            sortedHeaderResults[aHeaderPath].Insert(foundIndex, insertedItem);
            nameToID[aTestItem.Name] = normalizedID;

            return(foundIndex);
        }
Exemplo n.º 2
0
        public RCFileItem GetStringResourceByName(string aStringResourceName)
        {
            if (!HeaderContent.NameToID.ContainsKey(aStringResourceName))
            {
                return(null);
            }

            var currentResourceID = new HeaderId(HeaderContent.NameToID[aStringResourceName]);

            if (IDValidator.IsRecurrentCase(currentResourceID, HeaderContent))
            {
                IDNormalizer.NormalizeRecurrenceForID(currentResourceID, HeaderContent);
            }
            if (IDValidator.IsHexaRepresentation(currentResourceID))
            {
                IDNormalizer.NormalizeHexaID(currentResourceID);
            }

            if (!IDValidator.IsValid(currentResourceID, HeaderContent))
            {
                return(null);
            }

            return(mRCFileContent.GetStringLineForName(aStringResourceName, currentResourceID));
        }