Exemplo n.º 1
0
        public static Dictionary <string, object> ToDictionary <T>(this ILeoVisitor <T> visitor)
        {
            if (visitor is null)
            {
                throw new ArgumentNullException(nameof(visitor));
            }
            var val = new Dictionary <string, object>();
            var rel = (ICoreVisitor <T>)visitor;

            if (rel.LiteMode == LvMode.LITE)
            {
                throw new InvalidOperationException("Lite mode visitor has no Member handler.");
            }
            var lazyHandler = rel.ExposeLazyMemberHandler();

            foreach (var name in lazyHandler.Value.GetNames())
            {
                val[name] = visitor.GetValue(name);
            }
            return(val);
        }
Exemplo n.º 2
0
 public ValueGetter(ILeoVisitor visitor, string name)
 {
     _visitor = visitor;
     _getter  = () => visitor.GetValue(name);
 }