Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/Tizen.Pims.Calendar/Tizen.Pims.Calendar/CalendarRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ public string Uri
/// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
public T Get<T>(uint propertyId)
{
object parsedValue = null;
if (typeof(T) == typeof(string))
{
string val;
Expand All @@ -261,7 +260,7 @@ public T Get<T>(uint propertyId)
Log.Error(Globals.LogTag, $"Get String Failed [{error}]{propertyId:X}");
throw CalendarErrorFactory.GetException(error);
}
parsedValue = Convert.ChangeType(val, typeof(T));
return (T)(object)val;
}
else if (typeof(T) == typeof(int))
{
Expand All @@ -272,7 +271,7 @@ public T Get<T>(uint propertyId)
Log.Error(Globals.LogTag, $"Get Intger Failed [{error}]{propertyId:X}");
throw CalendarErrorFactory.GetException(error);
}
parsedValue = Convert.ChangeType(val, typeof(T));
return (T)(object)val;
}
else if (typeof(T) == typeof(long))
{
Expand All @@ -283,7 +282,7 @@ public T Get<T>(uint propertyId)
Log.Error(Globals.LogTag, $"Get Long Failed [{error}]{propertyId:X}");
throw CalendarErrorFactory.GetException(error);
}
parsedValue = Convert.ChangeType(val, typeof(T));
return (T)(object)val;
}
else if (typeof(T) == typeof(double))
{
Expand All @@ -294,7 +293,7 @@ public T Get<T>(uint propertyId)
Log.Error(Globals.LogTag, $"Get Double Failed [{error}]{propertyId:X}");
throw CalendarErrorFactory.GetException(error);
}
parsedValue = Convert.ChangeType(val, typeof(T));
return (T)(object)val;
}
else if (typeof(T) == typeof(CalendarTime))
{
Expand All @@ -306,14 +305,13 @@ public T Get<T>(uint propertyId)
throw CalendarErrorFactory.GetException(error);
}
CalendarTime val = ConvertIntPtrToCalendarTime(time);
parsedValue = Convert.ChangeType(val, typeof(T));
return (T)(object)val;
}
else
{
Log.Error(Globals.LogTag, "Not supported Data T/ype");
throw CalendarErrorFactory.GetException((int)CalendarError.NotSupported);
}
return (T)parsedValue;
}

/// <summary>
Expand All @@ -329,7 +327,7 @@ public void Set<T>(uint propertyId, T value)
{
if (typeof(T) == typeof(string))
{
string val = Convert.ToString(value);
string val = value as string ?? string.Empty;
int error = Interop.Record.SetString(_recordHandle, propertyId, val);
if (CalendarError.None != (CalendarError)error)
{
Expand All @@ -339,7 +337,7 @@ public void Set<T>(uint propertyId, T value)
}
else if (typeof(T) == typeof(int))
{
int val = Convert.ToInt32(value);
int val = (int)(object)value;
int error = Interop.Record.SetInteger(_recordHandle, propertyId, val);
if (CalendarError.None != (CalendarError)error)
{
Expand All @@ -349,7 +347,7 @@ public void Set<T>(uint propertyId, T value)
}
else if (typeof(T) == typeof(long))
{
long val = Convert.ToInt64(value);
long val = (long)(object)value;
int error = Interop.Record.SetLli(_recordHandle, propertyId, val);
if (CalendarError.None != (CalendarError)error)
{
Expand All @@ -359,7 +357,7 @@ public void Set<T>(uint propertyId, T value)
}
else if (typeof(T) == typeof(double))
{
double val = Convert.ToDouble(value);
double val = (double)(object)value;
int error = Interop.Record.SetDouble(_recordHandle, propertyId, val);
if (CalendarError.None != (CalendarError)error)
{
Expand All @@ -369,7 +367,7 @@ public void Set<T>(uint propertyId, T value)
}
else if (typeof(T) == typeof(CalendarTime))
{
CalendarTime time = (CalendarTime)Convert.ChangeType(value, typeof(CalendarTime));
CalendarTime time = (CalendarTime)(object)value;
//Interop.Record.DateTime val = ConvertCalendarTimeToStruct(time);
IntPtr val = ConvertCalendarTimeToStruct(time);
//int error = Interop.Record.SetCalendarTime(_recordHandle, propertyId, val);
Expand Down
Loading