DeserializedJsonToWoopsaValue() public static méthode

public static DeserializedJsonToWoopsaValue ( object deserializedJson, WoopsaValueType type, System.DateTime timeStamp = null ) : WoopsaValue
deserializedJson object
type WoopsaValueType
timeStamp System.DateTime
Résultat WoopsaValue
Exemple #1
0
        internal string InvokeMethodDeserializedJson(string path, Dictionary <string, object> arguments)
        {
            int argumentsCount = arguments != null ? arguments.Count : 0;

            return(InvokeMethod(path, argumentsCount,
                                (argumentName, woopsaValueType) =>
            {
                object argumentValue = arguments[argumentName];
                if (argumentValue != null)
                {
                    return WoopsaValue.DeserializedJsonToWoopsaValue(
                        argumentValue, woopsaValueType);
                }
                else
                {
                    return null;
                }
            }));
        }
Exemple #2
0
        internal string WriteValueDeserializedJson(string path, object deserializedJson)
        {
            IWoopsaElement item = FindByPath(path);

            if ((item is IWoopsaProperty))
            {
                IWoopsaProperty property = item as IWoopsaProperty;
                if (property.IsReadOnly)
                {
                    throw new WoopsaInvalidOperationException(String.Format(
                                                                  "Cannot write a read-only WoopsaProperty for path {0}", path));
                }
                property.Value = WoopsaValue.DeserializedJsonToWoopsaValue(deserializedJson,
                                                                           property.Type);
                return(WoopsaValue.Null.Serialize());
            }
            else
            {
                throw new WoopsaInvalidOperationException(String.Format("Cannot write value of a non-WoopsaProperty for path {0}", path));
            }
        }
Exemple #3
0
        internal string InvokeMethodDeserializedJson(string path, Dictionary <string, object> arguments)
        {
            IWoopsaElement item = FindByPath(path);

            if (item is IWoopsaMethod)
            {
                int           argumentsCount = arguments != null ? arguments.Count : 0;
                IWoopsaMethod method         = item as IWoopsaMethod;
                if (argumentsCount == method.ArgumentInfos.Count())
                {
                    List <WoopsaValue> woopsaArguments = new List <WoopsaValue>();
                    foreach (var argInfo in method.ArgumentInfos)
                    {
                        object argumentValue = arguments[argInfo.Name];
                        if (argumentValue == null)
                        {
                            throw new WoopsaInvalidOperationException(String.Format("Missing argument {0} for method {1}", argInfo.Name, item.Name));
                        }
                        woopsaArguments.Add(WoopsaValue.DeserializedJsonToWoopsaValue(
                                                argumentValue, argInfo.Type));
                    }
                    IWoopsaValue result = method.Invoke(woopsaArguments.ToArray());
                    return(result != null?result.Serialize() : WoopsaConst.WoopsaNull);
                }
                else
                {
                    throw new WoopsaInvalidOperationException(String.Format(
                                                                  "Wrong argument count for method {0}", item.Name));
                }
            }
            else
            {
                throw new WoopsaInvalidOperationException(String.Format(
                                                              "Cannot invoke a {0}", item.GetType()));
            }
        }
Exemple #4
0
 internal string WriteValueDeserializedJson(string path, object deserializedJson)
 {
     return(WriteValue(path, (woopsaValueType) => WoopsaValue.DeserializedJsonToWoopsaValue(deserializedJson, woopsaValueType)));
 }