Ejemplo n.º 1
0
        public virtual ITypedValue GetTypedValue(bool deserializeValue)
        {
            if ((cachedValue != null) && cachedValue is ISerializableValue && (Context.CommandContext != null))
            {
                ISerializableValue serializableValue = (ISerializableValue)cachedValue;
                if (deserializeValue && !serializableValue.IsDeserialized)
                {
                    // clear cached value in case it is not deserialized and user requests deserialized value
                    cachedValue = null;
                }
            }

            if ((cachedValue == null) && (errorMessage == null))
            //try
            {
                cachedValue = Serializer.ReadValue(valueFields, deserializeValue);

                if (isNotifyOnImplicitUpdates && IsMutableValue(cachedValue) && Context.CommandContext != null)
                {
                    Context.CommandContext.RegisterCommandContextListener(this);
                }

                //}
                // catch (Exception e)
                //{
                // intercept the error message
                //    errorMessage = e.Message;
                //    throw e;
            }
            return(cachedValue);
        }
Ejemplo n.º 2
0
        internal ISerializableValue Instantiate(Type type, PainlessBinaryReader reader)
        {
            RegisteredType     registeredType = GetRegisteredType(type);
            ISerializableValue value          = registeredType.Instantiator(this, type, reader);

            return(value);
        }
Ejemplo n.º 3
0
        internal ISerializableValue WrapRawValue(Type type, object value)
        {
            RegisteredType     registeredType    = GetRegisteredType(type);
            ISerializableValue serializableValue = registeredType.Wrapper(this, type, value);

            return(serializableValue);
        }
Ejemplo n.º 4
0
        void WriteRegularValue(Type type, object value, bool doesTypeSerializeAsReference)
        {
            ISerializableValue itemSerializableValue = _typeManager.WrapRawValue(type, value);

            itemSerializableValue.Write(this);

            if (doesTypeSerializeAsReference)
            {
                uint referenceNumber = _referenceTable.Register(value);
                Write(referenceNumber);
            }
        }
Ejemplo n.º 5
0
        object ReadRegularValue(Type expectedType)
        {
            ISerializableValue itemSerializableValue = _typeManager.Instantiate(expectedType, this);

            itemSerializableValue.Read(this);
            object value = itemSerializableValue.Value;

            if (_typeManager.DetermineIsTypeSerializedAsReference(expectedType))
            {
                uint referenceId = ReadUInt32();
                _referenceTable.Add(referenceId, value);
            }

            return(value);
        }