コード例 #1
0
            /// <summary>
            /// Reconstructors a label registration from a JSON representation.
            /// </summary>
            /// <param name="label">JSON representation of a label registration.</param>
            /// <param name="types">Type space to look up label types.</param>
            /// <returns>Label registration corresponding to the JSON representation.</returns>
            public static LabelTarget FromJson(Json.Expression label, TypeSpace types)
            {
                var jo   = (Json.ObjectExpression)label;
                var type = types.Lookup(TypeRef.FromJson(jo.Members["Type"]));
                var name = (string)((Json.ConstantExpression)jo.Members["Name"]).Value;

                return(Expression.Label(type, name));
            }
コード例 #2
0
ファイル: Scope.cs プロジェクト: tamirdresher/reaqtor
        /// <summary>
        /// Creates a deserialization frame from the given JSON representation.
        /// </summary>
        /// <param name="json">JSON representation of a frame.</param>
        /// <param name="types">Type space used to lookup parameter types.</param>
        public DeserializationFrame(Json.Expression json, TypeSpace types)
        {
            _parameters = new List <ParameterExpression>();
            _mapping    = new Dictionary <string, ParameterExpression>();

            foreach (Json.ObjectExpression p in ((Json.ArrayExpression)json).Elements)
            {
                //
                // Note: keep in sync with SerializationFrame::ToJson code.
                //
                Add(
                    (string)((Json.ConstantExpression)p.Members["Name"]).Value,
                    types.Lookup(TypeRef.FromJson(p.Members["Type"])),
                    (string)((Json.ConstantExpression)p.Members["FriendlyName"]).Value
                    );
            }
        }