public static void Marshal(object value, Stream stream) { Debug.Assert(value != null, "MarshalingManager: value cannot be null"); ITypeMarshaler marshaler = GetMarshaler(value.GetType()); marshaler.MarshalObject(value, stream); }
public static byte[] MarshalObject(this ITypeMarshaler marshaler, object value) { using (MemoryStream memoryStream = new MemoryStream()) { marshaler.MarshalObject(value, memoryStream); return(memoryStream.ToArray()); } }
public void MarshalObject(object value, Stream stream) { Array array = (Array)value; Int32Marshaler.Marshal(array.Length, stream); foreach (object element in array) { _elementMarshaler.MarshalObject(element, stream); } }
public void MarshalObject(object value, Stream stream) { List <UniqueSettings> settings = new List <UniqueSettings>(((IEnumerable)value).Cast <UniqueSettings>()); Int32Marshaler.Marshal(settings.Count(), stream); foreach (UniqueSettings element in settings) { _elementMarshaler.MarshalObject(element, stream); } }
public void MarshalObject(object value, Stream stream) { object underlyingValue = Convert.ChangeType(value, _underlyingMarshaler.ManagedType); _underlyingMarshaler.MarshalObject(underlyingValue, stream); }