GetRealmPath() 공개 정적인 메소드

public static GetRealmPath ( User user, Uri serverUri ) : string
user User
serverUri System.Uri
리턴 string
예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SyncConfiguration"/> class.
        /// </summary>
        /// <param name="user">
        /// A valid <see cref="User"/>. If not provided, the currently logged-in user will be used.
        /// </param>
        /// <param name="serverUri">
        /// A unique <see cref="Uri"/> that identifies the Realm. In URIs, <c>~</c> can be used as a placeholder for a user Id.
        /// If a relative Uri is provided, it will be resolved using the user's <see cref="ServerUri"/> as baseUri.
        /// If <c>null</c> is passed, a Uri will be constructed from the user's <see cref="ServerUri"/>, combined with
        /// <c>/default</c> and <see cref="IsPartial"/> will be set to <c>true</c>.
        /// </param>
        /// <param name="optionalPath">
        /// Path to the realm, must be a valid full path for the current platform, relative subdirectory, or just filename.
        /// </param>
        public SyncConfiguration(User user = null, Uri serverUri = null, string optionalPath = null)
        {
            Argument.Ensure(user != null || User.AllLoggedIn.Length == 1,
                            "The user must be explicitly specified when the number of logged-in users is not 1.",
                            nameof(user));

            User = user ?? User.Current;
            if (serverUri == null)
            {
                // Using default realm
                IsPartial = true;
                ServerUri = User.GetUriForRealm("/default");
            }
            else if (!serverUri.IsAbsoluteUri)
            {
                ServerUri = User.GetUriForRealm(serverUri);
            }
            else
            {
                Argument.Ensure(serverUri.Scheme.StartsWith("realm"), "Unexpected protocol for server url. Expected realm:// or realms://.", nameof(serverUri));
                ServerUri = serverUri;
            }

            DatabasePath = GetPathToRealm(optionalPath ?? SharedRealmHandleExtensions.GetRealmPath(User, ServerUri));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SyncConfiguration"/> class.
        /// </summary>
        /// <param name="user">A valid <see cref="User"/>.</param>
        /// <param name="serverUri">
        /// A unique <see cref="Uri"/> that identifies the Realm. In URIs, <c>~</c> can be used as a placeholder for a user Id.
        /// </param>
        /// <param name="optionalPath">
        /// Path to the realm, must be a valid full path for the current platform, relative subdirectory, or just filename.
        /// </param>
        public SyncConfiguration(User user, Uri serverUri, string optionalPath = null)
            : base(optionalPath ?? SharedRealmHandleExtensions.GetRealmPath(user, serverUri))
        {
            Argument.NotNull(user, nameof(user));
            Argument.NotNull(serverUri, nameof(serverUri));
            Argument.Ensure(serverUri.Scheme.StartsWith("realm"), "Unexpected protocol for server url. Expected realm:// or realms://.", nameof(serverUri));

            User      = user ?? throw new ArgumentNullException(nameof(user));
            ServerUri = serverUri ?? throw new ArgumentNullException(nameof(serverUri));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SyncConfiguration"/> class.
        /// </summary>
        /// <param name="user">A valid <see cref="User"/>.</param>
        /// <param name="serverUri">A unique <see cref="Uri"/> that identifies the Realm. In URIs, <c>~</c> can be used as a placeholder for a user Id.</param>
        /// <param name="optionalPath">Path to the realm, must be a valid full path for the current platform, relative subdirectory, or just filename.</param>
        public SyncConfiguration(User user, Uri serverUri, string optionalPath = null) : base(optionalPath ?? SharedRealmHandleExtensions.GetRealmPath(user, serverUri))
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            if (serverUri == null)
            {
                throw new ArgumentNullException(nameof(serverUri));
            }

            User      = user;
            ServerUri = serverUri;
        }