public override object InternalExecute(Program program, object argument1) { #if NILPROPOGATION if (argument1 == null) { return(null); } #endif if (argument1 is byte[]) { return(Convert.ToBase64String(((byte[])argument1))); } if (argument1 is StreamID) { Stream stream = program.StreamManager.Open((StreamID)argument1, LockMode.Exclusive); try { byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); return(Convert.ToBase64String(buffer)); } finally { stream.Close(); } } IScalar scalar = (IScalar)DataValue.FromNative(program.ValueManager, Nodes[0].DataType, argument1); if (scalar.IsNative) { return(scalar.AsBase64String); } else { Stream stream = scalar.OpenStream(); try { byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); return(Convert.ToBase64String(buffer)); } finally { stream.Close(); } } }
public override object InternalExecute(Program program, object argument1) { #if NILPROPOGATION if (argument1 == null) { return(null); } #endif if (argument1 is byte[]) { return((long)((byte[])argument1).Length); } if (argument1 is StreamID) { Stream stream = program.StreamManager.Open((StreamID)argument1, LockMode.Exclusive); try { return(stream.Length); } finally { stream.Close(); } } IScalar scalar = (IScalar)DataValue.FromNative(program.ValueManager, Nodes[0].DataType, argument1); if (scalar.IsNative) { return(scalar.AsByteArray.Length); } else { Stream stream = scalar.OpenStream(); try { return(stream.Length); } finally { stream.Close(); } } }