Ejemplo n.º 1
0
        /// <summary>
        /// Create <see cref="ResourceManager"/> with <see cref="ResourceProviderBase.AssemblyName"/> and <see cref="ResourceProviderBase.ResourceName"/>
        /// </summary>
        protected virtual void CreateResourceManager()
        {
            if (_resourceManager != null)
            {
                return;
            }

            lock (_syncLock) {
                if (_resourceManager == null)
                {
                    if (IsDebugEnabled)
                    {
                        log.Debug(@"Create new resource manager. resource file=[{0}.{1}]", AssemblyName, ResourceName);
                    }

                    try {
                        var asm = AssemblyName.IsWhiteSpace()
                                      ? Assembly.GetEntryAssembly()
                                      : Assembly.Load(AssemblyName);

                        if (IsDebugEnabled)
                        {
                            log.Debug(@"Load assembly: " + asm.FullName);
                        }

                        _resourceManager = new ResourceManager(string.Format("{0}.{1}", AssemblyName, ResourceName), asm);
                    }
                    catch (Exception ex) {
                        if (log.IsErrorEnabled)
                        {
                            log.Error(@"ResourceManager를 생성하는데 실패했습니다. AssemblyName=[{0}], ResourceName=[{1}]", AssemblyName,
                                      ResourceName);
                            log.Error(ex);
                        }

                        throw;
                    }
                }
            }
        }