Example #1
0
 /// <summary>
 /// Creates an instance of PlayServicesSupport.  This instance is
 /// used to add dependencies for the calling client and invoke the resolution.
 /// </summary>
 /// <returns>The instance.</returns>
 /// <param name="clientName">Client name.  Must be a valid filename.
 /// This is used to uniquely identify
 /// the calling client so that dependencies can be associated with a specific
 /// client to help in resetting dependencies.</param>
 /// <param name="sdkPath">Sdk path for Android SDK (unused).</param>
 /// <param name="settingsDirectory">This parameter is obsolete.</param>
 /// <param name="logger">Delegate used to write messages to the log.</param>
 /// <param name="logMessageWithLevel">Delegate used to write messages to the log.  If
 /// this is specified "logger" is ignored.</param>
 public static PlayServicesSupport CreateInstance(
     string clientName, string sdkPath, string settingsDirectory,
     LogMessage logger = null, LogMessageWithLevel logMessageWithLevel = null)
 {
     return(CreateInstance(clientName, sdkPath, null, settingsDirectory, logger: logger,
                           logMessageWithLevel: logMessageWithLevel));
 }
        /// <summary>
        /// Creates an instance of PlayServicesSupport.  This instance is
        /// used to add dependencies for the calling client and invoke the resolution.
        /// </summary>
        /// <returns>The instance.</returns>
        /// <param name="clientName">Client name.  Must be a valid filename.
        /// This is used to uniquely identify
        /// the calling client so that dependencies can be associated with a specific
        /// client to help in resetting dependencies.</param>
        /// <param name="sdkPath">Sdk path for Android SDK.</param>
        /// <param name="additionalRepositories">Array of additional repository paths. can be
        /// null</param>
        /// <param name="settingsDirectory">This parameter is obsolete.</param>
        /// <param name="logger">Delegate used to write messages to the log.</param>
        /// <param name="logMessageWithLevel">Delegate used to write messages to the log.  If
        /// this is specified "logger" is ignored.</param>
        internal static PlayServicesSupport CreateInstance(
            string clientName, string sdkPath, string[] additionalRepositories,
            string settingsDirectory, LogMessage logger = null,
            LogMessageWithLevel logMessageWithLevel     = null)
        {
            PlayServicesSupport instance     = new PlayServicesSupport();
            LogMessageWithLevel legacyLogger = (string message, LogLevel level) => {
                if (logger != null)
                {
                    logger(message);
                }
            };

            PlayServicesSupport.logger =
                PlayServicesSupport.logger ?? (logMessageWithLevel ??
                                               (logger != null ? legacyLogger : null));
            // Only set the SDK path if it differs to what is configured in the editor or
            // via an environment variable.  The SDK path can be changed by the user before
            // this module is reloaded.
            if (!String.IsNullOrEmpty(sdkPath) && sdkPath != PlayServicesSupport.SDKInternal)
            {
                PlayServicesSupport.userSdkPath = sdkPath;
            }
            string badchars = new string(Path.GetInvalidFileNameChars());

            foreach (char ch in clientName)
            {
                if (badchars.IndexOf(ch) >= 0)
                {
                    throw new Exception("Invalid clientName: " + clientName);
                }
            }

            instance.clientName = clientName;

            var repoPaths = new List <string>();

            repoPaths.AddRange(additionalRepositories ?? new string[] {});
            // Add the standard repo paths from the Android SDK
            string sdkExtrasDir = Path.Combine(SdkVariable, "extras");

            repoPaths.AddRange(
                new string [] {
                Path.Combine(sdkExtrasDir, Path.Combine("android", "m2repository")),
                Path.Combine(sdkExtrasDir, Path.Combine("google", "m2repository"))
            });
            instance.repositoryPaths       = UniqueList(repoPaths);
            instances[instance.clientName] = instance;
            return(instance);
        }
Example #3
0
        /// <summary>
        /// Creates an instance of PlayServicesSupport.  This instance is
        /// used to add dependencies for the calling client and invoke the resolution.
        /// </summary>
        /// <returns>The instance.</returns>
        /// <param name="clientName">Client name.  Must be a valid filename.
        /// This is used to uniquely identify
        /// the calling client so that dependencies can be associated with a specific
        /// client to help in resetting dependencies.</param>
        /// <param name="sdkPath">Sdk path for Android SDK (unused).</param>
        /// <param name="additionalRepositories">Array of additional repository paths. can be
        /// null</param>
        /// <param name="settingsDirectory">This parameter is obsolete.</param>
        /// <param name="logger">Delegate used to write messages to the log.</param>
        /// <param name="logMessageWithLevel">Delegate used to write messages to the log.  If
        /// this is specified "logger" is ignored.</param>
        internal static PlayServicesSupport CreateInstance(
            string clientName, string sdkPath, string[] additionalRepositories,
            string settingsDirectory, LogMessage logger = null,
            LogMessageWithLevel logMessageWithLevel     = null)
        {
            PlayServicesSupport instance     = new PlayServicesSupport();
            LogMessageWithLevel legacyLogger = (string message, LogLevel level) => {
                if (logger != null)
                {
                    logger(message);
                }
            };

            PlayServicesSupport.logger =
                PlayServicesSupport.logger ?? (logMessageWithLevel ??
                                               (logger != null ? legacyLogger : null));
            string badchars = new string(Path.GetInvalidFileNameChars());

            foreach (char ch in clientName)
            {
                if (badchars.IndexOf(ch) >= 0)
                {
                    throw new Exception("Invalid clientName: " + clientName);
                }
            }

            instance.clientName = clientName;

            var repoPaths = new List <string>();

            repoPaths.AddRange(additionalRepositories ?? new string[] {});
            // Add the standard repo paths from the Android SDK
            string sdkExtrasDir = Path.Combine(SdkVariable, "extras");

            repoPaths.AddRange(
                new string [] {
                Path.Combine(sdkExtrasDir, Path.Combine("android", "m2repository")),
                Path.Combine(sdkExtrasDir, Path.Combine("google", "m2repository"))
            });
            instance.repositoryPaths       = UniqueList(repoPaths);
            instances[instance.clientName] = instance;
            return(instance);
        }