Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Warning
To use the provided migration method you must not remove the old implementations of the policies prior to following this guide.
- To migrate your custom policies, you should first create a new class with the same methods but inheriting
CheckinPolicyBaseclass (IPolicyCompatibilityJsonforIPolicyCompatibility) instead ofPolicyBase. Examples:
Obsolete
[Serializable]
public class Simple : PolicyBase
{
public override string Description => "SimplePolicyDescription";
...
}
Updated
[Serializable]
public class SimpleNew : CheckinPolicyBase
{
public override string Description => "SimplePolicyDescription";
...
}
- If
GetBinaryFormatterwas overridden, then also implementGetJsonSerializerSettingswith same logic for serialization. Example:
Obsolete
[Serializable]
public class Simple : PolicyBase
{
public override BinaryFormatter GetBinaryFormatter()
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Binder = new SimpleBinder();
return formatter;
}
...
}
Updated
[Serializable]
public class SimpleNew : CheckinPolicyBase
{
public override JsonSerializerSettings GetJsonSerializerSettings()
{
return new JsonSerializerSettings()
{
SerializationBinder = new SimpleNewSerializationBinder(),
TypeNameHandling = TypeNameHandling.Objects
};
}
...
}
- Instead of the old methods like
GetCheckinPoliciesForServerPaths/GetCheckinPolicies/SetCheckinPoliciesnew ones were introduced:GetCheckinClientPoliciesForServerPaths/GetCheckinClientPolicies/SetCheckinClientPoliciesaccordingly. For example, default behavior right now for theLoadPoliciesmethod in the package is to use new policies if they are created/available and obsolete ones in case they are absent.
Note
If you are not planning to use the migration method provided by NuGet package, further instructions can be omitted and obsolete policies can be removed, you are done, congratulations!
- For your obsolete policy add
IPolicyMigration(This interface marked as deprecated only to show that it will be removed as unnecessary together withPolicyBaseandIPolicyCompatibility).
Warning
Obsolete policies that don’t inherit this interface will be skipped during migration and not saved as new policies.
- Implement
ToNewPolicyTypefrom the mentioned interface. It should return the instance of the newly created policy class that is based on currently modified policy. Example:
[Serializable]
public class Simple : PolicyBase, IPolicyMigration
{
...
public CheckinPolicyBase ToNewPolicyType()
{
return new SimpleNew();
}
}
- Call
MigrateFromOldPoliciesmethod.
You are done, congratulations!