internal static object MarshalPropertyValue(PropertyID propertyID, object input) { if (input == null) { return(null); } try { if (propertyID == Property.DATATYPE) { return((short)OpcCom.Interop.GetType((System.Type)input)); } if (propertyID == Property.ACCESSRIGHTS) { switch (((accessRights)input)) { case accessRights.readable: return(1); case accessRights.writable: return(2); case accessRights.readWritable: return(3); } return(null); } if (propertyID == Property.EUTYPE) { switch (((euType)input)) { case euType.noEnum: return(OPCEUTYPE.OPC_NOENUM); case euType.analog: return(OPCEUTYPE.OPC_ANALOG); case euType.enumerated: return(OPCEUTYPE.OPC_ENUMERATED); } return(null); } if (propertyID == Property.QUALITY) { Quality quality = (Quality)input; return(quality.GetCode()); } if (!(propertyID == Property.TIMESTAMP) || (input.GetType() != typeof(DateTime))) { return(input); } DateTime time = (DateTime)input; if (time != DateTime.MinValue) { return(time.ToUniversalTime()); } return(time); } catch { } return(input); }