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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
// 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); }
private List <Rec> list; // does not include version private string VersionToText(int major, int minor, string comment) { string majorMinor = FtStandardText.Get(major) + VersionPartsSeparator.ToString() + FtStandardText.Get(minor); if (comment.Length == 0) { return(majorMinor); } else { return(majorMinor + VersionPartsSeparator.ToString() + comment); } }
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)); } } }
internal protected virtual bool ResolveItemsTo(FtMetaSequence sequence, FtMetaFieldList fieldList, FtMetaSequenceList sequenceList, out string errorDescription) { ItemSorter.Rec[] sorterRecArray = new ItemSorter.Rec[itemList.Count + fieldIndices.Length]; SequenceItemReadElement[] sortedItemElements; for (int i = 0; i < itemList.Count; i++) { SequenceItemReadElement itemElement = itemList[i]; sorterRecArray[i].Target = itemElement; sorterRecArray[i].Implicit = i; sorterRecArray[i].Explicit = itemElement.ExplicitIndex; } int elementallyDefinedItemCount = itemList.Count; for (int i = 0; i < fieldIndices.Length; i++) { SequenceItemReadElement itemElement = new SequenceItemReadElement(); // Add FieldIndex to element as if it were read from an attribute. int fieldIndex = fieldIndices[i]; string attributeName = SequenceItemPropertyIdFormatter.ToAttributeName(FtMetaSequenceItem.PropertyId.FieldIndex); string attributeValue = FtStandardText.Get(fieldIndex); if (!itemElement.TryAddOrIgnoreAttribute(attributeName, attributeValue, out errorDescription)) { throw FtInternalException.Create(InternalError.SequenceReadElement_ResolveItemsTo_TryAddOrIgnoreAttribute, errorDescription); // program error } else { int implicitIndex = elementallyDefinedItemCount + i; sorterRecArray[implicitIndex].Target = itemElement; sorterRecArray[implicitIndex].Implicit = implicitIndex; sorterRecArray[implicitIndex].Explicit = -1; } } int duplicateExplicitIndex; if (!ItemSorter.TrySort(sorterRecArray, out sortedItemElements, out duplicateExplicitIndex)) { errorDescription = string.Format(Properties.Resources.SequenceReadElement_ResolveItemsTo_DuplicateExplicitIndex, duplicateExplicitIndex); return(false); } else { errorDescription = ""; bool result = true; for (int i = 0; i < sortedItemElements.Length; i++) { SequenceItemReadElement itemElement = sortedItemElements[i]; FtMetaSequenceItem item = sequence.ItemList.New(); if (!itemElement.ResolveTo(item, fieldList, sequenceList, out errorDescription)) { result = false; break; } } return(result); } }