示例#1
0
        public IconProxy GetIcon(string businessObjectClass, string businessObject, string arguments)
        {
            if (businessObjectClass == null)
            {
                return(null);
            }

            Type type = TypeUtility.GetType(businessObjectClass, true);
            var  businessObjectProvider = BindableObjectProvider.GetProviderForBindableObjectType(type);
            var  bindableObjectClass    = businessObjectProvider.GetBindableObjectClass(type);
            IBusinessObjectWithIdentity businessObjectWithIdentity = null;

            if (!string.IsNullOrEmpty(businessObject))
            {
                var businessObjectClassWithIdentity = (IBusinessObjectClassWithIdentity)bindableObjectClass;
                businessObjectWithIdentity = businessObjectClassWithIdentity.GetObject(businessObject);
            }

            var iconInfo = BusinessObjectBoundWebControl.GetIcon(businessObjectWithIdentity, bindableObjectClass.BusinessObjectProvider);

            if (iconInfo != null)
            {
                return(IconProxy.Create(new HttpContextWrapper(Context), iconInfo));
            }

            return(null);
        }
        public void Create_UrlMissing()
        {
            var iconInfo = new IconInfo();

            Assert.That(
                () => IconProxy.Create(_httpContextStub, iconInfo),
                Throws.ArgumentException.With.Message.StartsWith("IconProxy does not support IconInfo objects without an empty Url."));
        }
        public void Create_OnlyUrl()
        {
            var iconInfo = new IconInfo("~/url");

            var iconProxy = IconProxy.Create(_httpContextStub, iconInfo);

            Assert.That(iconProxy.Url, Is.EqualTo("/root/url"));
            Assert.That(iconProxy.AlternateText, Is.Null);
            Assert.That(iconProxy.ToolTip, Is.Null);
            Assert.That(iconProxy.Width, Is.Null);
            Assert.That(iconProxy.Height, Is.Null);
        }
        public void Create_Complete()
        {
            var iconInfo = new IconInfo("~/url")
            {
                AlternateText = "Alt", ToolTip = "ToolTip", Width = Unit.Pixel(4), Height = Unit.Percentage(8)
            };

            var iconProxy = IconProxy.Create(_httpContextStub, iconInfo);

            Assert.That(iconProxy.Url, Is.EqualTo("/root/url"));
            Assert.That(iconProxy.AlternateText, Is.EqualTo("Alt"));
            Assert.That(iconProxy.ToolTip, Is.EqualTo("ToolTip"));
            Assert.That(iconProxy.Width, Is.EqualTo("4px"));
            Assert.That(iconProxy.Height, Is.EqualTo("8%"));
        }