Пример #1
0
        public void TestValueOfTrue()
        {
            String pattern = "True";
            bool?  res     = BooleanUtil.ValueOf(pattern);

            Assert.AreEqual(res, true);
        }
Пример #2
0
        public void TestValueOfFalse()
        {
            String pattern = "False";
            bool?  res     = BooleanUtil.ValueOf(pattern);

            Assert.AreEqual(res, false);
        }
Пример #3
0
        private IDeviceBitmap GetOrCreateDeviceBitmap(IDeviceResourceFactory factory, SizeInt32 desiredPixelSize)
        {
            base.VerifyAccess();
            IDeviceBitmap result = null;
            int           num    = Int32Util.Pow2RoundUp(desiredPixelSize.Width);
            int           num2   = Int32Util.Pow2RoundUp(desiredPixelSize.Height);
            int           width  = Math.Max(Math.Max(num, num2), 0x100);
            SizeInt32     num5   = new SizeInt32(width, width);

            while (this.deviceBitmapPool.TryDequeue(out result))
            {
                SizeInt32 pixelSize = result.PixelSize;
                if (((pixelSize.Width >= num5.Width) && (pixelSize.Width <= (num5.Width * 2))) && ((pixelSize.Height >= num5.Height) && (pixelSize.Height <= (num5.Height * 2))))
                {
                    break;
                }
                DisposableUtil.Free <IDeviceBitmap>(ref result);
            }
            if (result == null)
            {
                result = factory.CreateDeviceBitmap(desiredPixelSize, maskBitmapProperties);
                AttachedData.SetValue(result, isPooledBitmapAttachedKey, BooleanUtil.GetBoxed(true));
            }
            return(result);
        }
Пример #4
0
        public void convert()
        {
            List <Object> falses = new List <Object>();
            List <Object> trues  = new List <Object>();

            falses.Add(0);
            falses.Add(0.0d);
            falses.Add("");
            falses.Add(false);
            falses.Add(new List <String>());
            falses.Add(new int[] {});

            trues.Add(1);
            trues.Add(0.5d);
            trues.Add("a");
            trues.Add(" ");
            trues.Add(true);
            trues.Add(new [] { "a" });
            trues.Add(new [] { 1, 2 });
            trues.Add(new Object());

            foreach (Object obj in falses)
            {
                Assert.IsFalse(BooleanUtil.convert(obj), obj + " (" + obj.GetType().FullName + ") should be false");
            }
            foreach (Object obj in trues)
            {
                Assert.IsTrue(BooleanUtil.convert(obj), obj + " (" + obj.GetType().FullName + ") should be true");
            }
        }
Пример #5
0
        object ConvertCore(object value)
        {
            if (value is bool boolean)
            {
                return(BooleanUtil.GetBoxed(!boolean));
            }

            return(DependencyProperty.UnsetValue);
        }
Пример #6
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is Visibility visibility)
            {
                return(BooleanUtil.GetBoxed(visibility == Visibility.Collapsed));
            }

            return(BoxedConstants.Boolean.False);
        }
Пример #7
0
 public void TestValueOftNull()
 {
     try
     {
         String pattern = null;
         bool?  res     = BooleanUtil.ValueOf(pattern);
     }
     catch (NullReferenceException)
     {
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
Пример #8
0
 public void TestValueOfEmpty()
 {
     try
     {
         String pattern = "";
         bool?  res     = BooleanUtil.ValueOf(pattern);
         Assert.AreEqual(res, false);
     }
     catch (FormatException)
     {
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
Пример #9
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var target = parameter as Type;

            if (target == null)
            {
                return(DependencyProperty.UnsetValue);
            }

            var type = value.GetType();

            if (target.IsInterface)
            {
                return(BooleanUtil.GetBoxed(type.IsAssignableFrom(target)));
            }

            return(BooleanUtil.GetBoxed(type.IsSubclassOf(target)));
        }
Пример #10
0
        static public void AssignLocationProperties(IGxContext context,
                                                    String sLocation,
                                                    GxHttpClient oClient)
        {
            GxLocation oLocation;
            GxLocation oGroupLocation;
            String     sGroupLocation;
            short      nGroupErr;

            oLocation = SoapParm.getlocation(context, sLocation);
            if (context.nSOAPErr != 0)
            {
                sGroupLocation = "LOC:" + oClient.Host + oClient.BaseURL;
                oGroupLocation = context.colLocations.GetItem(sGroupLocation);
                nGroupErr      = 0;
                if (oGroupLocation == null)
                {
                    nGroupErr = 1;
                }
                if (nGroupErr == 0)
                {
                    context.nSOAPErr        = 0;
                    oLocation.GroupLocation = sGroupLocation;
                    assigngroupproperties(context, oLocation);
                }
            }
            if (context.nSOAPErr == 0)
            {
                if (StringUtil.StrCmp(oLocation.Host, "") != 0)
                {
                    oClient.Host = oLocation.Host;
                }
                if (oLocation.Port != -1)
                {
                    oClient.Port = oLocation.Port;
                }
                if (StringUtil.StrCmp(oLocation.ProxyServerHost, "") != 0)
                {
                    oClient.ProxyServerHost = oLocation.ProxyServerHost;
                }
                if (oLocation.ProxyServerPort != -1)
                {
                    oClient.ProxyServerPort = (short)(oLocation.ProxyServerPort);
                }
                if (StringUtil.StrCmp(oLocation.BaseUrl, "") != 0)
                {
                    oClient.BaseURL = oLocation.BaseUrl;
                }
                if (oLocation.Secure != -1)
                {
                    oClient.Secure = (BooleanUtil.Val(StringUtil.Str((decimal)(oLocation.Secure), 1, 0)) ? 1 : 0);
                }
                if (oLocation.Timeout != -1)
                {
                    oClient.Timeout = oLocation.Timeout;
                }
                if (StringUtil.StrCmp(oLocation.ProxyAuthenticationUser, "") != 0)
                {
                    oClient.AddProxyAuthentication(oLocation.ProxyAuthenticationMethod, oLocation.ProxyAuthenticationRealm, oLocation.ProxyAuthenticationUser, oLocation.ProxyAuthenticationPassword);
                }
                if (StringUtil.StrCmp(oLocation.Certificate, "") != 0)
                {
                    oClient.AddCertificate(oLocation.Certificate);
                }
                if (oLocation.Authentication == 1)
                {
                    oClient.AddAuthentication(oLocation.AuthenticationMethod, oLocation.AuthenticationRealm, oLocation.AuthenticationUser, oLocation.AuthenticationPassword);
                }
            }
        }
Пример #11
0
        protected override void Invoke(PropertyAccessor propertyAccessor, object target)
        {
            var value = (bool)propertyAccessor.GetValue(target);

            propertyAccessor.SetValue(target, BooleanUtil.GetBoxed(!value));
        }
Пример #12
0
 public static void SetAlignBottomWithPanel(UIElement element, bool value) =>
 element.SetValue(AlignBottomWithPanelProperty, BooleanUtil.GetBoxed(value));
Пример #13
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
 BooleanUtil.GetBoxed(Equals(value, parameter));
Пример #14
0
 public static void SetIsHighQualityScalingEnabled(CanvasView canvasView, bool value)
 {
     canvasView.SetValue(IsHighQualityScalingEnabledProperty, BooleanUtil.GetBoxed(value));
 }
Пример #15
0
 public static void SetAllowDrag(PaintDotNet.UI.FrameworkElement target, bool value)
 {
     target.SetValue(AllowDragProperty, BooleanUtil.GetBoxed(value));
 }
Пример #16
0
 public static void SetIsPixelGridEnabled(CanvasView canvasView, bool value)
 {
     canvasView.SetValue(IsPixelGridEnabledProperty, BooleanUtil.GetBoxed(value));
 }
Пример #17
0
 public static void SetIsEnabled(PaintDotNet.UI.FrameworkElement target, bool value)
 {
     target.SetValue(IsEnabledProperty, BooleanUtil.GetBoxed(value));
 }
Пример #18
0
 private static void SetIsPressed(PaintDotNet.UI.FrameworkElement target, bool value)
 {
     target.SetValue(IsPressedPropertyKey, BooleanUtil.GetBoxed(value));
 }
Пример #19
0
 static RotationAnchorResetButton()
 {
     HandleElement.IsHotOnMouseOverProperty.OverrideMetadata(typeof(RotationAnchorResetButton), new FrameworkPropertyMetadata(BooleanUtil.GetBoxed(false)));
 }