Пример #1
0
 public ValueTypeSerializer(
     ValueConstructor constructor,
     SerializationCallbacksFactory.SerializationCallbacks <SerializationCallback> callbacks,
     SerializationEntryCodec entrySerializer,
     StreamingContext streamingContext,
     IFormatterConverter formatterConverter)
 {
     this.constructor        = constructor;
     this.callbacks          = callbacks;
     this.entrySerializer    = entrySerializer;
     this.streamingContext   = streamingContext;
     this.formatterConverter = formatterConverter;
 }
Пример #2
0
        /// <summary>
        /// Interpret the term as a .NET value in this context
        /// </summary>
        public IComparable InterpretTerm(Term term)
        {
            Any a = term as Any;

            if (a != null)
            {
                return(a);
            }

            Literal l = term as Literal;

            if (l != null)
            {
                return(l.Value);
            }

            //IComparable result;
            CompoundTerm ct = term as CompoundTerm;

            if (ct != null)
            {
                Symbol sort = ct.Symbol;
                // Case 1: Quoted term. No evaluation needed
                if (quoteSymbol.Equals(sort))
                {
                    return(ct.Arguments.Head);
                }
                // Case 2: reconstruct value from sort.
                else
                {
                    int arity = ct.Arguments.Count;
                    ValueConstructor       ctor = GetValueConstructor(sort, arity);
                    Sequence <IComparable> args = ct.Arguments.Convert <IComparable>(InterpretTerm);
                    return(ctor(args));
                }
            }

            throw new ArgumentException("Can't interpret term " + term.ToString());
        }
Пример #3
0
 public ScriptValue(ValueConstructor valueConstructor)
 {
     m_valueConstructor = valueConstructor;
 }
Пример #4
0
 /// <summary>
 /// Add a value constructor for the given sort
 /// </summary>
 public void AddValueConstructor(Symbol sort, ValueConstructor constructor)
 {
     valueConstructors.Add(sort, constructor);
 }
Пример #5
0
 /// <summary>
 /// Add a value constructor for the given sort
 /// </summary>
 public void AddValueConstructor(Symbol sort, ValueConstructor constructor)
 {
     valueConstructors.Add(sort, constructor);
 }