{
private IntPtr _filterHandle = IntPtr.Zero;
private bool _disposedValue = false;
+ private ContentCollation _conditionCollate = ContentCollation.Default;
+ private ContentCollation _orderCollate = ContentCollation.Default;
+ private ContentOrder _orderType = ContentOrder.Asc;
+ private string _orderKeyword = null;
+ private string _conditionMsg = null;
internal IntPtr Handle
{
get
{
+ if (_filterHandle == IntPtr.Zero)
+ {
+ throw new ObjectDisposedException(nameof(ContentFilter));
+ }
+
return _filterHandle;
}
}
int offset;
int count;
MediaContentValidator.ThrowIfError(
- Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to get offset");
+ Interop.Filter.GetOffset(Handle, out offset, out count), "Failed to get offset");
return offset;
}
set
{
MediaContentValidator.ThrowIfError(
- Interop.Filter.SetOffset(_filterHandle, value, this.Count), "Failed to set offset");
+ Interop.Filter.SetOffset(Handle, value, this.Count), "Failed to set offset");
}
}
int offset;
int count;
MediaContentValidator.ThrowIfError(
- Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to get count");
+ Interop.Filter.GetOffset(Handle, out offset, out count), "Failed to get count");
return count;
}
set
{
MediaContentValidator.ThrowIfError(
- Interop.Filter.SetOffset(_filterHandle, this.Offset, value), "Failed to set count");
+ Interop.Filter.SetOffset(Handle, this.Offset, value), "Failed to set count");
}
}
{
get
{
- ContentOrder order;
- IntPtr val = IntPtr.Zero;
- ContentCollation collate;
- try
- {
- MediaContentValidator.ThrowIfError(
- Interop.Filter.GetOrder(_filterHandle, out order, out val, out collate), "Failed to get order");
+ return _orderType;
+ }
- return order;
- }
- finally
+ set
+ {
+ if (_orderKeyword != null)
{
- Interop.Libc.Free(val);
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetOrder(Handle, value, _orderKeyword, _orderCollate), "Failed to set order");
}
+
+ _orderType = value;
}
}
/// <summary>
- /// The collate type for comparing two strings
+ /// The search order keyword
/// </summary>
- public ContentCollation CollationType
+ public string OrderKey
{
get
{
+ ContentOrder order;
IntPtr val = IntPtr.Zero;
ContentCollation type;
try
{
MediaContentValidator.ThrowIfError(
- Interop.Filter.GetCondition(_filterHandle, out val, out type), "Failed to get collation");
+ Interop.Filter.GetOrder(Handle, out order, out val, out type), "Failed to GetOrder for OrderKey");
- return type;
+ return Marshal.PtrToStringAnsi(val);
}
finally
{
set
{
MediaContentValidator.ThrowIfError(
- Interop.Filter.SetCondition(_filterHandle, this.Condition, value), "Failed to set collation");
+ Interop.Filter.SetOrder(Handle, _orderType, value, _orderCollate), "Failed to set OrderKey");
+
+ _orderKeyword = value;
+ }
+ }
+
+ /// <summary>
+ /// The collate type for comparing two strings
+ /// </summary>
+ public ContentCollation OrderCollationType
+ {
+ get
+ {
+ return _orderCollate;
+ }
+
+ set
+ {
+ if (_orderKeyword != null)
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetOrder(Handle, _orderType, _orderKeyword, value), "Failed to set collation");
+ }
+
+ _orderCollate = value;
}
}
try
{
MediaContentValidator.ThrowIfError(
- Interop.Filter.GetCondition(_filterHandle, out val, out type), "Failed to get condition");
+ Interop.Filter.GetCondition(Handle, out val, out type), "Failed to get condition");
return Marshal.PtrToStringAnsi(val);
}
set
{
MediaContentValidator.ThrowIfError(
- Interop.Filter.SetCondition(_filterHandle, value, this.CollationType), "Failed to set condition");
+ Interop.Filter.SetCondition(Handle, value, _conditionCollate), "Failed to set condition");
+
+ _conditionMsg = value;
}
}
/// <summary>
- /// Sets the storage id for the given filter.
- /// You can use this property when you want to search items only in the specific storage
+ /// The collate type for comparing two strings
/// </summary>
- public string StorageId
+ public ContentCollation ConditionCollationType
{
get
{
- IntPtr val = IntPtr.Zero;
- try
- {
- MediaContentValidator.ThrowIfError(
- Interop.Filter.GetStorage(_filterHandle, out val), "Failed to get condition");
-
- return Marshal.PtrToStringAnsi(val);
- }
- finally
- {
- Interop.Libc.Free(val);
- }
+ return _conditionCollate;
}
set
{
- MediaContentValidator.ThrowIfError(
- Interop.Filter.SetStorage(_filterHandle, value), "Failed to set condition");
+ if (_conditionMsg != null)
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetCondition(Handle, _conditionMsg, value), "Failed to set collation");
+ }
+
+ _conditionCollate = value;
}
}
/// <summary>
- /// The search order keyword
+ /// Sets the storage id for the given filter.
+ /// You can use this property when you want to search items only in the specific storage
/// </summary>
- public string OrderKey
+ public string StorageId
{
get
{
- ContentOrder order;
IntPtr val = IntPtr.Zero;
- ContentCollation type;
try
{
MediaContentValidator.ThrowIfError(
- Interop.Filter.GetOrder(_filterHandle, out order, out val, out type), "Failed to GetOrder for OrderKey");
+ Interop.Filter.GetStorage(Handle, out val), "Failed to get condition");
return Marshal.PtrToStringAnsi(val);
}
Interop.Libc.Free(val);
}
}
+
+ set
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetStorage(Handle, value), "Failed to set condition");
+ }
}
/// <summary>
public MediaGroupType GroupType { get; set; }
/// <summary>
- /// SetOrderProperties like OrderType and OrderKey.
- /// </summary>
- /// <param name="order">ordering type</param>
- /// <param name="oderKey">Keywords to sort</param>
- public void SetOrderProperties(ContentOrder order, string oderKey)
- {
- MediaContentValidator.ThrowIfError(
- Interop.Filter.SetOrder(_filterHandle, order, oderKey, CollationType), "Failed to set order");
- }
-
-
- /// <summary>
/// Dispose API for closing the internal resources.
/// This function can be used to stop all effects started by Vibrate().
/// </summary>