public Comparer(CultureInfo culture)
		{
			if (culture == null)
				throw new ArgumentNullException("culture");

			m_compareInfo = culture.CompareInfo;
		}
    public bool PosTest2()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest2: Verify convert byte value when CurrencySymbol is set...");

        try
        {
            string byteString = "@10";
            CultureInfo culture = new CultureInfo("");
            NumberFormatInfo numberFormat = culture.NumberFormat;
            numberFormat.CurrencySymbol = "@";

            Byte myByte = Byte.Parse(byteString, NumberStyles.Currency | NumberStyles.Number, numberFormat);
            UInt16 conVertUInt16 = ((IConvertible)myByte).ToUInt16(numberFormat);

            if (conVertUInt16 != 10)
            {
                TestLibrary.TestFramework.LogError("003", "The convert byte is not equal to original!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #3
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: check Decimal which is the MaxValue and MinValue.");

        try
        {
            Decimal i1 = Decimal.MaxValue;
            CultureInfo myCulture = new CultureInfo("en-us");
            bool actualValue = ((IConvertible)i1).ToBoolean(myCulture);
            if (!actualValue)
            {
                TestLibrary.TestFramework.LogError("002.1", "ToBoolean  should return " + actualValue);
                retVal = false;
            }
            i1 = Decimal.MinValue;
            actualValue = ((IConvertible)i1).ToBoolean(myCulture);
            if (!actualValue)
            {
                TestLibrary.TestFramework.LogError("002.2", "ToBoolean  should return " + actualValue);
                retVal = false;
            }
          
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.4", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #4
0
    static void Main()
    {
        CultureInfo MyCultureInfo = new CultureInfo("en-US");

            DateTime myDateTime;
            DateTime startTime = DateTime.Parse("1:00 PM");
            DateTime endTime = DateTime.Parse("3:00 AM");
            string inputString = Console.ReadLine();

            if (DateTime.TryParseExact(inputString, "h:mm tt", MyCultureInfo, DateTimeStyles.None, out myDateTime))
            {
                if (myDateTime > startTime || myDateTime < endTime)
                {
                    Console.WriteLine("beer time");
                }
                else
                {
                    Console.WriteLine("non-beer time");
                }
            }
            else
            {
                Console.WriteLine("invalid time");
            }
    }
    public bool PosTest1()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify convert byte value when positiveSign is set...");

        try
        {
            string byteString = "plus128";
            CultureInfo culture = new CultureInfo("");
            NumberFormatInfo numberFormat = culture.NumberFormat;
            numberFormat.PositiveSign = "plus";

            Byte myByte = Byte.Parse(byteString, NumberStyles.Number, numberFormat);
            UInt16 conVertUInt16 = ((IConvertible)myByte).ToUInt16(numberFormat);

            if (conVertUInt16 != 128)
            {
                TestLibrary.TestFramework.LogError("001", "The convert byte is not equal to original!");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception occurs: " + e);
            retVal = false;
        }

        return retVal;
    }
    static void Main()
    {
        CultureInfo enUS = new CultureInfo("en-US");
        DateTime time;
        DateTime startTime = DateTime.Parse("1:00 PM");
        DateTime endTime = DateTime.Parse("3:00 AM");
        string dateString = Console.ReadLine();

        if (DateTime.TryParseExact(dateString, "h:mm tt", enUS,
                                    DateTimeStyles.None, out time))
        {
            if (time > startTime || time < endTime)
            {
                Console.WriteLine("beer time");
            }
            else
            {
                Console.WriteLine("non-beer time");
            }
        }
        else
        {
            Console.WriteLine("invalid time");
        }
    }
Example #7
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Check a random Decimal.");

        try
        {
            Decimal i1 =new decimal( TestLibrary.Generator.GetSingle(-55));
            CultureInfo myCulture = new CultureInfo("en-us");
            bool actualValue = ((IConvertible)i1).ToBoolean(myCulture);
            if (!actualValue)
            {
                TestLibrary.TestFramework.LogError("001.1", "ToBoolean  should return " + actualValue);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
    public bool PosTest2()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest2: Convert a random Int16 to Boolean ");

        try
        {
            Int16 i1 = 0;
            while (i1 == 0)
            {
                i1 = TestLibrary.Generator.GetInt16(-55);
            }
            IConvertible Icon1 = (IConvertible)i1;
            CultureInfo cultureinfo = new CultureInfo("en-US");
            bool s1 = (bool)Icon1.ToType(typeof(System.Boolean), cultureinfo);
            if (s1 != true)
            {
                TestLibrary.TestFramework.LogError("003", "The result is not the value as expected.The random number is :" + i1.ToString());
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #9
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Convert UInt64MinValue to string");

        try
        {
            UInt64 i = UInt64.MinValue;
            IFormatProvider iFormatProvider = new CultureInfo("fr-FR");
            string str = Convert.ToString(i, iFormatProvider);
            if (str != i.ToString(iFormatProvider))
            {
                TestLibrary.TestFramework.LogError("005", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: CultureTypes.NeutralCultures.");
        try
        {
            CultureInfo myCulture = new CultureInfo("en");
			//SL now support neutral cultures
            if (!(myCulture is CultureInfo))
            {
                TestLibrary.TestFramework.LogError("001", "should return 'en' CultureInfo.");
                retVal = false;
            }
        }
        catch (ArgumentException)
        {
			// ArgumentException is not expected on Windows either
			TestLibrary.TestFramework.LogError("001.1", "Expect no exception instead got ArgumentException");
            retVal = false;
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }
        return retVal;
    }
    public bool PosTest1()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest1: Convert a random Int16 to String ");

        try
        {
            Int16 i1 = TestLibrary.Generator.GetInt16(-55);
            IConvertible Icon1 = (IConvertible)i1;
            CultureInfo cultureinfo = new CultureInfo("en-US");
            string s1 = Icon1.ToType(typeof(System.String), cultureinfo) as string;
            if (s1 != i1.ToString())
            {
                TestLibrary.TestFramework.LogError("001", "The result is not the value as expected.The random number is :" + i1.ToString());
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #12
0
	//CultureInfo.GetCultureInfo has been removed. Replaced by CultureInfo ctor.
	public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Check a  random single.");

        try
        {
            Single i1 = TestLibrary.Generator.GetSingle(-55);
            int expectValue = 0;
            if (i1 > 0.5)
                expectValue = 1;
            else
                expectValue = 0;
            CultureInfo myCulture = new CultureInfo("en-us");
            int actualValue = ((IConvertible)i1).ToInt32(myCulture);
            if (actualValue != expectValue)
            {
                TestLibrary.TestFramework.LogError("001.1", "ToInt32  return failed. ");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #13
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Check a single which is  -123.");

        try
        {
            Single i1 = (Single)(-123);
            CultureInfo myCulture = new CultureInfo("en-us");
            int actualValue = ((IConvertible)i1).ToInt32(myCulture);
            if (actualValue != (int)(-123))
            {
                TestLibrary.TestFramework.LogError("002.1", "ToInt32  return failed. ");
                retVal = false;
            }

        }

        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #14
0
    public bool PosTest2()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest2: Verify the TextInfo is not same  CultureInfo's . ";
        const string c_TEST_ID = "P002";


        TextInfo textInfoFrance = new CultureInfo("fr-FR").TextInfo;
        TextInfo textInfoUS = new CultureInfo("en-US").TextInfo;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            int franceHashCode = textInfoFrance.GetHashCode();
            int usHashCode = textInfoUS.GetHashCode();
            if (franceHashCode == usHashCode)
            {
                string errorDesc = "the differente TextInfo's HashCode should not equal. ";
                TestLibrary.TestFramework.LogError("003" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004" + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
    public bool PosTest1()
    {
        bool retVal = true;

        // Add your scenario description here
        TestLibrary.TestFramework.BeginScenario("PosTest1: Verify method GetInstance .");

        try
        {
            CultureInfo ci = new CultureInfo("fr-FR");
            NumberFormatInfo nfi = NumberFormatInfo.GetInstance(ci);

            if (nfi == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "Method GetInstance Err .");
                retVal = false;
            }
    
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Example #16
0
    public bool PosTest1()
    {
        bool retVal = true;
        string c_TEST_DESC = "PosTest1: Verify the DateTime is now and IFormatProvider is en-US CultureInfo... ";
        string c_TEST_ID = "P001";


        DateTime dt = DateTime.Now;
        IFormatProvider provider = new CultureInfo("en-US");
        String actualValue = dt.ToString(provider);

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            String resValue = Convert.ToString(dt,provider);
            if (actualValue != resValue)
            {
                string errorDesc = "value is not " + resValue.ToString() + " as expected: Actual is " + actualValue.ToString();
                errorDesc = "\n IFormatProvider is en-US CultureInfo.";
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "unexpected exception occurs :" + e);
            retVal = false;
        }

        return retVal;
    }
Example #17
0
    public bool PosTest1()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest1: Verify the TextInfo equals original TextInfo. ";
        const string c_TEST_ID = "P001";

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        CultureInfo ci = new CultureInfo("en-US");
        CultureInfo ci2 = new CultureInfo("en-US");
        object textInfo = ci2.TextInfo;
       
        try
        {
            int originalHC = ci.TextInfo.GetHashCode();
            int clonedHC = (textInfo as TextInfo).GetHashCode();
            if (originalHC != clonedHC)
            {
                string errorDesc = "the cloned TextInfo'HashCode should equal original TextInfo's HashCode.";
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
    // Returns true if the expected result is right
    // Returns false if the expected result is wrong
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: CultureTypes.NeutralCultures");
        try
        {

            CultureInfo myCultureInfo = new CultureInfo("en");
            string expectedstring = "en";
            if (myCultureInfo.TwoLetterISOLanguageName != expectedstring)
            {
                TestLibrary.TestFramework.LogError("003", "the TwoLetterISOLanguageName  of 'en' should be 'en'.");
                retVal = false;
            }
            if (TestLibrary.Utilities.IsWindows)
            {
                TestLibrary.TestFramework.LogError("003.1", "On Windows expected an ArgumentException");
            }
        }
        catch (ArgumentException)
        {
            if (!TestLibrary.Utilities.IsWindows)
            {
                TestLibrary.TestFramework.LogError("003.2", "Expect no exception on Macintosh; instead got ArgumentException");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }
        return retVal;
    }
Example #19
0
 static void Main()
 {
     CultureInfo MyCultureInfo = new CultureInfo("en-US");
     Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
     Console.Write("Please enter the time: (example : 05:50 PM or 22:22 ");
     string timeInput = Console.ReadLine();
     DateTime amOrPm = DateTime.Parse(timeInput);
     Console.WriteLine(amOrPm);
     string amPm = amOrPm.ToString("tt");
     bool isAm = amOrPm.Hour <= 3 && amOrPm.Minute >= 0 && amOrPm.Minute < 60;
     bool isPm = amOrPm.Hour >= 1;
     if (amPm == "AM")
     {
         if (isAm)
         {
             Console.WriteLine("Beer Time");
         }
         else
         {
             Console.WriteLine("not a beer time");
         }
     }
     else
     {
         if (isPm)
         {
             Console.WriteLine("beer time");
         }
         else
         {
             Console.WriteLine("non-beer time");
         }
     }
 }
Example #20
0
    protected override void InitializeCulture()
    {
        HttpCookie CultureCookie = Request.Cookies["ASLang"];

        CultureInfo ci;
        if (CultureCookie == null)
        {
            ci = new CultureInfo("ar-JO");
        }
        else
        {
            ci = new CultureInfo(CultureCookie.Value);
        }
        Thread.CurrentThread.CurrentCulture = ci;
        Thread.CurrentThread.CurrentUICulture = ci;
        base.InitializeCulture();
        switch (Page.Culture)
        {
            case "Arabic (Jordan)":
                Page.Theme = "Ar";
                break;
            default:
                Page.Theme = "En";
                break;
        }
    }
Example #21
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: The object is an int32");

        try
        {
            Int32 i = TestLibrary.Generator.GetInt32(-55);
            object ob = i;
            IFormatProvider iFormatProvider = new CultureInfo("fr-FR");
            decimal decimalValue = Convert.ToDecimal(ob, iFormatProvider);
            if (decimalValue != i)
            {
                TestLibrary.TestFramework.LogError("003", "The result is not the value as expected,i is" + i);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #22
0
    protected void ApplyNewLanguageAndRefreshPage(CultureInfo culture)
    {
        ApplyNewLanguage(culture);
        //Refresh the current page to make all control-texts take effect

        Response.Redirect(Request.Url.AbsoluteUri);
    }
Example #23
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Compare two string ");

        try
        {
			string a = "hello";
			string b = "aaaaa";
			CultureInfo cultureInfo = new CultureInfo("en-US");
			CompareInfo comparer = cultureInfo.CompareInfo;
			int result = comparer.Compare(b, a);
			if (result >= 0)
			{
				TestLibrary.TestFramework.LogError("003", "The result is not the value as expected");
				retVal = false;
			}
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Example #24
0
    public bool NegTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest1: Check a single which is  >UInt32.MaxValue.");

        try
        {
            Single i1 = (float)UInt32.MaxValue + 1.0f;
            CultureInfo myCulture =  new CultureInfo("en-US");
            uint actualValue = ((IConvertible)i1).ToUInt32(myCulture);
            TestLibrary.TestFramework.LogError("101.1", "ToUInt32  return failed. ");
            retVal = false;


        }
        catch (OverflowException)
        {

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("101.2", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
    static void Main()
    {
        /*
         Problem 19. Dates from text in Canada
            Write a program that extracts from a given text all dates that match the format DD.MM.YYYY.
            Display them in the standard date format for Canada.
         */
        IFormatProvider culture = new CultureInfo("en-CA", true);
        string text = "fgfdgdgd 29.03.2014 29.02.2013 gd dfdg fggggggd 30.04.2013 g g 2.3 33.2.333";

        for (int i = 0; i < text.Length - 9; i++)
        {
            if(char.IsDigit(text[i]))
            {
                for(int j = 0; j <= 1; j++)
                {
                    string strDate = text.Substring(i, 9 + j);
                    DateTime date;

                    if(DateTime.TryParseExact(strDate, "dd.MM.yyyy", culture, DateTimeStyles.None, out date))
                    {
                        DateTime dt = date;
                        Console.WriteLine("{0}.{1}.{2}", date.Day, date.Month, date.Year);
                        i += 9;
                    }
                }
            }
        }
    }
Example #26
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Check a single which is  +123.");

        try
        {
            Single i1 = (Single)(+123);
            CultureInfo myCulture =  new CultureInfo("en-US");
            Single actualValue = ((IConvertible)i1).ToSingle(myCulture);
            if (actualValue != i1)
            {
                TestLibrary.TestFramework.LogError("003.1", "ToSingle  return failed. ");
                retVal = false;
            }

        }

        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.2", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
	public void Initialize(CultureInfo thisCultureInfo, bool checkTranslation = false)
	{
		if(smartLocWindow != null && !Application.isPlaying && thisCultureInfo != null)
		{
			if(undoManager == null)
			{
				// Instantiate Undo Manager
				undoManager = new HOEditorUndoManager(this, "Smart Localization - Translate Language Window");
			}

			if(thisCultureInfo != null)
			{
				bool newLanguage = thisCultureInfo != this.thisCultureInfo ? true : false;
				this.thisCultureInfo = thisCultureInfo;
				if(thisLanguageValues == null || thisLanguageValues.Count < 1 || newLanguage)
				{
					InitializeLanguage(thisCultureInfo, LocFileUtility.LoadParsedLanguageFile(null), LocFileUtility.LoadParsedLanguageFile(thisCultureInfo.Name));
				}
			}

			if(checkTranslation)
			{
				//Check if the language can be translated
				canLanguageBeTranslated = false;
				CheckIfCanBeTranslated();

				if(translateFromDictionary != null)
				{
					translateFromDictionary.Clear();
					translateFromDictionary = null;
				}
			}
		}
	}
 static void Main()
 {
     try
     {
         Console.WriteLine("Enter dates in format: dd:mm:yyyy");
         Console.Write("Enter first date: ");
         string firstDate = Console.ReadLine();
         Console.Write("Enter second date: ");
         string secondDate = Console.ReadLine();
         IFormatProvider culture = new CultureInfo("bg");
         string format = "dd/mm/yyyy";
         DateTime dateOne = DateTime.ParseExact(firstDate, format, culture);
         DateTime dateTwo = DateTime.ParseExact(secondDate, format, culture);
         int dayOne = dateOne.Day;
         int dayTwo = dateTwo.Day;
         int result;
         if (dayOne > dayTwo)
         {
             result = dayOne - dayTwo;
         }
         else
         {
             result = dayTwo - dayOne;
         }
         Console.WriteLine("Distance : {0}", result);
     }
     catch (Exception)
     {
         Console.WriteLine("Invalid date format !");
         Console.WriteLine("Try like the following example : (27.02.2006)");
         throw;
     }
 }
 static void Main()
 {
     Console.WriteLine("Inpute time:");
     string timeString = Console.ReadLine();
     CultureInfo culture = new CultureInfo("en-US");
     DateTimeStyles styles = DateTimeStyles.None;
     DateTime time;
     DateTime startTime = DateTime.Parse("1:00 PM");
     DateTime endTime = DateTime.Parse("3:00 AM");
     if (DateTime.TryParse(timeString, culture, styles, out time))
     {
         if (startTime <= time || time < endTime)
         {
             Console.WriteLine("Beer time");
         }
         else
         {
             Console.WriteLine("Non-beer time");
         }
     }
     else
     {
         Console.WriteLine("Invalid time");
     }
 }
Example #30
0
    private void ApplyNewLanguage(CultureInfo culture)
    {
        LanguageManager.CurrentCulture = culture;
        //Keep current language in session

        Session.Add(SESSION_KEY_LANGUAGE, LanguageManager.CurrentCulture);
    }
Example #31
0
        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is null && !typeof(TTarget).IsClass && Nullable.GetUnderlyingType(typeof(TTarget)) == null)
            {
                throw new NotSupportedException();
            }

            return(ConvertBack((TTarget)value, targetType, parameter, culture));
        }
Example #32
0
 /// <summary>
 /// Convert
 /// </summary>
 /// <param name="o"></param>
 /// <param name="type"></param>
 /// <param name="parameter"></param>
 /// <param name="culture"></param>
 /// <returns></returns>
 public object Convert(object o, Type type, object parameter,
                       CultureInfo culture)
 {
     return(new Thickness((int)o * C_INDENT_SIZE, 0, 0, 0));
 }
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     throw new NotImplementedException();
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var res = (bool)value;

            return(ToString(res));
        }
Example #35
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
     return Math.Max((value.As(321d) / 180).FloorToInt(), 2);
 }
 /// <summary>
 /// Converting back is not supported.
 /// </summary>
 /// <param name="value">
 /// The value.
 /// </param>
 /// <param name="targetType">
 /// The target type.
 /// </param>
 /// <param name="parameter">
 /// The parameter.
 /// </param>
 /// <param name="culture">
 /// The culture.
 /// </param>
 /// <returns>
 /// Returns <see cref="DependencyProperty.UnsetValue"/> always.
 /// </returns>
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(DependencyProperty.UnsetValue);
 }
Example #37
0
 protected virtual TTarget Convert(TSource value, Type targetType, object parameter, CultureInfo culture)
 {
     throw new NotImplementedException();
 }
Example #38
0
        public BatchGeocoderTest()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");

            batchGeocoder = CreateBatchGeocoder();
        }
        public ILocaleCache CacheFor(CultureInfo culture)
        {
            var cache = _cache.CacheFor(culture, () => _storage.Load(culture));

            return(cache);
        }
            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                if (value is SolidColorBrush)
                {
                    return(ToColor(((SolidColorBrush)value).Color));
                }

                return(null);
            }
Example #41
0
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(Enum.ToObject(targetType, (byte)(int)value));
 }
Example #42
0
 public string ToString(CultureInfo info) => Value.ToString(info) + Unit;
Example #43
0
 public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
 {
     return(null);
 }
 public LocaleCacheFactory(CultureInfo defaultCulture, ILocalizationStorage storage, ILocalizationCache cache)
 {
     _defaultCulture = defaultCulture;
     _storage        = storage;
     _cache          = cache;
 }
Example #45
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var level = (int)value;

            return(level == 0 ? FontWeights.DemiBold : FontWeights.Regular);
        }
Example #46
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(System.Convert.ChangeType(value, targetType, CultureInfo.CurrentCulture));
 }
 public override void FormatFrame(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgStackFrameFormatterOptions options, DbgValueFormatterOptions valueOptions, CultureInfo cultureInfo) =>
 new VisualBasicStackFrameFormatter(output, evalInfo, this, options, valueOptions.ToValueFormatterOptions(), cultureInfo).Format();
Example #48
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var scroll = values[1] as ScrollViewerPro;

            return(scroll.IsVerticalScrollBarAtBottom);
        }
 public override void FormatType(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DmdType type, DbgDotNetValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo) =>
 new VisualBasicTypeFormatter(output, options.ToTypeFormatterOptions(), cultureInfo).Format(type, value);
Example #50
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(!(bool)value);
 }
Example #51
0
 public void SetUp()
 {
     // Important so that ToString() versions of decimal works whatever the current culture.
     this.savedCulture = Thread.CurrentThread.CurrentCulture;
     Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fr-FR");
 }
 public override void FormatValue(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgDotNetValue value, DbgValueFormatterOptions options, CultureInfo cultureInfo) =>
 new VisualBasicValueFormatter(output, evalInfo, this, options.ToValueFormatterOptions(), cultureInfo).Format(value);
 /// <summary>
 /// 
 /// </summary>
 /// <param name="value"></param>
 /// <param name="targetType"></param>
 /// <param name="parameter"></param>
 /// <param name="culture"></param>
 /// <returns></returns>
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return null;
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ICollection <string> errors = value as ICollection <string>;

            return(errors != null && errors.Count > 0 ? errors.ElementAt(0) : null);
        }
Example #55
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (SelectedTab == 0)
            {
                double    progressStep    = 100 / 4;
                Stopwatch stopWatchStep   = new Stopwatch();
                Stopwatch stopWatchGlobal = new Stopwatch();

                try
                {
                    stopWatchGlobal.Start();
                    App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <bool>(base.MessageManager.SetBusyMode), true);

                    //Set culture for the new thread
                    if (!string.IsNullOrEmpty(Setting.ReportingParameter.CultureName))
                    {
                        var culture = new CultureInfo(Setting.ReportingParameter.CultureName);
                        Thread.CurrentThread.CurrentCulture   = culture;
                        Thread.CurrentThread.CurrentUICulture = culture;
                    }

                    //Get result for the Application
                    stopWatchStep.Restart();
                    ApplicationBLL.BuildApplicationResult(ActiveConnection, SelectedApplication);
                    stopWatchStep.Stop();
                    App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, "Build result for the application", stopWatchStep.Elapsed);


                    //Get result for the previous snapshot
                    stopWatchStep.Restart();
                    SnapshotBLL.BuildSnapshotResult(ActiveConnection, SelectedSnapshot, true);
                    stopWatchStep.Stop();
                    App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, "Build result for the selected snapshot", stopWatchStep.Elapsed);


                    //Get result for the previuos snapshot
                    if (PreviousSnapshot != null)
                    {
                        stopWatchStep.Restart();
                        SnapshotBLL.BuildSnapshotResult(ActiveConnection, PreviousSnapshot, false);
                        stopWatchStep.Stop();

                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, "Build result for the previous snapshot", stopWatchStep.Elapsed);
                    }

                    //Launch generaion
                    stopWatchStep.Restart();
                    GenerateReport();
                    stopWatchStep.Stop();

                    App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, "Report generated", stopWatchStep.Elapsed);


                    //Show final message and unlock the screen
                    stopWatchGlobal.Stop();
                    App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <string, TimeSpan>(base.MessageManager.OnReportGenerated), ReportFileName, stopWatchGlobal.Elapsed);
                    App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <bool>(base.MessageManager.SetBusyMode), false);
                }
                catch (Exception ex)
                {
                    App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <Exception>(WorkerThreadException), ex);
                }
            }
            else
            {
                List <Application> Apps      = new List <Application>();
                List <Snapshot>    Snapshots = new List <Snapshot>();
                //if (SelectedTag != null)
                //{
                //GetActive Connection
                ActiveConnection = (Setting != null) ? Setting.GetActiveConnection() : null;

                //Get list of domains
                if (_ActiveConnection != null)
                {
                    try
                    {
                        using (CastDomainBLL castDomainBLL = new CastDomainBLL(ActiveConnection))
                        {
                            Apps = castDomainBLL.GetCommonTaggedApplications(SelectedTag);
                        }
                    }
                    catch (Exception ex)
                    {
                        base.MessageManager.OnErrorOccured(ex);
                    }
                }


                if (Apps != null)
                {
                    Application[] SelectedApps = Apps.ToArray <Application>();

                    double    progressStep    = 100 / 4;
                    Stopwatch stopWatchStep   = new Stopwatch();
                    Stopwatch stopWatchGlobal = new Stopwatch();

                    try
                    {
                        stopWatchGlobal.Start();
                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <bool>(base.MessageManager.SetBusyMode), true);

                        //Set culture for the new thread
                        if (!string.IsNullOrEmpty(Setting.ReportingParameter.CultureName))
                        {
                            var culture = new CultureInfo(Setting.ReportingParameter.CultureName);
                            Thread.CurrentThread.CurrentCulture   = culture;
                            Thread.CurrentThread.CurrentUICulture = culture;
                        }
                        string[] SnapsToIgnore = null;
                        //Get result for the Portfolio
                        stopWatchStep.Restart();
                        string[] AppsToIgnorePortfolioResult = PortfolioBLL.BuildPortfolioResult(ActiveConnection, SelectedApps);
                        stopWatchStep.Stop();
                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, "Build result for the portfolio", stopWatchStep.Elapsed);

                        List <Application> N_Apps = new List <Application>();
                        //Remove from Array the Ignored Apps
                        for (int i = 0; i < SelectedApps.Count(); i++)
                        {
                            int intAppYes = 0;
                            foreach (string s in AppsToIgnorePortfolioResult)
                            {
                                if (s == SelectedApps[i].Name)
                                {
                                    intAppYes = 1;
                                    break;
                                }
                                else
                                {
                                    intAppYes = 0;
                                }
                            }

                            if (intAppYes == 0)
                            {
                                N_Apps.Add(SelectedApps[i]);
                            }
                        }

                        Application[] N_SelectedApps = N_Apps.ToArray();

                        //GetActive Connection
                        ActiveConnection = (Setting != null) ? Setting.GetActiveConnection() : null;

                        //Get list of domains
                        if (_ActiveConnection != null)
                        {
                            try
                            {
                                using (CastDomainBLL castDomainBLL = new CastDomainBLL(ActiveConnection))
                                {
                                    Snapshots = castDomainBLL.GetAllSnapshots(N_SelectedApps);
                                }
                            }
                            catch (Exception ex)
                            {
                                base.MessageManager.OnErrorOccured(ex);
                            }
                        }
                        List <Snapshot> N_Snaps = new List <Snapshot>();
                        //Get result for each app's latest snapshot
                        if (Snapshots != null)
                        {
                            Snapshot[] SelectedApps_Snapshots = Snapshots.ToArray <Snapshot>();

                            //Get result for all snapshots in Portfolio
                            stopWatchStep.Restart();
                            SnapsToIgnore = PortfolioSnapshotsBLL.BuildSnapshotResult(ActiveConnection, SelectedApps_Snapshots, true);
                            stopWatchStep.Stop();
                            App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, "Build result for snapshots in portfolio", stopWatchStep.Elapsed);

                            for (int i = 0; i < SelectedApps_Snapshots.Count(); i++)
                            {
                                int intRemoveYes = 0;
                                foreach (string s in SnapsToIgnore)
                                {
                                    if (s == SelectedApps_Snapshots[i].Href)
                                    {
                                        intRemoveYes = 1;
                                        break;
                                    }
                                    else
                                    {
                                        intRemoveYes = 0;
                                    }
                                }
                                if (intRemoveYes == 0)
                                {
                                    N_Snaps.Add(SelectedApps_Snapshots[i]);
                                }
                            }

                            Snapshot[] N_SelectedApps_Snapshots = N_Snaps.ToArray();


                            //Launch generaion
                            stopWatchStep.Restart();
                            GenerateReportPortfolio(N_SelectedApps, N_SelectedApps_Snapshots, AppsToIgnorePortfolioResult, SnapsToIgnore);
                            stopWatchStep.Stop();
                        }


                        System.Text.StringBuilder sb = new System.Text.StringBuilder();



                        if ((AppsToIgnorePortfolioResult.Count() > 0 && AppsToIgnorePortfolioResult != null) || (SnapsToIgnore.Count() > 0 && SnapsToIgnore != null))
                        {
                            sb.Append("Some Applications or Snapshots were ignored during processing REST API.");

                            if (AppsToIgnorePortfolioResult.Count() > 0 && AppsToIgnorePortfolioResult != null)
                            {
                                AppsToIgnorePortfolioResult = AppsToIgnorePortfolioResult.Distinct().ToArray();
                                sb.Append("Ignored Applications are: ");
                                for (int i = 0; i < AppsToIgnorePortfolioResult.Count(); i++)
                                {
                                    if (i == 0)
                                    {
                                        sb.Append(AppsToIgnorePortfolioResult[i].ToString());
                                    }
                                    else
                                    {
                                        sb.Append("," + AppsToIgnorePortfolioResult[i].ToString());
                                    }
                                }
                            }

                            if (SnapsToIgnore.Count() > 0 && SnapsToIgnore != null)
                            {
                                SnapsToIgnore = SnapsToIgnore.Distinct().ToArray();
                                sb.Append(" Ignored Snapshots are: ");
                                for (int i = 0; i < SnapsToIgnore.Count(); i++)
                                {
                                    if (i == 0)
                                    {
                                        sb.Append(_ActiveConnection.Url + "/" + SnapsToIgnore[i].ToString());
                                    }
                                    else
                                    {
                                        sb.Append("," + _ActiveConnection.Url + "/" + SnapsToIgnore[i].ToString());
                                    }
                                }
                            }
                            App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, sb.ToString() + "", null);
                        }


                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, "Report generated", stopWatchStep.Elapsed);


                        //Show final message and unlock the screen
                        stopWatchGlobal.Stop();
                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <string, TimeSpan>(base.MessageManager.OnReportGenerated), ReportFileName, stopWatchGlobal.Elapsed);
                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <bool>(base.MessageManager.SetBusyMode), false);
                    }
                    catch (System.Net.WebException webEx)
                    {
                        LogHelper.Instance.LogErrorFormat
                            ("Request URL '{0}' - Error execution :  {1}"
                            , ""
                            , webEx.Message
                            );

                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <double, string, TimeSpan>(base.MessageManager.OnStepDone), progressStep, "Error Generating Report - " + webEx.Message + " - Typically happens when Report Generator does not find REST API (in schema)", stopWatchStep.Elapsed);
                        stopWatchGlobal.Stop();
                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <bool>(base.MessageManager.SetBusyMode), false);
                    }
                    catch (Exception ex)
                    {
                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <Exception>(WorkerThreadException), ex);
                    }
                }
            }
        }
Example #56
0
 void IPrintingConfig.ChangeCulture(CultureInfo culture) => this.culture = culture;
Example #57
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            TimeSpan.TryParse(value as string, out var time);

            return(time);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="value"></param>
 /// <param name="targetType"></param>
 /// <param name="parameter"></param>
 /// <param name="culture"></param>
 /// <returns></returns>
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return value != null && (int)value > 0;
 }
Example #59
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var time = (TimeSpan?)value;

            return(time?.ToString(@"hh\:mm"));
        }
 private void SetCurrentCultureResObjs(string LangID)
 {
     Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(LangID);
     Thread.CurrentThread.CurrentUICulture = new CultureInfo(LangID);
 }