Exemplo n.º 1
0
        public static void Output(this PropertyValidatorParameterDescriptor pvp, TextWriter writer, int indent = 0)
        {
            string indentChars = new string('\t', indent);

            writer.WriteLine("{0}ParamName={1}, DataType={2}, ParamValue={3}",
                             indentChars,
                             pvp.ParamName,
                             pvp.DataType,
                             pvp.ParamValue);
        }
Exemplo n.º 2
0
        private static PropertyValidatorParameterDescriptor PreparePropertyValidatorParameterDescriptor()
        {
            PropertyValidatorParameterDescriptor propertyValiParaDesp = new PropertyValidatorParameterDescriptor();

            propertyValiParaDesp.DataType   = PropertyDataType.DateTime;
            propertyValiParaDesp.ParamValue = DateTime.Now.ToString("yyyy-MM-dd");
            propertyValiParaDesp.ParamName  = "参数名称";

            return(propertyValiParaDesp);
        }
        internal static PropertyValidatorParameterDescriptor PreparePropertyValidatorParameterDateTimeDescriptor()
        {
            PropertyValidatorParameterDescriptor pvpd = new PropertyValidatorParameterDescriptor();

            pvpd.DataType   = PropertyDataType.DateTime;
            pvpd.ParamName  = "testDateTimeParamName";
            pvpd.ParamValue = System.DateTime.Now.ToString("yyyy-MM-dd");

            return(pvpd);
        }
        internal static PropertyValidatorParameterDescriptor PreparePropertyValidatorParameterIntegerDescriptor()
        {
            PropertyValidatorParameterDescriptor pvpd = new PropertyValidatorParameterDescriptor();

            pvpd.DataType   = PropertyDataType.Integer;
            pvpd.ParamName  = "testIntegerParamName";
            pvpd.ParamValue = "23";

            return(pvpd);
        }
		public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
		{
			PropertyValidatorParameterDescriptor propValiParamDesp = new PropertyValidatorParameterDescriptor();

			propValiParamDesp.ParamName = DictionaryHelper.GetValue(dictionary, "paramName", string.Empty);

			propValiParamDesp.DataType = DictionaryHelper.GetValue(dictionary, "dataType", PropertyDataType.String);

			propValiParamDesp.ParamValue = DictionaryHelper.GetValue(dictionary, "paramValue", string.Empty);

			return propValiParamDesp;
		}
        public void PropertyValidatorParameterDescriptorJSONConverterTest()
        {
            JSONSerializerExecute.RegisterConverter(typeof(PropertyValidatorParameterDescriptorConverter));

            PropertyValidatorParameterDescriptor pvpd = PreparePropertyValidatorParameterDateTimeDescriptor();

            string result = JSONSerializerExecute.Serialize(pvpd);

            Console.WriteLine(result);

            PropertyValidatorParameterDescriptor deserializedDesp = JSONSerializerExecute.Deserialize <PropertyValidatorParameterDescriptor>(result);

            string reSerialized = JSONSerializerExecute.Serialize(deserializedDesp);

            Assert.AreEqual(result, reSerialized);
        }
        public void PropertyValidatorParameterDescriptorSerializeTest()
        {
            PropertyValidatorParameterDescriptor pvpd = PreparePropertyValidatorParameterDateTimeDescriptor();

            XElementFormatter formatter = new XElementFormatter();

            XElement root = formatter.Serialize(pvpd);

            Console.WriteLine(root.ToString());

            PropertyValidatorParameterDescriptor newPropertyValue = (PropertyValidatorParameterDescriptor)formatter.Deserialize(root);

            XElement rootReserialized = formatter.Serialize(newPropertyValue);

            Assert.AreEqual(root.ToString(), rootReserialized.ToString());
            Assert.AreEqual(pvpd.ParamValue, newPropertyValue.ParamValue);
            Assert.AreEqual(pvpd.ParamName, newPropertyValue.ParamName);
            Assert.AreEqual(pvpd.DataType, newPropertyValue.DataType);
        }
		private static PropertyValidatorParameterDescriptor PreparePropertyValidatorParameterDescriptor()
		{
			PropertyValidatorParameterDescriptor propertyValiParaDesp = new PropertyValidatorParameterDescriptor();
			propertyValiParaDesp.DataType = PropertyDataType.DateTime;
			propertyValiParaDesp.ParamValue = DateTime.Now.ToString("yyyy-MM-dd");
			propertyValiParaDesp.ParamName = "参数名称";

			return propertyValiParaDesp;
		}
		internal static PropertyValidatorParameterDescriptor PreparePropertyValidatorParameterDateTimeDescriptor()
		{
			PropertyValidatorParameterDescriptor pvpd = new PropertyValidatorParameterDescriptor();
			pvpd.DataType = PropertyDataType.DateTime;
			pvpd.ParamName = "testDateTimeParamName";
			pvpd.ParamValue = System.DateTime.Now.ToString("yyyy-MM-dd");

			return pvpd;
		}
		internal static PropertyValidatorParameterDescriptor PreparePropertyValidatorParameterIntegerDescriptor()
		{
			PropertyValidatorParameterDescriptor pvpd = new PropertyValidatorParameterDescriptor();
			pvpd.DataType = PropertyDataType.Integer;
			pvpd.ParamName = "testIntegerParamName";
			pvpd.ParamValue = "23";

			return pvpd;
		}