/// <summary>
        /// 仅复制目标集合中已有的属性
        /// </summary>
        /// <param name="cpvc"></param>
        /// <param name="pvc"></param>
        public void ClientToServer(IEnumerable<ClientPropertyValue> cpvc, PropertyValueCollection pvc)
        {
            cpvc.NullCheck("cpvc");
            pvc.NullCheck("pvc");

            foreach (ClientPropertyValue cpv in cpvc)
            {
                if (pvc.ContainsKey(cpv.Key))
                    ClientPropertyValueConverter.Instance.ClientToServer(cpv, pvc[cpv.Key]);
            }
        }
        /// <summary>
        /// 仅复制目标集合中已有的属性
        /// </summary>
        /// <param name="cpvc"></param>
        /// <param name="pvc"></param>
        public void ClientToServer(IEnumerable <ClientPropertyValue> cpvc, PropertyValueCollection pvc)
        {
            cpvc.NullCheck("cpvc");
            pvc.NullCheck("pvc");

            foreach (ClientPropertyValue cpv in cpvc)
            {
                if (pvc.ContainsKey(cpv.Key))
                {
                    ClientPropertyValueConverter.Instance.ClientToServer(cpv, pvc[cpv.Key]);
                }
            }
        }
        private static void MergeProperties(PropertyValueCollection properties, Dictionary <string, object> parameters)
        {
            foreach (KeyValuePair <string, object> kp in parameters)
            {
                if (string.Compare(kp.Key, "Key", true) != 0)
                {
                    if (properties.ContainsKey(kp.Key))
                    {
                        PropertyValue pv = properties[kp.Key];

                        pv.StringValue = kp.Value.ToString();
                    }
                }
            }
        }
Пример #4
0
        public void ClientPropertiesToIgnoredServerProperties()
        {
            ClientPropertyValueCollection cpvc = new ClientPropertyValueCollection();

            cpvc.AddOrSetValue("Key", "N0");
            cpvc.AddOrSetValue("Name", "Shen Zheng");
            cpvc.AddOrSetValue("Description", "Shen Zheng's c to s property set");
            cpvc.AddOrSetValue("Enabled", true);
            cpvc.AddOrSetValue("Ignored", true);

            PropertyValueCollection spc = PrepareServerProperties();

            ClientPropertyValueCollectionConverter.Instance.ClientToServer(cpvc, spc);

            OutputServerProperties(spc);

            Assert.AreEqual(cpvc.GetValue("Key", string.Empty), spc.GetValue("Key", string.Empty));
            Assert.AreEqual(cpvc.GetValue("Name", string.Empty), spc.GetValue("Name", string.Empty));
            Assert.AreEqual(cpvc.GetValue("Description", string.Empty), spc.GetValue("Description", string.Empty));
            Assert.AreEqual(cpvc.GetValue("Enabled", false), spc.GetValue("Enabled", false));

            Assert.IsFalse(spc.ContainsKey("Ignored"));
        }