csharp-sdk-upm/Storage/Source/Internal/Utilities/AVRelationExtensions.cs

29 lines
1.1 KiB
C#
Raw Normal View History

2019-07-19 15:01:34 +08:00
using System;
using System.Collections.Generic;
namespace LeanCloud.Storage.Internal {
/// <summary>
/// So here's the deal. We have a lot of internal APIs for AVObject, AVUser, etc.
///
/// These cannot be 'internal' anymore if we are fully modularizing things out, because
/// they are no longer a part of the same library, especially as we create things like
/// Installation inside push library.
///
/// So this class contains a bunch of extension methods that can live inside another
/// namespace, which 'wrap' the intenral APIs that already exist.
/// </summary>
public static class AVRelationExtensions {
public static AVRelation<T> Create<T>(AVObject parent, string childKey) where T : AVObject {
return new AVRelation<T>(parent, childKey);
}
public static AVRelation<T> Create<T>(AVObject parent, string childKey, string targetClassName) where T: AVObject {
return new AVRelation<T>(parent, childKey, targetClassName);
}
public static string GetTargetClassName<T>(this AVRelation<T> relation) where T : AVObject {
return relation.TargetClassName;
}
}
}