NHibernate.Lob.XlobType.GetData C# (CSharp) Method

GetData() protected method

protected GetData ( object value ) : object
value object
return object
		protected override object GetData(object value)
		{
			Xlob xlob = value as Xlob;
			if (xlob == null) return null;
			if (compression == null)
			{
				if (xlob.Equals(Xlob.Empty)) return "";
				StringXlob sx = xlob as StringXlob;
				if (sx != null) return sx.XmlFragment;
				using (StringWriter sw = new StringWriter())
				{
					xlob.WriteTo(sw);
					return sw.ToString();
				}
			}
			else
			{
				CompressedXlob cx = xlob as CompressedXlob;
				if (cx != null && cx.Compression.Equals(compression)) return cx.Data;
				using (MemoryStream data = new MemoryStream())
				{
					using (XmlWriter xw = compression.GetCompressor(data))
						xlob.WriteTo(xw);
					return data.ToArray();
				}
			}
		}