public void TestSerializeSchemaPropertyValueCollection() { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.MemoryStream ms = new System.IO.MemoryStream(); SchemaPropertyValueCollection obj1 = new SchemaPropertyValueCollection(); SCGroup group = SCObjectGenerator.PrepareGroupObject(); foreach (string key in group.Properties.GetAllKeys()) { obj1.Add(group.Properties[key]); } bf.Serialize(ms, obj1); ms.Seek(0, System.IO.SeekOrigin.Begin); var obj2 = (SchemaPropertyValueCollection)bf.Deserialize(ms); Assert.AreEqual(obj1.Count, obj2.Count); var keys1 = obj1.GetAllKeys(); foreach (var key in keys1) { Assert.IsTrue(obj2.ContainsKey(key)); Assert.AreEqual(obj1[key].StringValue, obj2[key].StringValue); } }
/// <summary> /// 使用指定的<see cref="DESchemaDefine"/>初始化<see cref="SchemaPropertyValueCollection"/>的新实例 /// </summary> /// <returns></returns> public SchemaPropertyValueCollection ToProperties() { SchemaPropertyValueCollection properties = new SchemaPropertyValueCollection(); this.Properties.ForEach(pd => properties.Add(new SchemaPropertyValue(pd))); return(properties); }
/// <summary> /// 使用指定的<see cref="SchemaDefine"/>初始化<see cref="SchemaPropertyValueCollection"/>的新实例 /// </summary> /// <returns></returns> public SchemaPropertyValueCollection ToProperties() { SchemaPropertyValueCollection properties = new SchemaPropertyValueCollection(); this.Properties.ForEach(pd => properties.Add(new SchemaPropertyValue(pd))); return properties; }
private SchemaPropertyValueCollection TabGroup(SchemaPropertyValueCollection propertyValues, string groupName) { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); foreach (var property in propertyValues) { if (property.Definition.Tab == groupName) { result.Add(property); } } return(result); }
public SchemaPropertyValueCollection ToProperties() { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); this.ForEach(p => { SchemaPropertyDefine pd = new SchemaPropertyDefine { Name = p.Name, Description = p.Description, DefaultValue = p.DefaultValue }; result.Add(new SchemaPropertyValue(pd)); }); return(result); }
private SchemaPropertyValueCollection GetCommonValues(SchemaObjectCollection objects, List <SchemaPropertyDefineConfigurationElement> propertyDefines) { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); HashSet <string> pool = new HashSet <string>(); foreach (var item in propertyDefines) { pool.Clear(); SchemaPropertyValue val = null; foreach (var obj in objects) { val = obj.Properties[item.Name]; pool.Add(val.StringValue); } result.Add(pool.Count == 1 ? val : new SchemaPropertyValue(val.Definition)); } return(result); }
private SchemaPropertyValueCollection GetCommonValues(SchemaObjectCollection objects, List<SchemaPropertyDefineConfigurationElement> propertyDefines) { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); HashSet<string> pool = new HashSet<string>(); foreach (var item in propertyDefines) { pool.Clear(); SchemaPropertyValue val = null; foreach (var obj in objects) { val = obj.Properties[item.Name]; pool.Add(val.StringValue); } result.Add(pool.Count == 1 ? val : new SchemaPropertyValue(val.Definition)); } return result; }
private SchemaPropertyValueCollection TabGroup(SchemaPropertyValueCollection propertyValues, string groupName) { SchemaPropertyValueCollection result = new SchemaPropertyValueCollection(); foreach (var property in propertyValues) { if (property.Definition.Tab == groupName) { result.Add(property); } } return result; }