Skip to content

Commit

Permalink
Fix whitespace issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Oct 6, 2016
1 parent 6bf6655 commit 8aec775
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 303 deletions.
56 changes: 28 additions & 28 deletions Realm.Shared/Dynamic/DynamicRealmObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,35 @@ internal class DynamicRealmObjectHelper : IRealmObjectHelper
{
internal static readonly DynamicRealmObjectHelper Instance = new DynamicRealmObjectHelper();

public void CopyToRealm(RealmObject instance)
{
foreach (var property in instance.ObjectSchema)
{
var field = property.PropertyInfo.DeclaringType.GetField(
property.PropertyInfo.GetCustomAttribute<WovenPropertyAttribute>().BackingFieldName,
BindingFlags.Instance | BindingFlags.NonPublic
);
var value = field?.GetValue(this);
if (value != null)
{
var listValue = value as IEnumerable<RealmObject>;
if (listValue != null) // assume it is IList NOT a RealmList so need to wipe afer copy
{
// cope with ReplaceListGetter creating a getter which assumes
// a backing field for a managed IList is already a RealmList, so null it first
field.SetValue(this, null); // now getter will create a RealmList below
var realmList = (ICopyValuesFrom)property.PropertyInfo.GetValue(this, null);
realmList.CopyValuesFrom(listValue);
}
else
{
property.PropertyInfo.SetValue(this, value, null);
}
} // only null if blank relationship or string so leave as default
}
}
public void CopyToRealm(RealmObject instance)
{
foreach (var property in instance.ObjectSchema)
{
var field = property.PropertyInfo.DeclaringType.GetField(
property.PropertyInfo.GetCustomAttribute<WovenPropertyAttribute>().BackingFieldName,
BindingFlags.Instance | BindingFlags.NonPublic
);
var value = field?.GetValue(this);
if (value != null)
{
var listValue = value as IEnumerable<RealmObject>;
if (listValue != null) // assume it is IList NOT a RealmList so need to wipe afer copy
{
// cope with ReplaceListGetter creating a getter which assumes
// a backing field for a managed IList is already a RealmList, so null it first
field.SetValue(this, null); // now getter will create a RealmList below
var realmList = (ICopyValuesFrom)property.PropertyInfo.GetValue(this, null);
realmList.CopyValuesFrom(listValue);
}
else
{
property.PropertyInfo.SetValue(this, value, null);
}
} // only null if blank relationship or string so leave as default
}
}

public RealmObject CreateInstance()
public RealmObject CreateInstance()
{
return new DynamicRealmObject();
}
Expand Down
2 changes: 1 addition & 1 deletion Realm.Shared/ICopyValuesFrom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Realms
{

// Interface allows us to cast a generic RealmList to this and invoke CopyValuesFrom
public interface ICopyValuesFrom
public interface ICopyValuesFrom
{
void CopyValuesFrom(IEnumerable<RealmObject> values);
}
Expand Down
8 changes: 4 additions & 4 deletions Realm.Shared/RealmList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ private void ManageObjectIfNeeded(T obj)

void ICopyValuesFrom.CopyValuesFrom(IEnumerable<RealmObject> values)
{
if (values == null)
{
return;
}
if (values == null)
{
return;
}

foreach (var item in values.Cast<T>())
{
Expand Down
2 changes: 1 addition & 1 deletion Realm.Shared/RealmObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal class Metadata
internal void _CopyDataFromBackingFieldsToRow()
{
Debug.Assert(this.IsManaged);
_metadata.Helper.CopyToRealm(this);
_metadata.Helper.CopyToRealm(this);
}

#region Getters
Expand Down
2 changes: 1 addition & 1 deletion Realm.Shared/weaving/IRealmObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public interface IRealmObjectHelper
{
RealmObject CreateInstance();

void CopyToRealm(RealmObject instance);
void CopyToRealm(RealmObject instance);
}
}
Loading

0 comments on commit 8aec775

Please sign in to comment.