// ------------------------------------------------------------------------------------------- // Translator Methods /* Turns out is was a bad idea to get "Value" by default via constructor. Instead, the * value should only be pulled from the translator when need comes. * This recursive call traverses the parents once the LAST enumerator is ready to read a value. * * FIXED: Made some fixes to the method (_Value was not being updated). */ public IValueType TranslatorGetValue() { if (Parent != null) { Parent.TranslatorGetValue(); // (recursively get dependent XML nodes first) if (Translator == null) { throw new InvalidOperationException("No translator specified."); } _Value = Translator.GetValue(Parent, NamePath.Split('.'), ValueIndex); // Note: The translator will expect Parent.Value to contain the XmlNodeField or DataListField<XmlNodeField> data it needs to read from. return(_Value); } if (_Value == null) // Note: This shouldn't happen, but just in case... { _Value = new XmlNodeField(null, true); } return(_Value); // Note: top level source enumerator simply returns the root XML document (as XmlNodeField). }
public void TranslatorSetValue(IValueType value) { Translator.SetValue(Parent, NamePath.Split('.'), value, ValueIndex); }
/// <summary> /// Преобразовать к строке /// </summary> /// <returns>Строка</returns> public override string ToString() { return(string.Format("[{0}: {1}]", Type, string.Join(".", NamePath.SkipWhile(o => o == "")))); }