/// <summary />
        /// <exception cref="InvalidOperationException">Thrown when a resource as not constructed by the SDK.</exception>
        public static T GetOwnerOrThrow <T>(this IServiceResource resource, [CallerMemberName] string callerName = "")
            where T : class
        {
            var owner = resource.Owner as T;

            if (owner != null)
            {
                return(owner);
            }

            var ownerName = typeof(T).Name;

            throw new InvalidOperationException(string.Format($"{callerName} can only be used on instances which were constructed by {ownerName}. Use {ownerName}.{callerName} instead."));
        }
 public PersonService(IServiceResource <TDataConnection> factory) : base(factory)
 {
 }
 public GeneralService()
 {
     controller = new ServiceController();
     resource   = new ServiceResource();
 }
 private void SetOwner(IServiceResource <RackConnectService> resource)
 {
     resource.Owner = this;
 }
Exemple #5
0
 public ServiceBase(IServiceResource <TDataConnection> factory)
 {
     Factory = factory;
 }
 public AccountService(IServiceResource <TDataConnection> factory) : base(factory)
 {
 }
 private void SetOwner(IServiceResource<RackConnectService> resource)
 {
     resource.Owner = this;
 }