internal void AssignToOCRepPayload(IntPtr ocRepPayloadHandle) { foreach (var property in this) { bool ok = false; if (property.Value == null) { ok = OCPayloadInterop.OCRepPayloadSetNull(ocRepPayloadHandle, property.Key); } else if (property.Value is bool) { ok = OCPayloadInterop.OCRepPayloadSetPropBool(ocRepPayloadHandle, property.Key, (bool)property.Value); } else if (property.Value is double) { ok = OCPayloadInterop.OCRepPayloadSetPropDouble(ocRepPayloadHandle, property.Key, (double)property.Value); } else if (property.Value is long) { ok = OCPayloadInterop.OCRepPayloadSetPropInt(ocRepPayloadHandle, property.Key, (long)property.Value); } else if (property.Value is string) { ok = OCPayloadInterop.OCRepPayloadSetPropString(ocRepPayloadHandle, property.Key, (string)property.Value); } else if (property.Value is double[]) { var value = (double[])property.Value; ok = OCPayloadInterop.OCRepPayloadSetDoubleArray(ocRepPayloadHandle, property.Key, value, new UIntPtr[] { (UIntPtr)value.Length }); } else if (property.Value is long[]) { var value = (long[])property.Value; ok = OCPayloadInterop.OCRepPayloadSetIntArray(ocRepPayloadHandle, property.Key, value, new UIntPtr[] { (UIntPtr)value.Length }); } else if (property.Value is bool[]) { var value = (bool[])property.Value; ok = OCPayloadInterop.OCRepPayloadSetBoolArray(ocRepPayloadHandle, property.Key, value, new UIntPtr[] { (UIntPtr)value.Length }); } else { throw new NotSupportedException("Property Type for key '" + property.Key + "' of type " + property.Value.GetType().FullName + " not supported"); } if (!ok) { throw new InvalidOperationException($"Failed to assigning property '{property.Key}' to payload"); } } }
public bool SetProperty(string name, bool value) { return(OCPayloadInterop.OCRepPayloadSetPropBool(Handle, name, value)); }