/// <summary>
 /// Constructs a new <see cref="SerializationTypeMap"/>
 /// </summary>
 /// <param name="context"></param>
 /// <param name="surrogateSelector"></param>
 public SerializationTypeMap(FudgeContext context, FudgeSurrogateSelector surrogateSelector)
 {
     this.context             = context;
     this.surrogateSelector   = surrogateSelector;
     this.AllowTypeDiscovery  = (bool)context.GetProperty(ContextProperties.AllowTypeDiscoveryProperty, true);
     this.FieldNameConvention = (FudgeFieldNameConvention)context.GetProperty(ContextProperties.FieldNameConventionProperty, FudgeFieldNameConvention.Identity);
     RegisterSurrogateSelector((ISurrogateSelector)context.GetProperty(ContextProperties.DotNetSurrogateSelectorProperty));
 }
Esempio n. 2
0
 /// <summary>
 /// Constructs a new <see cref="SerializationTypeMap"/>
 /// </summary>
 /// <param name="context"></param>
 public SerializationTypeMap(FudgeContext context)
 {
     this.context = context;
     this.surrogateSelector = new FudgeSurrogateSelector(context);
     this.AllowTypeDiscovery = (bool)context.GetProperty(ContextProperties.AllowTypeDiscoveryProperty, true);
     this.FieldNameConvention = (FudgeFieldNameConvention)context.GetProperty(ContextProperties.FieldNameConventionProperty, FudgeFieldNameConvention.Identity);
     RegisterSurrogateSelector((ISurrogateSelector)context.GetProperty(ContextProperties.DotNetSurrogateSelectorProperty));
 }
Esempio n. 3
0
        public void PropertiesCreatedAfterContext()
        {
            var context = new FudgeContext();

            var newProp = new FudgeContextProperty("NewProp");

            Assert.Null(context.GetProperty(newProp));
            context.SetProperty(newProp, "test");
            Assert.Equal("test", context.GetProperty(newProp));
        }
Esempio n. 4
0
        public void BasicPropertyTest()
        {
            var myProp  = new FudgeContextProperty("SomeProp");
            var context = new FudgeContext();

            Assert.Null(context.GetProperty(myProp));
            Assert.Equal(12, context.GetProperty(myProp, 12));

            context.SetProperty(myProp, 17);

            Assert.Equal(17, context.GetProperty(myProp));
            Assert.Equal(17, context.GetProperty(myProp, 12));
        }
Esempio n. 5
0
        /// <summary>
        /// Constructs a new instance.
        /// </summary>
        /// <param name="context">Context for the writer.</param>
        /// <param name="writer"><see cref="TextWriter"/> to receive the output.</param>
        public FudgeJSONStreamWriter(FudgeContext context, TextWriter writer)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            if (writer == null)
                throw new ArgumentNullException("writer");

            this.context = context;
            this.writer = writer;
            this.settings = (JSONSettings)context.GetProperty(JSONSettings.JSONSettingsProperty) ?? new JSONSettings();
        }
        /// <summary>
        /// Constructs a new <c>FudgeXmlStreamWriter</c>, outputting to a given <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="context">Context to control behaviours.</param>
        /// <param name="writer"><see cref="XmlWriter"/> to use to output XML.</param>
        /// <param name="outerElementName">The name of the XML element used for outermost messages.</param>
        public FudgeXmlStreamWriter(FudgeContext context, XmlWriter writer, string outerElementName)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            if (writer == null)
                throw new ArgumentNullException("writer");
            if (outerElementName == null)
                throw new ArgumentNullException("outerElementName");

            this.context = context;
            this.writer = writer;
            this.outerElementName = outerElementName;
            this.AutoFlushOnMessageEnd = (bool)context.GetProperty(AutoFlushOnMessageEndProperty, true);
        }
Esempio n. 7
0
        /// <summary>
        /// Constructs a new <see cref="FudgeSerializer"/> instance.
        /// </summary>
        /// <param name="context"><see cref="FudgeContext"/> for the serializer.</param>
        /// <param name="typeMap">Typemap to use rather than creating a default one.</param>
        public FudgeSerializer(FudgeContext context, SerializationTypeMap typeMap)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (typeMap == null)
            {
                // REVIEW 2010-02-02 t0rx -- Have serialization type map as context property?
                typeMap = new SerializationTypeMap(context);
            }

            this.context = context;
            this.typeMap = typeMap;

            this.TypeMappingStrategy = (IFudgeTypeMappingStrategy)context.GetProperty(ContextProperties.TypeMappingStrategyProperty, new DefaultTypeMappingStrategy());
        }
        /// <summary>
        /// Constructs a new <c>FudgeXmlStreamWriter</c>, outputting to a given <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="context">Context to control behaviours.</param>
        /// <param name="writer"><see cref="XmlWriter"/> to use to output XML.</param>
        /// <param name="outerElementName">The name of the XML element used for outermost messages.</param>
        public FudgeXmlStreamWriter(FudgeContext context, XmlWriter writer, string outerElementName)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (outerElementName == null)
            {
                throw new ArgumentNullException("outerElementName");
            }

            this.context               = context;
            this.writer                = writer;
            this.outerElementName      = outerElementName;
            this.AutoFlushOnMessageEnd = (bool)context.GetProperty(AutoFlushOnMessageEndProperty, true);
        }
Esempio n. 9
0
        public void PropertiesCreatedAfterContext()
        {
            var context = new FudgeContext();

            var newProp = new FudgeContextProperty("NewProp");

            Assert.Null(context.GetProperty(newProp));
            context.SetProperty(newProp, "test");
            Assert.Equal("test", context.GetProperty(newProp));
        }
Esempio n. 10
0
        public void BasicPropertyTest()
        {
            var myProp = new FudgeContextProperty("SomeProp");
            var context = new FudgeContext();

            Assert.Null(context.GetProperty(myProp));
            Assert.Equal(12, context.GetProperty(myProp, 12));

            context.SetProperty(myProp, 17);

            Assert.Equal(17, context.GetProperty(myProp));
            Assert.Equal(17, context.GetProperty(myProp, 12));
        }