This is an Helper for reading Xml Based columns in a way as a Ado.net Constructor is written
상속: IDataRecord
예제 #1
0
		public void GetValue()
		{
			var xmlSerilizer = new XmlSerializer(typeof (InstanceMock));
			string content = "";
			using (var ms = new MemoryStream())
			{
				xmlSerilizer.Serialize(ms, new InstanceMock());
				content = Encoding.Default.GetString(ms.ToArray());
			}

			var xmlRecord = new XmlDataRecord(content, typeof (InstanceMock).GetClassInfo());
			Assert.AreEqual(xmlRecord.GetValue(0), "NAN");
			Assert.AreEqual(xmlRecord.GetValue(1), 0);
		}
예제 #2
0
        /// <summary>
        ///     This is our standart solution for Seriliation
        ///     takes care of the loader strategy
        /// </summary>
        /// <param name="xmlStream">The XML stream.</param>
        /// <param name="target">The target.</param>
        /// <param name="single">if set to <c>true</c> [single].</param>
        /// <param name="accessLayer">The access layer.</param>
        /// <returns></returns>
        public static XmlDataRecord TryParse(string xmlStream, Type target, bool single, DbConfig accessLayer = null)
        {
            if (string.IsNullOrEmpty(xmlStream) || string.IsNullOrWhiteSpace(xmlStream))
            {
                return(null);
            }
            try
            {
                var xDocument = XDocument.Parse(xmlStream, LoadOptions.None);
                var record    = new XmlDataRecord(xDocument, target, accessLayer);

                if (single)
                {
                    return(record.CreateListOfItems().FirstOrDefault());
                }

                return(record);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #3
0
		/// <summary>
		///     This is our standart solution for Seriliation
		///     takes care of the loader strategy
		/// </summary>
		/// <returns></returns>
		public static XmlDataRecord TryParse(string xmlStream, Type target, bool single, DbConfig accessLayer = null)
		{
			if (string.IsNullOrEmpty(xmlStream) || string.IsNullOrWhiteSpace(xmlStream))
				return null;
			try
			{
				var xDocument = XDocument.Parse(xmlStream, LoadOptions.None);
				var record = new XmlDataRecord(xDocument, target, accessLayer);

				if (single)
				{
					return record.CreateListOfItems().FirstOrDefault();
				}

				return record;
			}
			catch (Exception)
			{
				return null;
			}
		}