Esempio n. 1
0
        private bool ResolveStuffedEmbeddedQuotes(FtMeta meta, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMeta.PropertyId.StuffedEmbeddedQuotes, out attributeValue))
            {
                meta.StuffedEmbeddedQuotes = FtMeta.DefaultStuffedEmbeddedQuotes;
            }
            else
            {
                bool propertyValue;
                if (FtStandardText.TryParse(attributeValue, out propertyValue))
                {
                    meta.StuffedEmbeddedQuotes = propertyValue;
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.FieldedTextReadElement_ResolveStuffedEmbeddedQuotes_Invalid, attributeValue);
                    result           = false;
                }
            }

            return(result);
        }
Esempio n. 2
0
        private bool ResolveLineCommentChar(FtMeta meta, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMeta.PropertyId.LineCommentChar, out attributeValue))
            {
                meta.LineCommentChar = FtMeta.DefaultLineCommentChar;
            }
            else
            {
                char propertyValue;
                if (FtStandardText.TryParse(attributeValue, out propertyValue))
                {
                    meta.LineCommentChar = propertyValue;
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.FieldedTextReadElement_ResolveLineCommentChar_Invalid, attributeValue);
                    result           = false;
                }
            }

            return(result);
        }
Esempio n. 3
0
        private bool ResolveMainHeadingLineIndex(FtMeta meta, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMeta.PropertyId.MainHeadingLineIndex, out attributeValue))
            {
                meta.MainHeadingLineIndex = FtMeta.DefaultMainHeadingLineIndex;
            }
            else
            {
                int propertyValue;
                if (FtStandardText.TryParse(attributeValue, out propertyValue))
                {
                    meta.MainHeadingLineIndex = propertyValue;
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.FieldedTextReadElement_ResolveMainHeadingLineIndex_Invalid, attributeValue);
                    result           = false;
                }
            }

            return(result);
        }
Esempio n. 4
0
        private bool ResolveHeadingWritePrefixSpace(FtMeta meta, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMeta.PropertyId.HeadingWritePrefixSpace, out attributeValue))
            {
                meta.HeadingWritePrefixSpace = FtMeta.DefaultHeadingWritePrefixSpace;
            }
            else
            {
                bool propertyValue;
                if (FtStandardText.TryParse(attributeValue, out propertyValue))
                {
                    meta.HeadingWritePrefixSpace = propertyValue;
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.FieldedTextReadElement_ResolveHeadingWritePrefixSpace_Invalid, attributeValue);
                    result           = false;
                }
            }

            return(result);
        }
Esempio n. 5
0
        private bool ResolveAllowIncompleteRecords(FtMeta meta, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMeta.PropertyId.AllowIncompleteRecords, out attributeValue))
            {
                meta.AllowIncompleteRecords = FtMeta.DefaultAllowIncompleteRecords;
            }
            else
            {
                bool propertyValue;
                if (FtStandardText.TryParse(attributeValue, out propertyValue))
                {
                    meta.AllowIncompleteRecords = propertyValue;
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.FieldedTextReadElement_ResolveAllowIncompleteRecords_Invalid, attributeValue);
                    result           = false;
                }
                allowIncompleteRecordsSpecified = true;
            }

            return(result);
        }
Esempio n. 6
0
        private bool ResolveToken(FtMetaSubstitution substitution, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMetaSubstitution.PropertyId.Token, out attributeValue))
            {
                errorDescription = string.Format(Properties.Resources.SubstitutionReadElement_ResolveToken_Missing, SubstitutionTypeFormatter.ToAttributeValue(substitution.Type));
                result           = false;
            }
            else
            {
                char propertyValue;
                if (FtStandardText.TryParse(attributeValue, out propertyValue))
                {
                    substitution.Token = propertyValue;
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.SubstitutionReadElement_ResolveToken_Invalid, attributeValue);
                    result           = false;
                }
            }

            return(result);
        }
Esempio n. 7
0
        private bool ResolveLegacyEndOfLineIsSeparator(FtMeta meta, out string errorDescription)
        {
            errorDescription = "";
            bool result = true;

            if (!lastLineEndedTypeSpecified)
            {
                string attributeValue;
                if (attributeDictionary.TryGetValue(FtMeta.PropertyId.LegacyEndOfLineIsSeparator, out attributeValue))
                {
                    bool propertyValue;
                    if (FtStandardText.TryParse(attributeValue, out propertyValue)) // ignore invalid property - will use default from ResolveLastLineEndedType
                    {
                        if (propertyValue)
                        {
                            meta.LastLineEndedType = FtLastLineEndedType.Never;
                        }
                        else
                        {
                            meta.LastLineEndedType = FtLastLineEndedType.Optional;
                        }
                    }
                }
            }

            return(result);
        }
Esempio n. 8
0
        private bool ResolveRoot(FtMetaSequence sequence, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMetaSequence.PropertyId.Root, out attributeValue))
            {
                sequence.Root = FtMetaSequence.DefaultRoot;
            }
            else
            {
                bool propertyValue;
                if (FtStandardText.TryParse(attributeValue, out propertyValue))
                {
                    sequence.Root = propertyValue;
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.SequenceReadElement_ResolveRoot_Invalid, attributeValue);
                    result           = false;
                }
            }

            return(result);
        }
Esempio n. 9
0
        private bool ResolveExactStringValue(FtExactStringMetaSequenceRedirect redirect, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMetaSequenceRedirect.PropertyId.Value, out attributeValue))
            {
                errorDescription = string.Format(Properties.Resources.SequenceRedirectReadElement_ResolveExactStringValue_Missing, FtStandardSequenceRedirectType.ToName(redirectType));
                result           = false;
            }
            else
            {
                string propertyValue;
                if (FtStandardText.TryParse(attributeValue, out propertyValue))
                {
                    redirect.Value = propertyValue;
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.SequenceRedirectReadElement_ResolveExactStringValue_Invalid, attributeValue);
                    result           = false;
                }
            }

            return(result);
        }
Esempio n. 10
0
        internal protected override bool TryAddOrIgnoreAttribute(string name, string value, out string errorDescription)
        {
            errorDescription = "";
            bool result = true;

            FtMetaSequenceItem.PropertyId id;
            if (SequenceItemPropertyIdFormatter.TryParseAttributeName(name, out id))
            {
                switch (id)
                {
                case FtMetaSequenceItem.PropertyId.Index:
                    int parsedIndex;
                    if (FtStandardText.TryParse(value, out parsedIndex))
                    {
                        explicitIndex = parsedIndex;
                    }
                    else
                    {
                        errorDescription = string.Format(Properties.Resources.SequenceItemReadElement_TryAddOrIgnoreAttribute_Invalid, value);
                        result           = false;
                    }
                    break;

                default:
                    attributeDictionary.Add(id, value);
                    break;
                }
            }

            return(result);
        }
Esempio n. 11
0
        // properties

        private bool ResolveFieldIndex(FtMetaSequenceItem item, FtMetaFieldList fieldList, out string errorDescription)
        {
            errorDescription = "";
            bool   result = true;
            string attributeValue;

            if (!attributeDictionary.TryGetValue(FtMetaSequenceItem.PropertyId.FieldIndex, out attributeValue))
            {
                errorDescription = string.Format(Properties.Resources.SequenceItemReadElement_ResolveFieldIndex_Missing);
                result           = false;
            }
            else
            {
                int fieldIndex;
                if (FtStandardText.TryParse(attributeValue, out fieldIndex))
                {
                    if (fieldIndex < 0 || fieldIndex >= fieldList.Count)
                    {
                        errorDescription = string.Format(Properties.Resources.SequenceItemReadElement_ResolveFieldIndex_OutOfRange, fieldIndex);
                    }
                    else
                    {
                        item.Field = fieldList[fieldIndex];
                    }
                }
                else
                {
                    errorDescription = string.Format(Properties.Resources.SequenceItemReadElement_ResolveFieldIndex_Invalid, attributeValue);
                    result           = false;
                }
            }

            return(result);
        }
Esempio n. 12
0
        private bool ParseVersionValue(string text, out int major, out int minor, out string comment)
        {
            int majorMinorSeparatorIdx = text.IndexOf(VersionPartsSeparator);

            if (majorMinorSeparatorIdx <= 0 || majorMinorSeparatorIdx >= (text.Length - 1))
            {
                major   = -1;
                minor   = -1;
                comment = "";
                return(false);
            }
            else
            {
                int minorCommentSeparatorIdx = text.IndexOf(VersionPartsSeparator, majorMinorSeparatorIdx + 1);
                if (minorCommentSeparatorIdx < 0)
                {
                    comment = "";
                    minorCommentSeparatorIdx = text.Length;
                }
                else
                {
                    if (minorCommentSeparatorIdx >= (text.Length - 1))
                    {
                        comment = "";
                    }
                    else
                    {
                        comment = text.Substring(minorCommentSeparatorIdx + 1);
                    }
                }

                string majorText = text.Substring(0, majorMinorSeparatorIdx);
                if (!FtStandardText.TryParse(majorText, out major))
                {
                    major = -1;
                    minor = -1;
                    return(false);
                }
                else
                {
                    string minorText = text.Substring(majorMinorSeparatorIdx + 1, minorCommentSeparatorIdx - majorMinorSeparatorIdx - 1);
                    return(FtStandardText.TryParse(minorText, out minor));
                }
            }
        }