Exemplo n.º 1
0
        /// <inheritdoc/>
        public virtual void OnAfterDeserialize(KeyDataStore dataStore)
        {
            var contentRoots = dataStore.GetData(k_HostingServiceContentRootKey, string.Empty);

            HostingServiceContentRoots.AddRange(contentRoots.Split(';'));
            WasEnabled      = dataStore.GetData(k_IsHostingServiceRunningKey, false);
            DescriptiveName = dataStore.GetDataString(k_DescriptiveNameKey, string.Empty);
            InstanceId      = dataStore.GetData(k_InstanceIdKey, -1);
        }
Exemplo n.º 2
0
        public void OnBeforeSerializeShould_PersistExpectedDataToKeyDataStore()
        {
            var data = new KeyDataStore();

            m_Service.DescriptiveName = "Testing 123";
            m_Service.InstanceId      = 123;
            m_Service.HostingServiceContentRoots.Clear();
            m_Service.HostingServiceContentRoots.AddRange(new[] { "/test123", "/test456" });
            m_Service.OnBeforeSerialize(data);
            Assert.AreEqual("Testing 123", data.GetData("DescriptiveName", string.Empty));
            Assert.AreEqual(123, data.GetData("InstanceId", 0));
            Assert.AreEqual("/test123;/test456", data.GetData("ContentRoot", string.Empty));
        }
Exemplo n.º 3
0
        public void SerializeComplexType()
        {
            var store = new KeyDataStore();
            var obj   = new CustomTestClass2 {
                floatValue = 3.14f, intValue = 7, name = "test object", objectValue = new CustomTestClass1 {
                    name = "sub object", intValue = 14, floatValue = .99999f
                }
            };

            obj.listValue = new List <CustomTestClass1> {
                new CustomTestClass1 {
                    name = "list item 1", intValue = 33, floatValue = .234534f
                }
            };
            store.SetData("obj", obj);
            store.OnBeforeSerialize();
            store.OnAfterDeserialize();
            var v = store.GetData <CustomTestClass2>("obj", null);

            Assert.AreEqual(obj.name, v.name);
            Assert.AreEqual(obj.intValue, v.intValue);
            Assert.AreEqual(obj.floatValue, v.floatValue);
            Assert.AreEqual(v.objectValue.name, obj.objectValue.name);
            Assert.AreEqual(v.objectValue.intValue, obj.objectValue.intValue);
            Assert.AreEqual(v.objectValue.floatValue, obj.objectValue.floatValue);
            Assert.AreEqual(v.listValue[0].name, obj.listValue[0].name);
            Assert.AreEqual(v.listValue[0].intValue, obj.listValue[0].intValue);
            Assert.AreEqual(v.listValue[0].floatValue, obj.listValue[0].floatValue);
        }
        public void OnBeforeSerializeShould_PersistExpectedDataToKeyDataStore()
        {
            m_Service.StartHostingService();
            var port = m_Service.HostingServicePort;
            var data = new KeyDataStore();

            m_Service.OnBeforeSerialize(data);
            Assert.AreEqual(port, data.GetData("HostingServicePort", 0));
        }
        public void OnBeforeSerializeShould_WasEnableCorrectToKeyDataStore()
        {
            m_Service.StartHostingService();
            var data = new KeyDataStore();

            m_Service.OnDisable();
            m_Service.OnBeforeSerialize(data);
            Assert.IsTrue(data.GetData("IsEnabled", false), "Hosting server was started before shutting down. IsEnabled expected to be true");
        }
Exemplo n.º 6
0
        public void Serialize <T>(T val)
        {
            var store = new KeyDataStore();

            store.SetData("key", val);
            store.OnBeforeSerialize();
            store.OnAfterDeserialize();
            var v = store.GetData("key", default(T));

            Assert.AreEqual(val, v);
        }
Exemplo n.º 7
0
 /// <inheritdoc/>
 public override void OnAfterDeserialize(KeyDataStore dataStore)
 {
     HostingServicePort = dataStore.GetData(k_HostingServicePortKey, 0);
     base.OnAfterDeserialize(dataStore);
 }
 public override void OnAfterDeserialize(KeyDataStore dataStore)
 {
     InstanceId = dataStore.GetData(BaseHostingService.k_InstanceIdKey, -1);
 }