public void ForTypeHappyPath()
        {
            var resourceManager1 = ResourceManagers.ForType(typeof(Properties.Resources));
            var resourceManager2 = ResourceManagers.ForType(typeof(Properties.Resources));

            Assert.AreSame(resourceManager1, resourceManager2);
            Assert.AreSame(resourceManager1, Properties.Resources.ResourceManager);
        }
        /// <inheritdoc />
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            try
            {
                if (this.MemberType != null)
                {
                    var resourceManager = ResourceManagers.ForType(this.MemberType);
                    return(CreateBindingExpression(resourceManager, this.Member, serviceProvider));
                }

                if (string.IsNullOrEmpty(this.Member))
                {
                    throw new InvalidOperationException("MarkupExtensionStaticMember");
                }

                var qnk = QualifiedNameAndKey.Parse(this.Member);
                if (qnk.QualifiedName == null || qnk.Key == null)
                {
                    return(string.Format(Resources.UnknownErrorFormat, this.Member));
                }

                var type = serviceProvider.Resolve(qnk.QualifiedName);
                if (type == null)
                {
                    return(string.Format(Resources.MissingResourcesFormat, this.Member));
                }

                var manager = ResourceManagers.ForType(type);
                this.Member = qnk.Key;
                return(CreateBindingExpression(manager, this.Member, serviceProvider));
            }
            catch (Exception)
            {
                return(string.Format(Resources.UnknownErrorFormat, this.Member));
            }
        }
 public void ForTypeThrows()
 {
     Assert.Throws <ArgumentException>(() => ResourceManagers.ForType(typeof(ResourceManager)));
 }