Example #1
0
        public object Deserialize(IFileStream stream)
        {
            var obj = new TType();

            PropertySerializer.Serialize(obj, stream);
            return(obj);
        }
Example #2
0
 public virtual void Serialize(IFileStream stream)
 {
     if (stream.Mode == SerializeMode.Reading)
     {
         PropertySerializer.Serialize(this, stream);
         stream.SerializeValue(ref _objectUnknown);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Example #3
0
        public void TestSerializeReadOnlyWithContinue()
        {
            HaveReadOnly o = new HaveReadOnly();

            o.Value = "a";

            PropertySerializer <HaveReadOnly> ser = new PropertySerializer <HaveReadOnly>("Value", "WriteOnly");

            ser.ContinueOnError = true;
            Assert.AreEqual(true, ser.ContinueOnError);

            ser.Serialize(o, Dictionary);
        }
Example #4
0
        public Task SaveStateCommand(string[] args)
        {
            AppState state = new AppState();

            state.TickerSymbol = service.TickerSymbol;
            state.Shares       = Shares;
            state.Cash         = Cash;

            PropertySerializer.Serialize(state, PropertyFiles.STATE_FILE);

            IO.ShowMessage(Messages.SavedStateFormat, PropertyFiles.STATE_FILE);

            return(Task.CompletedTask);
        }
Example #5
0
        public void TestDeserializeReadOnly()
        {
            HaveReadOnly o = new HaveReadOnly();

            o.Value = "a";

            PropertySerializer <HaveReadOnly> ser = new PropertySerializer <HaveReadOnly>("Value", "ReadOnly");

            ser.ContinueOnError = false;
            Assert.AreEqual(false, ser.ContinueOnError);

            ser.Serialize(o, Dictionary);

            HaveReadOnly test = new HaveReadOnly();

            ser.Deserialize(test, Dictionary);            //should go boom

            Assert.Fail();
        }
Example #6
0
        public void TestSerialize()
        {
            PropertySerializer ser = new PropertySerializer(typeof(TestValues1), ValueNames);

            ser.ContinueOnError = false;
            Assert.AreEqual(false, ser.ContinueOnError);

            ser.Serialize(ValuesA, Dictionary);

            TestValues test = new TestValues();

            ser.Deserialize(test, Dictionary);

            Assert.AreEqual(ValuesA._bool, test._bool);
            Assert.AreEqual(ValuesA._byte, test._byte);
            Assert.AreEqual(ValuesA._char, test._char);
            Assert.AreEqual(ValuesA._DateTime, test._DateTime);
            Assert.AreEqual(ValuesA._decimal, test._decimal);
            Assert.AreEqual(ValuesA._double, test._double);
            Assert.AreEqual(ValuesA._float, test._float);
            Assert.AreEqual(ValuesA._Guid, test._Guid);
            Assert.AreEqual(ValuesA._int, test._int);
            Assert.AreEqual(ValuesA._long, test._long);
            Assert.AreEqual(ValuesA._sbyte, test._sbyte);
            Assert.AreEqual(ValuesA._short, test._short);
            Assert.AreEqual(ValuesA._string, test._string);
            Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan);
            Assert.AreEqual(ValuesA._uint, test._uint);
            Assert.AreEqual(ValuesA._ulong, test._ulong);
            Assert.AreEqual(ValuesA._Uri, test._Uri);
            Assert.AreEqual(ValuesA._ushort, test._ushort);
            Assert.AreEqual(ValuesA._Version, test._Version);

            //ROK - note, it can not deserialize this since it does not know the type:
            Assert.AreEqual(null, test._object);
        }
Example #7
0
 public virtual void Serialize(IFileStream stream)
 {
     PropertySerializer.Serialize(this, stream);
     stream.SerializeValue(ref this.CObjectUnknown0);
 }
        public void TestSerializeShouldSerializeName()
        {
            var result = _serializer.Serialize(_name, new object());

            Assert.That(result.Name.LocalName, Is.EqualTo(_name));
        }
Example #9
0
 public void Serialize(IFileStream stream)
 {
     PropertySerializer.Serialize(this, stream);
 }
		public void TestSerializeReadOnlyWithContinue()
		{
			HaveReadOnly o = new HaveReadOnly();
			o.Value = "a";

			PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>("Value", "WriteOnly");
			ser.ContinueOnError = true;
			Assert.AreEqual(true, ser.ContinueOnError);

			ser.Serialize(o, Dictionary);
		}
		public void TestDeserializeReadOnly()
		{
			HaveReadOnly o = new HaveReadOnly();
			o.Value = "a";

			PropertySerializer<HaveReadOnly> ser = new PropertySerializer<HaveReadOnly>("Value", "ReadOnly");
			ser.ContinueOnError = false;
			Assert.AreEqual(false, ser.ContinueOnError);

			ser.Serialize(o, Dictionary);

			HaveReadOnly test = new HaveReadOnly();
			ser.Deserialize(test, Dictionary);//should go boom

			Assert.Fail();
		}
		public void TestSerialize()
		{
			PropertySerializer ser = new PropertySerializer(typeof(TestValues1), ValueNames);
			ser.ContinueOnError = false;
			Assert.AreEqual(false, ser.ContinueOnError);

			ser.Serialize(ValuesA, Dictionary);

			TestValues test = new TestValues();
			ser.Deserialize(test, Dictionary);

			Assert.AreEqual(ValuesA._bool, test._bool);
			Assert.AreEqual(ValuesA._byte, test._byte);
			Assert.AreEqual(ValuesA._char, test._char);
			Assert.AreEqual(ValuesA._DateTime, test._DateTime);
			Assert.AreEqual(ValuesA._decimal, test._decimal);
			Assert.AreEqual(ValuesA._double, test._double);
			Assert.AreEqual(ValuesA._float, test._float);
			Assert.AreEqual(ValuesA._Guid, test._Guid);
			Assert.AreEqual(ValuesA._int, test._int);
			Assert.AreEqual(ValuesA._long, test._long);
			Assert.AreEqual(ValuesA._sbyte, test._sbyte);
			Assert.AreEqual(ValuesA._short, test._short);
			Assert.AreEqual(ValuesA._string, test._string);
			Assert.AreEqual(ValuesA._TimeSpan, test._TimeSpan);
			Assert.AreEqual(ValuesA._uint, test._uint);
			Assert.AreEqual(ValuesA._ulong, test._ulong);
			Assert.AreEqual(ValuesA._Uri, test._Uri);
			Assert.AreEqual(ValuesA._ushort, test._ushort);
			Assert.AreEqual(ValuesA._Version, test._Version);

			//ROK - note, it can not deserialize this since it does not know the type:
			Assert.AreEqual(null, test._object);
		}
Example #13
0
        public void Serialize_SerializesName()
        {
            var sampleProperty = GetPropertyDefinition((ClassWithAllDataTypes _) => _.StringProperty);
            var actual         = _propertySerializer.Serialize(sampleProperty, _rdbmsPersistenceModelProviderStub);

            Assert.That(actual.Attributes().Select(a => a.Name.LocalName), Contains.Item("name"));
            Assert.That(
                actual.Attribute("name").Value,
                Is.EqualTo("Remotion.Data.DomainObjects.UnitTests.Persistence.Rdbms.SchemaGenerationTestDomain.ClassWithAllDataTypes.StringProperty"));
        }