internal sealed override object ReadValue(EmberReader reader, out ParameterType?parameterType)
        {
            switch (reader.InnerNumber)
            {
            case InnerNumber.Boolean:
                parameterType = ParameterType.Boolean;
                return(reader.ReadContentsAsBoolean());

            case InnerNumber.Integer:
                parameterType = ParameterType.Integer;
                return(reader.ReadContentsAsInt64());

            case InnerNumber.Octetstring:
                parameterType = ParameterType.Octets;
                return(reader.ReadContentsAsByteArray());

            case InnerNumber.Real:
                parameterType = ParameterType.Real;
                return(reader.ReadContentsAsDouble());

            default:
                parameterType = ParameterType.String;
                return(reader.AssertAndReadContentsAsString());
            }
        }
Exemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        private static void ReadInvocationResult(
            EmberReader reader, IDictionary <int, IInvocationResult> pendingInvocations)
        {
            var success = true;
            IInvocationResult result = null;

            while (reader.Read() && (reader.InnerNumber != InnerNumber.EndContainer))
            {
                switch (reader.GetContextSpecificOuterNumber())
                {
                case GlowInvocationResult.InvocationId.OuterNumber:
                    var invocationId = reader.AssertAndReadContentsAsInt32();
                    pendingInvocations.TryGetValue(invocationId, out result);
                    pendingInvocations.Remove(invocationId);
                    break;

                case GlowInvocationResult.Success.OuterNumber:
                    success = reader.ReadContentsAsBoolean();
                    break;

                case GlowInvocationResult.Result.OuterNumber:
                    if (result != null)
                    {
                        result.Read(reader);
                    }
                    else
                    {
                        reader.Skip();
                    }

                    break;

                default:
                    reader.Skip();
                    break;
                }
            }

            result?.Publish(success);
        }