Esempio n. 1
0
            public When_a_table_with_no_rows_is_immediately_followed_by_a_non_empty_one()
            {
                this.dataSet = new DataSet();

                var tableWithNoRows = new DataTable();

                tableWithNoRows.Columns.Add("Something", typeof(DateTime));
                var c = new[]
                {
                    new object[] { "Number", "Letter" },
                    new object[] { 9, "Z" },
                    new object[] { 8, "Y" }
                };

                this.dataSet.Tables.Add(tableWithNoRows);
                this.dataSet.Tables.Add(TestData.FromMatrix(c));

                this.stream = new MemoryStream();
                using (var originalReader = this.dataSet.CreateDataReader())
                {
                    DataSerializer.Serialize(this.stream, originalReader);

                    this.stream.Seek(0, SeekOrigin.Begin);

                    this.reader = DataSerializer.Deserialize(this.stream);
                }
            }
        /// <summary>
        /// Deserializes data from a savegame (or initialises new data structures when none available).
        /// Called by the game on load (including a new game).
        /// </summary>
        public override void OnLoadData()
        {
            base.OnLoadData();

            // Initialise building dictionary.
            BuildingsABLC.levelRanges = new Dictionary <ushort, LevelRange>();

            // Read data from savegame.
            byte[] data = serializableDataManager.LoadData(dataID);

            // Check to see if anything was read.
            if (data != null && data.Length != 0)
            {
                // Data was read - go ahead and deserialise.
                using (MemoryStream stream = new MemoryStream(data))
                {
                    BinaryFormatter formatter = new BinaryFormatter();

                    // Deserialise district arrays.
                    DataSerializer.Deserialize <DistrictSerializer>(stream, DataSerializer.Mode.Memory);

                    // Deserialise building list.
                    DataSerializer.Deserialize <BuildingSerializer>(stream, DataSerializer.Mode.Memory);
                }
            }
            else
            {
                // No data read - initialise empty data structures.
                Logging.Message("no data read");

                // Use the post-deserialisation method of the district data serialiser to populate arrays with defaults.
                new DistrictSerializer().AfterDeserialize(null);
            }
        }
Esempio n. 3
0
            public void TestFixtureSetUp()
            {
                dataSet = new DataSet();

                var tableWithNoRows = new DataTable();

                tableWithNoRows.Columns.Add("Something", typeof(DateTime));
                var c = new[]
                {
                    new object[] { "Number", "Letter" },
                    new object[] { 9, "Z" },
                    new object[] { 8, "Y" }
                };

                dataSet.Tables.Add(tableWithNoRows);
                dataSet.Tables.Add(TestData.FromMatrix(c));

                stream = new MemoryStream();
                using (var originalReader = dataSet.CreateDataReader())
                {
                    DataSerializer.Serialize(stream, originalReader);

                    stream.Seek(0, SeekOrigin.Begin);

                    reader = DataSerializer.Deserialize(stream);
                }
            }
        public override void OnLoadData()
        {
            base.OnLoadData();
            if (ToolManager.instance.m_properties.m_mode != ItemClass.Availability.Game)
            {
                return;
            }

            if (serializableDataManager.EnumerateData().Contains(GROWSTATE_ID))
            {
                var growStateData = serializableDataManager.LoadData(GROWSTATE_ID);
                using (var ms = new MemoryStream(growStateData)) {
                    var s = DataSerializer.Deserialize <GrowState>(ms, DataSerializer.Mode.Memory);
                }
            }

            if (UserMod.IsModEnabled(1873351912UL, "Tree Precision"))
            {
                return;
            }
            if (!serializableDataManager.EnumerateData().Contains(PRECISION_ID))
            {
                return;
            }
            var data = serializableDataManager.LoadData(PRECISION_ID);

            using (var ms = new MemoryStream(data)) {
                var s = DataSerializer.Deserialize <Precision>(ms, DataSerializer.Mode.Memory);
            }
        }
Esempio n. 5
0
        private void OnTileUpdateComplete()
        {
            RacingEvent data;

            if (DataSerializer.Deserialize(out data))
            {
                Dispatcher.BeginInvoke(() =>
                {
                    data.UpdateRemainingTime();

                    App.MainViewModel.Circuit        = data.Country + " " + data.Circuit;
                    App.MainViewModel.Session        = data.Session;
                    App.MainViewModel.EventTimeStamp = data.DownloadTimestamp;
                    App.MainViewModel.EventStartTime = data.SessionStartTime;
                    App.MainViewModel.IsSessionLive  = data.IsSessionLive;

                    TimeSpan left = TimeSpan.FromSeconds(data.RemainingTime);
                    App.MainViewModel.EventStartRemainingTime = left;
                    App.MainViewModel.CounterDays             = left.Days;
                    App.MainViewModel.CounterHours            = left.Hours;
                    App.MainViewModel.CounterMinutes          = left.Minutes;
                    App.MainViewModel.CounterSeconds          = left.Seconds;
                });
            }
        }
Esempio n. 6
0
        /// <summary>Obtain plugin versions supported by Flux</summary>
        /// <returns>List of products and versions currently supported by Flux.</returns>
        /// <exception cref="Exceptions.FluxException">Throws for internal SDK exceptions (Network is down, etc.).</exception>
        /// <exception cref="Exceptions.ConnectionFailureException">Throws if network connection is down.</exception>
        /// <exception cref="Exceptions.ServerUnavailableException">Throws if Flux server is down.</exception>
        /// <exception cref="Exceptions.InternalSDKException">Throws for unhandled SDK exceptions.</exception>
        public PluginVersions GetSupportedVersions()
        {
            log.Info("Getting Supported Versions data");
            var request = HttpWebClientHelper.CreateRequest(sdkMetadata, FluxApiData.EnvUrl, null);

            request.Method = "GET";

            try
            {
                using (var response = HttpWebClientHelper.GetResponse(request))
                {
                    return(DataSerializer.Deserialize <PluginVersions>(StreamUtils.GetDecompressedResponseStream(response)));
                }
            }
            catch (Exceptions.FluxException ex)
            {
                log.Error(ex);
                throw;
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw new Exceptions.InternalSDKException(ex.Message);
            }
        }
        object Deserialize(string name, DataNode node, Type type, DataContext ctx)
        {
            if (type.IsAssignableFrom(typeof(XmlElement)))
            {
                // The xml content is the first child of the data node
                DataItem it = node as DataItem;
                if (it == null || it.ItemData.Count > 1)
                {
                    throw new InvalidOperationException("Can't convert property to an XmlElement object.");
                }
                if (it.ItemData.Count == 0)
                {
                    return(null);
                }
                XmlConfigurationWriter sw  = new XmlConfigurationWriter();
                XmlDocument            doc = new XmlDocument();
                return(sw.Write(doc, it.ItemData [0]));
            }
            if (ctx == null)
            {
                throw new InvalidOperationException("Can't deserialize property '" + name + "'. Serialization context not set.");
            }

            DataSerializer ser = new DataSerializer(ctx);

            ser.SerializationContext.BaseFile = sourceFile;
            object ob = ser.Deserialize(type, node);

            return(ob);
        }
        private bool LoadSkinData()
        {
            Debug.Log("NS: Loading skin data!");

            try
            {
                var data = SimulationManager.instance.m_SerializableDataWrapper.LoadData(DataKey);
                if (data == null)
                {
                    Debug.Log("NS: No data found!");
                    return(false);
                }

                NetworkSkinDataContainer dataContainer;
                using (var stream = new MemoryStream(data))
                {
                    dataContainer = DataSerializer.Deserialize <NetworkSkinDataContainer>(stream, DataSerializer.Mode.Memory, NetworkSkinsMod.ResolveSerializedType);
                }

                _loadErrors = dataContainer.Errors;
            }
            catch (Exception e)
            {
                _loadErrors = new NetworkSkinLoadErrors();
                _loadErrors.MajorException(e);
            }

            return(true);
        }
Esempio n. 9
0
        private void DeserializeActiveOptions()
        {
            var selectedData = serializableDataManager.LoadData(SelectedOptionsId);

            if (selectedData == null)
            {
                Debug.Log("Network Skins: No select options data found!");
                return;
            }

            try
            {
                using (var stream = new MemoryStream(selectedData))
                {
                    DataSerializer.Deserialize <OptionsData>(stream, DataSerializer.Mode.Memory);
                }

                Debug.LogFormat("Network Skins: Selected Options loaded (Data length: {0})", selectedData.Length);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                return;
            }
        }
Esempio n. 10
0
        public static SaveGameMetaData GetMetaDataForDateTime(DateTime needle)
        {
            SaveGameMetaData result = null;

            foreach (Package.Asset current in PackageManager.FilterAssets(new Package.AssetType[]
            {
                UserAssetType.SaveGameMetaData
            }))
            {
                if (current != null && current.isEnabled)
                {
                    SaveGameMetaData saveGameMetaData = current.Instantiate <SaveGameMetaData>();
                    if (saveGameMetaData != null)
                    {
                        try
                        {
                            Stream             s         = saveGameMetaData.assetRef.GetStream();
                            SimulationMetaData mysimmeta = DataSerializer.Deserialize <SimulationMetaData>(s,
                                                                                                           DataSerializer.Mode.File);
                            if (mysimmeta.m_currentDateTime.Equals(needle))
                            {
                                return(saveGameMetaData);
                            }
                        }
                        catch (Exception ex)
                        {
                            ex.ToString();
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 11
0
        /// <summary>
        /// Deserializes data from a savegame (or initialises new data structures when none available).
        /// Called by the game on load (including a new game).
        /// </summary>
        public override void OnLoadData()
        {
            base.OnLoadData();

            // Read data from savegame.
            byte[] data = serializableDataManager.LoadData(dataID);

            // Check to see if anything was read.
            if (data != null && data.Length != 0)
            {
                // Data was read - go ahead and deserialise.
                using (MemoryStream stream = new MemoryStream(data))
                {
                    BinaryFormatter formatter = new BinaryFormatter();

                    // Deserialise savegame settings.
                    DataSerializer.Deserialize <BOBSerializer>(stream, DataSerializer.Mode.Memory);
                    Logging.Message("read ", stream.Length.ToString());
                }
            }
            else
            {
                // No data read.
                Logging.Message("no data read");
            }
        }
Esempio n. 12
0
        public void OnLoadData()
        {
            try
            {
                byte[] data = serializableData.LoadData(DataID);

                if (data == null)
                {
                    Debug.Log(Mod.LogMsgPrefix + "No saved data");
                    return;
                }

                using (var stream = new MemoryStream(data))
                {
                    DataSerializer.Deserialize <DisastersContainer.Data>(stream, DataSerializer.Mode.Memory);

                    DataSerializer.Deserialize <EnhancedForestFire.Data>(stream, DataSerializer.Mode.Memory);
                    DataSerializer.Deserialize <EnhancedThunderstorm.Data>(stream, DataSerializer.Mode.Memory);
                    DataSerializer.Deserialize <EnhancedSinkhole.Data>(stream, DataSerializer.Mode.Memory);
                    DataSerializer.Deserialize <EnhancedTsunami.Data>(stream, DataSerializer.Mode.Memory);
                    DataSerializer.Deserialize <EnhancedTornado.Data>(stream, DataSerializer.Mode.Memory);
                    DataSerializer.Deserialize <EnhancedEarthquake.Data>(stream, DataSerializer.Mode.Memory);
                    DataSerializer.Deserialize <EnhancedMeteorStrike.Data>(stream, DataSerializer.Mode.Memory);
                }
            }
            catch (Exception ex)
            {
                Debug.Log(Mod.LogMsgPrefix + "(load error) " + ex.Message);
            }

            Mod.UpdateUI();
        }
Esempio n. 13
0
        internal static User GetWhoAmI(IEnumerable <FluxCookie> cookies, SDKMetadata sdkMetadata)
        {
            if (cookies == null)
            {
                return(null);
            }

            var authCookie = cookies.FirstOrDefault(el => el.CookieName == FluxApiData.CookiesAuthName);

            if (authCookie == null)
            {
                return(null);
            }

            User user    = null;
            var  request = HttpWebClientHelper.CreateRequest(sdkMetadata, FluxApiData.WhoAmIUrl, cookies.ToList());

            request.Method = "GET";
            using (var response = HttpWebClientHelper.GetResponse(request))
            {
                user = DataSerializer.Deserialize <User>(StreamUtils.GetDecompressedResponseStream(response));
            }

            user.SdkMetadata = sdkMetadata;
            user.Cookies     = cookies.ToList();

            return(user);
        }
Esempio n. 14
0
        /// <summary>Update list of projects for the current user. </summary>
        /// <exception cref="Exceptions.ConnectionFailureException">Throws if network connection is down.</exception>
        /// <exception cref="Exceptions.UnathorizedException">Throws if provided cookies were obsolete.</exception>
        /// <exception cref="Exceptions.ServerUnavailableException">Throws if Flux server is down.</exception>
        /// <exception cref="Exceptions.InternalSDKException">Throws for unhandled SDK exceptions.</exception>
        public void UpdateProjects()
        {
            var projectList = new List <Project>();
            var request     = HttpWebClientHelper.CreateRequest(SdkMetadata, FluxApiData.ProjectsUrl, Cookies);

            request.Method = "GET";
            request.Headers.Add("user", Id);
            try
            {
                using (var response = HttpWebClientHelper.GetResponse(request))
                {
                    projectList = DataSerializer.Deserialize <List <Project> >(StreamUtils.GetDecompressedResponseStream(response));
                }
            }
            catch (Exceptions.FluxException ex)
            {
                log.Error(ex);
                throw;
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw new Exceptions.InternalSDKException(ex.Message);
            }

            Projects = projectList;
        }
Esempio n. 15
0
        public void UpdateAsync()
        {
            RacingEvent newData, oldData;

            if (DataSerializer.Deserialize(out oldData))
            {
                newData = oldData.DeepCopy();
                if (DataChecker.IsUpToDate(newData))
                {
                    if (DataChangeValidator.HasChanged(oldData, newData))
                    {
                        DataSerializer.Serialize(newData);
                        DataComplete(newData, CompletionStatus.Completed);
                    }
                    else
                    {
                        DataComplete(newData, CompletionStatus.NoChange);
                    }

                    return;
                }
            }

            NextEventDataDownloader nextEvent = new NextEventDataDownloader();

            nextEvent.OnDownloadCompleted += nextEvent_OnDownloadCompleted;
            nextEvent.DownloadEventDataAsync();
        }
Esempio n. 16
0
        internal static ScopedPolicy RawDeserialize(DataNode data)
        {
            string scope = null;
            Type   t     = GetRegisteredType(data.Name);

            if (t == null)
            {
                UnknownPolicy up = new UnknownPolicy(data);
                return(new ScopedPolicy(typeof(UnknownPolicy), up, up.Scope));
            }
            bool     allowDiff = false;
            DataItem di        = data as DataItem;

            if (di != null)
            {
                DataValue allowDiffData = di ["allowDiffSerialize"] as DataValue;
                allowDiff = allowDiffData != null && allowDiffData.Value == "True";
                DataValue val = di ["scope"] as DataValue;
                if (val != null)
                {
                    scope = val.Value;
                }
                DataValue inh = di ["inheritsSet"] as DataValue;
                if (inh != null && inh.Value == "null")
                {
                    return(new ScopedPolicy(t, null, scope, allowDiff));
                }
            }
            object o = Serializer.Deserialize(t, data);

            return(new ScopedPolicy(t, o, scope, allowDiff));
        }
Esempio n. 17
0
        public MetadataPart(ImageRow imageRow) : base(imageRow)
        {
            BindModel();

            DataSerializer ds = new DataSerializer();

            SetModel(ds.Deserialize(ImageRow.Body as string));
        }
Esempio n. 18
0
 public static DataModel Load()
 {
     if (File.Exists(filePath))
     {
         return(DataSerializer.Deserialize(filePath));
     }
     return(new DataModel());
 }
Esempio n. 19
0
 protected override void BeginProcessing()
 {
     if (string.IsNullOrEmpty(SettingPath))
     {
         SettingPath = File.Exists(Item.CURRENT_DIR_SETTING) ? Item.CURRENT_DIR_SETTING : Item.PROGRAMDATA_SETTING;
     }
     _setting = DataSerializer.Deserialize <EnumRunSetting>(SettingPath);
 }
Esempio n. 20
0
            public void InvalidXml_ThowsSerializationException()
            {
                //Arrange
                var serializer = new DataSerializer<DataContractTestClass>();

                //Act+Assert
                ActionAssert.Throws<SerializationException>(() => serializer.Deserialize("<int val=\"1\"/>"));
            }
Esempio n. 21
0
        public static void ReadTransportFile(
            [SqlFacet(MaxSize = 255, IsNullable = false)] SqlString fullFileName,
            [SqlFacet(MaxSize = 255, IsNullable = false)] SqlString serverName,
            [SqlFacet(MaxSize = 255, IsNullable = false)] SqlString databaseName,
            [SqlFacet(MaxSize = 255, IsNullable = false)] SqlString tableName,
            [SqlFacet(MaxSize = 255, IsNullable = false)] SqlString userName,
            [SqlFacet(MaxSize = 255, IsNullable = false)] SqlString password)
        {
            if (fullFileName.IsNull)
            {
                throw new ArgumentNullException("fullFileName");
            }
            if (tableName.IsNull)
            {
                throw new ArgumentNullException("serverName");
            }
            if (tableName.IsNull)
            {
                throw new ArgumentNullException("databaseName");
            }
            if (tableName.IsNull)
            {
                throw new ArgumentNullException("tableName");
            }
            if (userName.IsNull)
            {
                throw new ArgumentNullException("userName");
            }
            if (password.IsNull)
            {
                throw new ArgumentNullException("password");
            }

            using (var input = new FileStream(fullFileName.Value, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var      reader   = new OfflineDataPackReader();
                DataPack dataPack = reader.Read(input, "RRTFv6");

                var dataPart = dataPack.DataParts[0];

                var connectionString = string.Format(@"Server={0};Database={1};User Id={2};Password={3};", serverName, databaseName, userName, password);

                using (var partStream = dataPart.GetStream())
                    using (var dataReader = DataSerializer.Deserialize(partStream))
                        using (var connection = new SqlConnection(connectionString))
                        {
                            connection.Open();

                            using (var bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.Default, null))
                            {
                                bulkCopy.DestinationTableName = tableName.Value;
                                bulkCopy.BatchSize            = 500;

                                bulkCopy.WriteToServer(dataReader);
                            }
                        }
            }
        }
 public static List<NetworkSkinModifier> Deserialize(byte[] data, out NetworkSkinLoadErrors errors)
 {
     using (var stream = new MemoryStream(data))
     {
         var dataContainer = DataSerializer.Deserialize<Data>(stream, DataSerializer.Mode.Memory, NetworkSkinsMod.ResolveSerializedType);
         errors = dataContainer.Errors;
         return dataContainer.Modifiers;
     }
 }
Esempio n. 23
0
        public Project ReadProject(XmlReader reader)
        {
            DataNode data    = Read(reader);
            Project  project = (Project)serializer.Deserialize(typeof(Project), data);

            project.FileFormat = MD1ProjectService.FileFormat;
            project.FileName   = serializer.SerializationContext.BaseFile;
            return(project);
        }
Esempio n. 24
0
        internal static T ExtractAuxParams <T>(HttpWebResponse response)
        {
            log.Debug("Extracting aux parameters.");
            var auxHeader  = response.GetResponseHeader(AUX_HEADER);
            var auxJsonStr = string.IsNullOrEmpty(auxHeader) ? null : Utils.DecodeHeader(auxHeader);
            var auxObj     = DataSerializer.Deserialize <T>(auxJsonStr);

            return(auxObj);
        }
Esempio n. 25
0
        public static void ReadObjectProperties(this SlnSection pset, object ob)
        {
            DataSerializer ser = new DataSerializer(solutionDataContext);

            ser.SerializationContext.BaseFile = pset.ParentFile.FileName;
            var data = ReadDataItem(pset);

            ser.Deserialize(ob, data);
        }
Esempio n. 26
0
        public void TestWithIEnumerable()
        {
            var dataToSerialize = new[] { CreateSerializationTestClass(), CreateSerializationTestClass() };

            serializer = new DataSerializer();
            byte[] bytes = serializer.Serialize(dataToSerialize);
            CollectionAssert.AreEqual(dataToSerialize,
                                      serializer.Deserialize <IEnumerable <SerializationTestClass> >(bytes));
        }
Esempio n. 27
0
            public When_advancing_to_the_next_result_set_but_still_in_the_middle_of_the_current_one()
            {
                var a = new[]
                {
                    new object[] { "Number" },
                    new object[] { 0 },
                    new object[] { 1 },
                    new object[] { 2 },
                    new object[] { 3 },
                    new object[] { 4 },
                    new object[] { 5 },
                    new object[] { 6 },
                    new object[] { 7 },
                    new object[] { 8 },
                    new object[] { 9 },
                };

                var b = new[]
                {
                    new object[] { "Letter", "Number" },
                    new object[] { "A", 9 },
                    new object[] { "B", 8 },
                    new object[] { "C", 7 },
                    new object[] { "D", 6 },
                    new object[] { "E", 5 },
                };

                this.dataSet = new DataSet();

                var tableWithNoRows = new DataTable();

                tableWithNoRows.Columns.Add("ColumnA", typeof(Guid));

                var c = new[]
                {
                    new object[] { "Number" },
                    new object[] { 9 },
                    new object[] { 8 }
                };

                this.dataSet.Tables.Add(TestData.FromMatrix(a));
                this.dataSet.Tables.Add(TestData.FromMatrix(b));
                this.dataSet.Tables.Add(tableWithNoRows);
                this.dataSet.Tables.Add(new DataTable());
                this.dataSet.Tables.Add(TestData.FromMatrix(c));

                this.stream = new MemoryStream();
                using (var originalReader = this.dataSet.CreateDataReader())
                {
                    DataSerializer.Serialize(this.stream, originalReader);

                    this.stream.Seek(0, SeekOrigin.Begin);

                    this.reader = DataSerializer.Deserialize(this.stream);
                }
            }
Esempio n. 28
0
            public void TestFixtureSetUp()
            {
                var a = new[]
                {
                    new object[] { "Number" },
                    new object[] { 0 },
                    new object[] { 1 },
                    new object[] { 2 },
                    new object[] { 3 },
                    new object[] { 4 },
                    new object[] { 5 },
                    new object[] { 6 },
                    new object[] { 7 },
                    new object[] { 8 },
                    new object[] { 9 },
                };

                var b = new[]
                {
                    new object[] { "Letter", "Number" },
                    new object[] { "A", 9 },
                    new object[] { "B", 8 },
                    new object[] { "C", 7 },
                    new object[] { "D", 6 },
                    new object[] { "E", 5 },
                };

                dataSet = new DataSet();

                var tableWithNoRows = new DataTable();

                tableWithNoRows.Columns.Add("ColumnA", typeof(Guid));

                var c = new[]
                {
                    new object[] { "Number" },
                    new object[] { 9 },
                    new object[] { 8 }
                };

                dataSet.Tables.Add(TestData.FromMatrix(a));
                dataSet.Tables.Add(TestData.FromMatrix(b));
                dataSet.Tables.Add(tableWithNoRows);
                dataSet.Tables.Add(new DataTable());
                dataSet.Tables.Add(TestData.FromMatrix(c));

                stream = new MemoryStream();
                using (var originalReader = dataSet.CreateDataReader())
                {
                    DataSerializer.Serialize(stream, originalReader);

                    stream.Seek(0, SeekOrigin.Begin);

                    reader = DataSerializer.Deserialize(stream);
                }
            }
Esempio n. 29
0
        static async Task Main(string[] args)
        {
            var config = DataSerializer.Deserialize <Config>();
            var name   = args[0];
            var bot    = new TelegramBotClient(config.BotId);

            await bot.SendTextMessageAsync(
                config.ChatId,
                $"Файл {name} успешно загружен!");
        }
Esempio n. 30
0
        /// <summary>
        /// Update local project
        /// </summary>
        /// <param name="obj"></param>
        public void Push(string obj)
        {
#if DEBUG_ON
            Console.WriteLine("Push request received from server.");
#endif
            try {
                window.ReloadProject(DataSerializer <Project> .Deserialize(obj));
            }
            catch (Exception ex) { new ErrorHandler(ex); }
        }
        public PartiallyResolvedPart(ImageRow imageRow) : base(imageRow)
        {
            ResolveBoundProperties();

            DataSerializer ds = new DataSerializer();

            Model = ds.Deserialize(ImageRow.Body as string);

            //ResolveGeneralProperties(_generalPropertiesLocation);
        }
Esempio n. 32
0
            public void ValidXml_DeserializedCorrectly()
            {
                //Arrange
                var serializer = new DataSerializer<DataContractTestClass>();

                //Act
                DataContractTestClass obj = serializer.Deserialize("<DataContractTestClass xmlns=\"http://schemas.datacontract.org/2004/07/JohnsonControls.Serialization.Xml\"><Value>TestValue</Value></DataContractTestClass>");
                //Note that DataSerializer is very picky about the xmlns being present
                //Assert
                Assert.AreEqual("TestValue",obj.Value);
            }
Esempio n. 33
0
        public void DataContractSerialization_RoundTrip()
        {
            //Arrange
            var serializer = new DataSerializer<DataContractTestClass>();
            var obj = new DataContractTestClass { Value = "DemoValue" };

            //Act
            string xml = serializer.Serialize(obj);
            DataContractTestClass obj2 = serializer.Deserialize(xml);

            //Assert
            Assert.AreEqual(obj.Value, obj2.Value, "Round trip with DataSerializer failed");
        }