Exemplo n.º 1
0
        private static IValue ConvertDocument(Context context, Object value, Type type, IType returnType)
        {
            if ((returnType == DocumentType.Instance || returnType == AnyType.Instance) && value is IDictionary <string, object> )
            {
                IDictionary <string, object> dict = (IDictionary <string, object>)value;
                DocumentValue doc = new DocumentValue();
                foreach (KeyValuePair <string, object> kvp in dict)
                {
                    doc.SetMemberValue(context, kvp.Key, ConvertCSharpValueToPromptoValue(context, kvp.Value, null, AnyType.Instance));
                }
                return(doc);
            }

            return(null);
        }
Exemplo n.º 2
0
        public override IValue ReadJSONValue(Context context, JToken value, Dictionary <String, byte[]> parts)
        {
            if (!(value is JObject))
            {
                throw new InvalidDataException("Expecting a JSON object!");
            }
            JObject       obj      = (JObject)value;
            DocumentValue instance = new DocumentValue();

            foreach (KeyValuePair <String, JToken> prop in obj)
            {
                IValue item = ReadJSONField(context, prop.Value, parts);
                instance.SetMemberValue(context, prop.Key, item);
            }
            return(instance);
        }
Exemplo n.º 3
0
 protected override void writeValue(String name, IValue value)
 {
     document.SetMemberValue(calling, name, value);
 }