public bool PosTest1() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest1: Verify method Clone ."); try { NumberFormatInfo nfi1 = new NumberFormatInfo(); NumberFormatInfo nfi2 = (NumberFormatInfo)nfi1.Clone(); if (!nfi1.Equals(nfi2) && nfi1.GetHashCode() == nfi2.GetHashCode()) { TestLibrary.TestFramework.LogError("001.1", "Method Clone Err ."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public void GetInstance(IFormatProvider formatProvider, NumberFormatInfo expected) { NumberFormatInfo nfi = NumberFormatInfo.GetInstance(formatProvider); Assert.Equal(expected.CurrencyDecimalDigits, nfi.CurrencyDecimalDigits); Assert.Equal(expected.CurrencyDecimalSeparator, nfi.CurrencyDecimalSeparator); Assert.Equal(expected.CurrencyGroupSeparator, nfi.CurrencyGroupSeparator); Assert.Equal(expected.CurrencyGroupSizes, nfi.CurrencyGroupSizes); Assert.Equal(expected.CurrencyNegativePattern, nfi.CurrencyNegativePattern); Assert.Equal(expected.CurrencyPositivePattern, nfi.CurrencyPositivePattern); Assert.Equal(expected.CurrencySymbol, nfi.CurrencySymbol); Assert.Equal(expected.NaNSymbol, nfi.NaNSymbol); Assert.Equal(expected.NegativeInfinitySymbol, nfi.NegativeInfinitySymbol); Assert.Equal(expected.NegativeSign, nfi.NegativeSign); Assert.Equal(expected.NumberDecimalDigits, nfi.NumberDecimalDigits); Assert.Equal(expected.NumberDecimalSeparator, nfi.NumberDecimalSeparator); Assert.Equal(expected.NumberGroupSeparator, nfi.NumberGroupSeparator); Assert.Equal(expected.NumberGroupSizes, nfi.NumberGroupSizes); Assert.Equal(expected.NumberNegativePattern, nfi.NumberNegativePattern); Assert.Equal(expected.PercentDecimalDigits, nfi.PercentDecimalDigits); Assert.Equal(expected.PercentDecimalSeparator, nfi.PercentDecimalSeparator); Assert.Equal(expected.PercentGroupSeparator, nfi.PercentGroupSeparator); Assert.Equal(expected.PercentGroupSizes, nfi.PercentGroupSizes); Assert.Equal(expected.PercentNegativePattern, nfi.PercentNegativePattern); Assert.Equal(expected.PercentPositivePattern, nfi.PercentPositivePattern); Assert.Equal(expected.PercentSymbol, nfi.PercentSymbol); Assert.Equal(expected.PositiveInfinitySymbol, nfi.PositiveInfinitySymbol); Assert.Equal(expected.PerMilleSymbol, nfi.PerMilleSymbol); Assert.Equal(expected.PositiveSign, nfi.PositiveSign); }
public bool PosTest1() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest1: Verify default value of property CurrencyGroupSeparator ."); try { NumberFormatInfo nfi = new NumberFormatInfo(); if (nfi.CurrencyGroupSeparator != ",") { TestLibrary.TestFramework.LogError("001.1", "Property CurrencyGroupSeparator Err ."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public bool PosTest1() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest1: Verify Ctor ."); try { NumberFormatInfo nfi = new NumberFormatInfo(); if (nfi == null) { TestLibrary.TestFramework.LogError("001.1", "Failed to instance a NumberFormatInfo type ."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public bool PosTest1() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest1: Verify method GetFormat when arg is a type of NumberFormatInfo ."); try { NumberFormatInfo nfi = new NumberFormatInfo(); Type formatType = typeof(NumberFormatInfo); object obj = nfi.GetFormat(formatType); bool testVerify = obj is NumberFormatInfo; if (testVerify != true) { TestLibrary.TestFramework.LogError("001.1", "Method GetFormat ."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public void ReadOnly(NumberFormatInfo format, bool expected) { Assert.Equal(expected, format.IsReadOnly); NumberFormatInfo readOnlyFormat = NumberFormatInfo.ReadOnly(format); Assert.True(readOnlyFormat.IsReadOnly); }
public bool PosTest2() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest2: Verify method GetFormat when arg is not a type of NumberFormatInfo ."); try { NumberFormatInfo nfi = new NumberFormatInfo(); Type formatType = typeof(object); if (nfi.GetFormat(formatType) != null) { TestLibrary.TestFramework.LogError("002.1", "Failed to instance a NumberFormatInfo type ."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: Test the string with white space in both the beginning and the end"); try { int i2 = TestLibrary.Generator.GetInt32(-55); string s1 = " " + i2.ToString() + " "; NumberFormatInfo n1 = new NumberFormatInfo(); n1.NegativeSign = "#"; int i1 = Int32.Parse(s1, n1); if (i1 != i2) { 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; }
public bool PosTest1() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest1: Verify method ReadOnly ."); try { NumberFormatInfo nfi = new NumberFormatInfo(); NumberFormatInfo nfiReadOnly = NumberFormatInfo.ReadOnly(nfi); if (nfiReadOnly.IsReadOnly != true) { TestLibrary.TestFramework.LogError("001.1", "Method ReadOnly Err ."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public Boolean runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; String strBaseLoc = "Loc_0000oo_"; String strOut = null; NumberFormatInfo nfi1 = new NumberFormatInfo(); nfi1.NegativeSign = "^"; UInt64[] in2TestValues = {UInt64.MinValue, 0, 5, 13, 101, 1000, 50000, (ulong)Int32.MaxValue, (ulong)Int64.MaxValue, UInt64.MaxValue }; String[] strResultGFormat1 = {"0", "0", "5", "13", "101", "1000", "50000", "2147483647", "9223372036854775807", "18446744073709551615", }; try { strBaseLoc = "Loc_1100ds_"; for (int i=0; i < in2TestValues.Length;i++) { strLoc = strBaseLoc+ i.ToString(); iCountTestcases++; strOut = in2TestValues[i].ToString(nfi1); if(!strOut.Equals(strResultGFormat1[i])) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_293qu! , i=="+i+" strOut=="+strOut); } } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general); } if ( iCountErrors == 0 ) { Console.Error.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.Error.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
public bool DoPosTest(string testDesc, string id, UInt16 uintA, string format, String expectedValue, NumberFormatInfo _NFI) { bool retVal = true; string errorDesc; string actualValue; TestLibrary.TestFramework.BeginScenario(testDesc); try { actualValue = uintA.ToString(format, _NFI); if (actualValue != expectedValue) { errorDesc = string.Format("The string representation of {0} is not the value {1} as expected: actual({2})", uintA, expectedValue, actualValue); errorDesc += "\nThe format info is \"" + ((format == null) ? "null" : format) + "\" speicifed"; TestLibrary.TestFramework.LogError(id + "_001", errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpect exception:" + e; errorDesc += "\nThe UInt16 integer is " + uintA + ", format info is \"" + format + "\" speicifed."; TestLibrary.TestFramework.LogError(id + "_002", errorDesc); retVal = false; } return retVal; }
public RAOPClient( string Host ) { host = Host; volume = VOLUME_DEF; ajstatus = JACK_STATUS_DISCONNECTED; ajtype = JACK_TYPE_ANALOG; nfi = new CultureInfo( "en-US" ).NumberFormat; alg = Rijndael.Create(); alg.Mode = CipherMode.CBC; alg.Padding = PaddingMode.None; alg.KeySize = 128; alg.GenerateKey(); alg.GenerateIV(); int i = host.LastIndexOf( '.' ); string hostnet = host.Substring( 0, i ); IPHostEntry iphe = Dns.GetHostEntry(Dns.GetHostName());//Dns.GetHostByName( Dns.GetHostName() ); foreach( IPAddress ipaddr in iphe.AddressList ) { string s = ipaddr.ToString(); if( s.StartsWith( hostnet ) ) { local = s; break; } } if( local == null ) local = Host; }
public bool PosTest2() { bool retVal = true; // Add your scenario description here TestLibrary.TestFramework.BeginScenario("PosTest2: Verify set value of property CurrencyDecimalSeparator ."); try { string testStr = "testStr"; NumberFormatInfo nfi = new NumberFormatInfo(); nfi.CurrencyDecimalSeparator = testStr; if (nfi.CurrencyDecimalSeparator != testStr) { TestLibrary.TestFramework.LogError("002.1", "Property CurrencyDecimalSeparator Err ."); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Test the IFormatInfo parameter."); try { string s1 = " #1345"; NumberFormatInfo n1 = new NumberFormatInfo(); n1.NegativeSign = "#"; int i1 = Int32.Parse(s1, n1); if (i1 != -1345) { TestLibrary.TestFramework.LogError("001", "The result is not the value as expected. "); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e); retVal = false; } return retVal; }
void Start() { slot = GameObject.Find ("BeachDays").GetComponent<Slot>(); nfi = new CultureInfo( "en-US", false ).NumberFormat; nfi.CurrencyDecimalDigits = 0; updateUI(); }
public static IEnumerable<object[]> NumberFormatInfo_Set_TestData() { NumberFormatInfo customNumberFormatInfo1 = new NumberFormatInfo(); customNumberFormatInfo1.NegativeInfinitySymbol = "a"; yield return new object[] { "en-US", customNumberFormatInfo1 }; NumberFormatInfo customNumberFormatInfo2 = new NumberFormatInfo(); customNumberFormatInfo2.PositiveSign = "b"; yield return new object[] { "fi-FI", customNumberFormatInfo2 }; }
public static string ToStrWithPoint(this decimal? d) { var nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; //nfi.NumberGroupSeparator = "."; if (d.HasValue) return d.Value.ToString(nfi); return ""; }
public TextNumberFormat() { this.numberFormat = new NumberFormatInfo(); this.numberFormatType = 0; this.groupingActivated = true; this.separator = this.GetSeparator(0); this.maxIntDigits = 127; this.minIntDigits = 1; this.maxFractionDigits = 3; this.minFractionDigits = 0; }
public static void InitializeIFormatProvider() { nfi = new CultureInfo("en-US").NumberFormat; //For "G" // NegativeSign, NumberDecimalSeparator, NumberDecimalDigits, PositiveSign nfi.NumberDecimalDigits = 2; //Default: 2 nfi.PositiveSign = "+"; //Default: "+" nfi.NegativeSign = "-"; //Default: "-" nfi.NumberDecimalSeparator = "."; //Default: "." nfi.NaNSymbol = "NaN"; }
//private DateTimeFormatInfo mDateTimeFormat; internal CultureInfo() { mName = "en-US"; mLCID = 0x7f; mParentName = mDisplayName = mEnglishName = mNativeName = "English"; mTwoLetterISOLanguageName = "en"; mThreeLetterISOLanguageName = "eng"; mThreeLetterWindowsLanguageName = "ENU"; mCultureTypes = Globalization.CultureTypes.AllCultures; mIETFLanguageTag = "en"; mIsNeutralCulture = true; mNumberFormatInfo = NumberFormatInfo.InvariantInfo; mTextInfo = TextInfo.InvariantInfo; //mDateTimeFormat = DateTimeFormatInfo.InvariantInfo; }
static void Main() { double money = 1234567.89; Console.WriteLine("InvariantInfo: " + money.ToString("C", NumberFormatInfo.InvariantInfo)); Console.WriteLine("CurrentInfo: " + money.ToString("C", NumberFormatInfo.CurrentInfo)); NumberFormatInfo info = new NumberFormatInfo(); info.CurrencySymbol = "\x20AC"; info.CurrencyPositivePattern = 3; info.CurrencyNegativePattern = 8; Console.WriteLine("Custom Info: " + money.ToString("C", info)); }
public void Clone() { NumberFormatInfo format = new NumberFormatInfo(); format.CurrencyDecimalSeparator = "string"; NumberFormatInfo clone = (NumberFormatInfo)format.Clone(); Assert.NotEqual(format.GetHashCode(), clone.GetHashCode()); Assert.NotEqual(format, clone); Assert.NotSame(format, clone); Assert.Equal(format.CurrencyDecimalDigits, clone.CurrencyDecimalDigits); Assert.Equal(format.CurrencyDecimalSeparator, clone.CurrencyDecimalSeparator); Assert.Equal(format.CurrencyGroupSizes, clone.CurrencyGroupSizes); Assert.Equal(format.CurrencyGroupSeparator, clone.CurrencyGroupSeparator); Assert.Equal(format.CurrencyNegativePattern, clone.CurrencyNegativePattern); Assert.Equal(format.CurrencyPositivePattern, clone.CurrencyPositivePattern); Assert.Equal(format.IsReadOnly, clone.IsReadOnly); }
public bool PosTest1() { bool retVal = true; const string c_TEST_ID = "P001"; const string c_TEST_DESC = "PosTest1: Conversion to byte"; string errorDesc; byte b; object expectedObj; object actualObj; UInt16 uintA; b = TestLibrary.Generator.GetByte(-55); uintA = (UInt16)b; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { NumberFormatInfo numberFormat = new NumberFormatInfo(); IFormatProvider provider = numberFormat; IConvertible converter = uintA; expectedObj = b; actualObj = converter.ToType(typeof(byte), numberFormat); if (((byte)expectedObj != (byte)actualObj) || !(actualObj is byte)) { errorDesc = string.Format("Byte value of UInt16 {0} is not ", uintA); errorDesc += expectedObj + " as expected: Actual(" + actualObj + ")"; TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return retVal; }
public bool PosTest1() { bool retVal = true; const string c_TEST_ID = "P001"; const string c_TEST_DESC = "PosTest1: Random character"; string errorDesc; UInt16 expectedValue; UInt16 actualValue; char ch; expectedValue = (UInt16)(TestLibrary.Generator.GetInt32(-55) % (UInt16.MaxValue + 1)); ch = (char)expectedValue; TestLibrary.TestFramework.BeginScenario(c_TEST_DESC); try { NumberFormatInfo numberFormat = new NumberFormatInfo(); IFormatProvider provider = numberFormat; IConvertible converter = ch; actualValue = converter.ToUInt16(numberFormat); if (actualValue != expectedValue) { errorDesc = string.Format("UInt16 value of character \\u{0:x} is not ", (int)ch); errorDesc += expectedValue + " as expected: Actual(" + actualValue + ")"; TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } } catch (Exception e) { errorDesc = "Unexpected exception: " + e; TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc); retVal = false; } return retVal; }
static void Main() { double money = 1234567.89; string strDisplay; strDisplay = "InvariantInfo: " + money.ToString("C", NumberFormatInfo.InvariantInfo) + Environment.NewLine; strDisplay += "CurrentInfo: " + money.ToString("C", NumberFormatInfo.CurrentInfo) + Environment.NewLine; NumberFormatInfo info = new NumberFormatInfo(); info.CurrencySymbol = "\x20AC"; info.CurrencyPositivePattern = 3; info.CurrencyNegativePattern = 8; strDisplay += "Custom Info: " + money.ToString("C", info); MessageBox.Show(strDisplay, "Currency Formatting"); }
/// <summary> /// Writes the common/shared Atom feed element information to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer"> /// The <see cref="XmlWriter"/> to write channel element information to. /// </param> private void WriteAtomContentCommonElements(XmlWriter writer) { // ------------------------------------------------------------ // Write optional feed elements // ------------------------------------------------------------ writer.WriteStartElement("author"); writer.WriteElementString("name", this.Settings.AuthorName); writer.WriteEndElement(); writer.WriteStartElement("generator"); writer.WriteAttributeString("uri", GeneratorUri.ToString()); writer.WriteAttributeString("version", GeneratorVersion.ToString()); writer.WriteString(GeneratorName); writer.WriteEndElement(); // ------------------------------------------------------------ // Write blogChannel syndication extension elements // ------------------------------------------------------------ Uri blogRoll; if (Uri.TryCreate( String.Concat(Utils.AbsoluteWebRoot.ToString().TrimEnd('/'), "/opml.axd"), UriKind.RelativeOrAbsolute, out blogRoll)) { writer.WriteElementString( "blogChannel", "blogRoll", "http://backend.userland.com/blogChannelModule", blogRoll.ToString()); } if (!String.IsNullOrEmpty(this.Settings.Endorsement)) { Uri blink; if (Uri.TryCreate(this.Settings.Endorsement, UriKind.RelativeOrAbsolute, out blink)) { writer.WriteElementString( "blogChannel", "blink", "http://backend.userland.com/blogChannelModule", blink.ToString()); } } // ------------------------------------------------------------ // Write Dublin Core syndication extension elements // ------------------------------------------------------------ if (!String.IsNullOrEmpty(this.Settings.AuthorName)) { writer.WriteElementString("dc", "creator", "http://purl.org/dc/elements/1.1/", this.Settings.AuthorName); } if (!String.IsNullOrEmpty(this.Settings.Description)) { writer.WriteElementString( "dc", "description", "http://purl.org/dc/elements/1.1/", this.Settings.Description); } if (!String.IsNullOrEmpty(this.Settings.Language)) { writer.WriteElementString("dc", "language", "http://purl.org/dc/elements/1.1/", this.Settings.Language); } if (!String.IsNullOrEmpty(this.Settings.Name)) { writer.WriteElementString("dc", "title", "http://purl.org/dc/elements/1.1/", this.Settings.Name); } // ------------------------------------------------------------ // Write basic geo-coding syndication extension elements // ------------------------------------------------------------ var decimalFormatInfo = new NumberFormatInfo { NumberDecimalDigits = 6 }; if (this.Settings.GeocodingLatitude != Single.MinValue) { writer.WriteElementString( "geo", "lat", "http://www.w3.org/2003/01/geo/wgs84_pos#", this.Settings.GeocodingLatitude.ToString("N", decimalFormatInfo)); } if (this.Settings.GeocodingLongitude != Single.MinValue) { writer.WriteElementString( "geo", "long", "http://www.w3.org/2003/01/geo/wgs84_pos#", this.Settings.GeocodingLongitude.ToString("N", decimalFormatInfo)); } }
public NumberFormatProvider() { m_NumberFormat = new NumberFormatInfo(); }
public static ulong Parse(string s, IFormatProvider provider) { return(Number.ParseUInt64(s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider))); }
static JsonWriter() { number_format = NumberFormatInfo.InvariantInfo; }
public static Boolean TryParse(String s, NumberStyles style, IFormatProvider provider, out UInt64 result) { NumberFormatInfo.ValidateParseStyleInteger(style); return(Number.TryParseUInt64(s, style, NumberFormatInfo.GetInstance(provider), out result)); }
/// <devdoc> /// Convert the given value to a string using the given formatInfo /// </devdoc> internal override object FromString(string value, NumberFormatInfo formatInfo) { return(UInt64.Parse(value, NumberStyles.Integer, formatInfo)); }
public void CurrencyGroupSizes_Get_ReturnsExpected(NumberFormatInfo format, int[] expected) { Assert.Equal(expected, format.CurrencyGroupSizes); }
public MediaInfoWrapper(string strFile) { if (!MediaInfoExist()) { _mediaInfoNotloaded = true; return; } using (Settings xmlreader = new MPSettings()) { _DVDenabled = xmlreader.GetValueAsBool("dvdplayer", "mediainfoused", false); _BDenabled = xmlreader.GetValueAsBool("bdplayer", "mediainfoused", false); _ParseSpeed = xmlreader.GetValueAsString("debug", "MediaInfoParsespeed", "0.3"); // fix delay introduced after 0.7.26: http://sourceforge.net/tracker/?func=detail&aid=3013548&group_id=86862&atid=581181 } bool isTV = Util.Utils.IsLiveTv(strFile); bool isRadio = Util.Utils.IsLiveRadio(strFile); bool isRTSP = Util.Utils.IsRTSP(strFile); //rtsp for live TV and recordings. bool isDVD = Util.Utils.IsDVD(strFile); bool isVideo = Util.Utils.IsVideo(strFile); bool isAVStream = Util.Utils.IsAVStream(strFile); //other AV streams //currently disabled for all tv/radio/streaming video if (isTV || isRadio || isRTSP || isAVStream) { Log.Debug("MediaInfoWrapper: isTv:{0}, isRadio:{1}, isRTSP:{2}, isAVStream:{3}", isTV, isRadio, isRTSP, isAVStream); Log.Debug("MediaInfoWrapper: disabled for this content"); _mediaInfoNotloaded = true; return; } if (strFile.ToLowerInvariant().EndsWith(".wtv")) { Log.Debug("MediaInfoWrapper: WTV file is not handled"); _mediaInfoNotloaded = true; return; } // Check if video file is from image file string vDrive = DaemonTools.GetVirtualDrive(); string bDrive = Path.GetPathRoot(strFile); if (vDrive == Util.Utils.RemoveTrailingSlash(bDrive)) { isDVD = false; } //currently mediainfo is only used for local video related material (if enabled) if ((!isVideo && !isDVD) || (isDVD && !_DVDenabled) || (isDVD && _BDenabled)) { Log.Debug("MediaInfoWrapper: isVideo:{0}, isDVD:{1}[enabled:{2}]", isVideo, isDVD, _DVDenabled); Log.Debug("MediaInfoWrapper: disabled for this content"); _mediaInfoNotloaded = true; return; } try { _mI = new MediaInfo(); _mI.Option("ParseSpeed", _ParseSpeed); if (Util.VirtualDirectory.IsImageFile(System.IO.Path.GetExtension(strFile))) { strFile = Util.DaemonTools.GetVirtualDrive() + @"\VIDEO_TS\VIDEO_TS.IFO"; if (!File.Exists(strFile)) { strFile = Util.DaemonTools.GetVirtualDrive() + @"\BDMV\index.bdmv"; if (!File.Exists(strFile)) { _mediaInfoNotloaded = true; return; } } } if (strFile.ToLowerInvariant().EndsWith(".ifo")) { string path = Path.GetDirectoryName(strFile); string mainTitle = GetLargestFileInDirectory(path, "VTS_*1.VOB"); string titleSearch = Path.GetFileName(mainTitle); titleSearch = titleSearch.Substring(0, titleSearch.LastIndexOf('_')) + "*.VOB"; string[] vobs = Directory.GetFiles(path, titleSearch, SearchOption.TopDirectoryOnly); foreach (string vob in vobs) { int vobDuration = 0; _mI.Open(vob); int.TryParse(_mI.Get(StreamKind.General, 0, "Duration"), out vobDuration); _mI.Close(); _videoDuration += vobDuration; } // get all other info from main title's 1st vob strFile = mainTitle; } else if (strFile.ToLowerInvariant().EndsWith(".bdmv")) { string path = Path.GetDirectoryName(strFile) + @"\STREAM"; strFile = GetLargestFileInDirectory(path, "*.m2ts"); } if (strFile != null) { Log.Debug("MediaInfoWrapper.MediaInfoWrapper: Opening file : {0}", strFile); _mI.Open(strFile); } else { _mediaInfoNotloaded = true; return; } NumberFormatInfo providerNumber = new NumberFormatInfo(); providerNumber.NumberDecimalSeparator = "."; //Video double.TryParse(_mI.Get(StreamKind.Video, 0, "FrameRate"), NumberStyles.AllowDecimalPoint, providerNumber, out _framerate); int.TryParse(_mI.Get(StreamKind.Video, 0, "Width"), out _width); int.TryParse(_mI.Get(StreamKind.Video, 0, "Height"), out _height); _aspectRatio = _mI.Get(StreamKind.Video, 0, "DisplayAspectRatio"); if ((_aspectRatio == "4:3") || (_aspectRatio == "1.333")) { _aspectRatio = "fullscreen"; } else { _aspectRatio = "widescreen"; } _videoCodec = GetFullCodecName(StreamKind.Video); _scanType = _mI.Get(StreamKind.Video, 0, "ScanType").ToLowerInvariant(); _isInterlaced = _scanType.Contains("interlaced"); if (_width >= 1280 || _height >= 720) { _videoResolution = "HD"; } else { _videoResolution = "SD"; } if (_videoResolution == "HD") { if ((_width >= 7680 || _height >= 4320) && !_isInterlaced) { if (File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\4320P.png")) || File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\resolution\4320P.png"))) { _videoResolution = "4320P"; } } else if ((_width >= 3840 || _height >= 2160) && !_isInterlaced) { if (File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\2160P.png")) || File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\resolution\2160P.png"))) { _videoResolution = "2160P"; } } else if ((_width >= 1920 || _height >= 1080) && _isInterlaced) { _videoResolution = "1080I"; } else if ((_width >= 1920 || _height >= 1080) && !_isInterlaced) { _videoResolution = "1080P"; } else if ((_width >= 1280 || _height >= 720) && !_isInterlaced) { _videoResolution = "720P"; } } else { if (_height >= 576) { if (File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\576.png")) || File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\resolution\576.png"))) { _videoResolution = "576"; } } else if (_height >= 480) { if (File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\480.png")) || File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\resolution\480.png"))) { _videoResolution = "480"; } } else if (_height >= 360) { if (File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\360.png")) || File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\resolution\360.png"))) { _videoResolution = "360"; } } else if (_height >= 240) { if (File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\240.png")) || File.Exists(GUIGraphicsContext.GetThemedSkinFile(@"\Media\Logos\resolution\240.png"))) { _videoResolution = "240"; } } } if (_videoDuration == 0) { int.TryParse(_mI.Get(StreamKind.Video, 0, "Duration"), out _videoDuration); } //Audio int iAudioStreams = _mI.Count_Get(StreamKind.Audio); for (int i = 0; i < iAudioStreams; i++) { int intValue; string sChannels = _mI.Get(StreamKind.Audio, i, "Channel(s)").Split(new char[] { '/' })[0].Trim(); if (int.TryParse(sChannels, out intValue) && intValue > _audioChannels) { int.TryParse(_mI.Get(StreamKind.Audio, i, "SamplingRate"), out _audioRate); _audioChannels = intValue; _audioCodec = GetFullCodecName(StreamKind.Audio, i); } } switch (_audioChannels) { case 8: _audioChannelsFriendly = "7.1"; break; case 7: _audioChannelsFriendly = "6.1"; break; case 6: _audioChannelsFriendly = "5.1"; break; case 2: _audioChannelsFriendly = "stereo"; break; case 1: _audioChannelsFriendly = "mono"; break; default: _audioChannelsFriendly = _audioChannels.ToString(); break; } //Detection _hasAudio = _mI.Count_Get(StreamKind.Audio) > 0; _hasVideo = _mI.Count_Get(StreamKind.Video) > 0; //Subtitles _numsubtitles = _mI.Count_Get(StreamKind.Text); if (checkHasExternalSubtitles(strFile)) { _hasSubtitles = true; } else { _hasSubtitles = _numsubtitles > 0; } var sct = _mI.Count_Get(StreamKind.Text); for (var i = 0; i < sct; ++i) { var format = _mI.Get(StreamKind.Text, i, "Format").ToLowerInvariant(); _subtitleFormatsDetected.Add(format.ToLowerInvariant()); } Log.Debug("MediaInfoWrapper.MediaInfoWrapper: DLL Version : {0}", _mI.Option("Info_Version")); Log.Info("MediaInfoWrapper.MediaInfoWrapper: Inspecting media : {0}", strFile); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: Parse speed : {0}", _ParseSpeed); //Video Log.Debug("MediaInfoWrapper.MediaInfoWrapper: FrameRate : {0}", _framerate); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: Width : {0}", _width); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: Height : {0}", _height); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: AspectRatio : {0}", _aspectRatio); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: VideoCodec : {0} [ \"{1}.png\" ]", _videoCodec, Util.Utils.MakeFileName(_videoCodec).ToLowerInvariant()); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: Scan type : {0}", _scanType); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: IsInterlaced : {0}", _isInterlaced); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: VideoResolution : {0}", _videoResolution); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: VideoDuration : {0}", _videoDuration); //Audio Log.Debug("MediaInfoWrapper.MediaInfoWrapper: AudioRate : {0}", _audioRate); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: AudioChannels : {0} [ \"{1}.png\" ]", _audioChannels, _audioChannelsFriendly); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: AudioCodec : {0} [ \"{1}.png\" ]", _audioCodec, Util.Utils.MakeFileName(_audioCodec).ToLowerInvariant()); //Detection Log.Debug("MediaInfoWrapper.MediaInfoWrapper: HasAudio : {0}", _hasAudio); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: HasVideo : {0}", _hasVideo); //Subtitles Log.Debug("MediaInfoWrapper.MediaInfoWrapper: HasSubtitles : {0}", _hasSubtitles); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: NumSubtitles : {0}", _numsubtitles); } catch (Exception) { Log.Error( "MediaInfoWrapper.MediaInfoWrapper: Error occurred while scanning media: '{0}'", strFile); } finally { if (_mI != null) { _mI.Close(); Log.Debug("MediaInfoWrapper.MediaInfoWrapper: Closing file : {0}", strFile); } } }
/// <summary> /// Sets the sample customization settings. /// </summary> private void SampleCustomization() { this.sfDataGrid1.AllowEditing = true; this.sfDataGrid1.AllowGrouping = true; this.sfDataGrid1.AutoGenerateColumns = false; NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalDigits = 0; nfi.NumberGroupSizes = new int[] { }; OrderInfoRepository orderInfo = new OrderInfoRepository(); this.sfDataGrid1.DataSource = orderInfo.GetOrdersDetails(30); this.sfDataGrid1.Columns.Add(new GridNumericColumn() { MappingName = "OrderID", HeaderText = "رقم التعريف الخاص بالطلب", NumberFormatInfo = nfi }); this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "ShipCity", HeaderText = "مدينة السفن" }); this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "ShipCountry", HeaderText = "السفينة البلد" }); this.sfDataGrid1.Columns.Add(new GridDateTimeColumn() { MappingName = "ShippingDate", HeaderText = "السفينة البلد" }); this.sfDataGrid1.Columns.Add(new GridNumericColumn() { MappingName = "Freight", HeaderText = "شحن", FormatMode = FormatMode.Currency }); this.sfDataGrid1.Columns.Add(new GridCheckBoxColumn() { MappingName = "IsClosed", HeaderText = "مغلق", CheckBoxSize = new Size((int)DpiAware.LogicalToDeviceUnits(14.0f), (int)DpiAware.LogicalToDeviceUnits(14.0f)) }); #region Relation Creation GridViewDefinition viewDefinition = new GridViewDefinition(); viewDefinition.RelationalColumn = "OrderDetails"; SfDataGrid firstLevelSourceDataGrid = new SfDataGrid(); firstLevelSourceDataGrid.AutoGenerateColumns = false; firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "OrderID", HeaderText = "رقم التعريف الخاص بالطلب", NumberFormatInfo = nfi }); firstLevelSourceDataGrid.Columns.Add(new GridTextColumn() { MappingName = "Product", HeaderText = "المنتج" }); firstLevelSourceDataGrid.Columns.Add(new GridTextColumn() { MappingName = "CustomerCity", HeaderText = "مدينة العملاء" }); firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "ProductID", HeaderText = "معرف المنتج", FormatMode = FormatMode.Numeric, NumberFormatInfo = nfi }); //firstLevelSourceDataGrid.Columns.Add(new GridHyperlinkColumn() { MappingName = "HyperLink", HeaderText = "الارتباط التشعبي" }); firstLevelSourceDataGrid.Columns.Add(new GridDateTimeColumn() { MappingName = "OrderDate", HeaderText = "تاريخ الطلب" }); firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "UnitPrice", HeaderText = "سعر الوحدة", FormatMode = FormatMode.Currency }); CellStyleInfo cellStyle = new CellStyleInfo(); cellStyle.HorizontalAlignment = HorizontalAlignment.Right; firstLevelSourceDataGrid.Columns.Add(new GridUnboundColumn() { MappingName = "QuantitiesPrice", HeaderText = "المجموع الكلي", Expression = "UnitPrice * Quantity", CellStyle = cellStyle }); firstLevelSourceDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "Discount", HeaderText = "خصم", FormatMode = FormatMode.Percent }); firstLevelSourceDataGrid.Columns.Add(new GridImageColumn() { MappingName = "ImageLink", HeaderText = "بلد", ImageLayout = ImageLayout.Center }); (firstLevelSourceDataGrid.Columns["ImageLink"] as GridImageColumn).CellStyle.VerticalAlignment = System.Windows.Forms.VisualStyles.VerticalAlignment.Center; (firstLevelSourceDataGrid.Columns["ImageLink"] as GridImageColumn).CellStyle.HorizontalAlignment = HorizontalAlignment.Center; viewDefinition.DataGrid = firstLevelSourceDataGrid; this.sfDataGrid1.DetailsViewDefinitions.Add(viewDefinition); firstLevelSourceDataGrid.AutoSizeColumnsMode = AutoSizeColumnsMode.Fill; this.sfDataGrid1.AutoSizeColumnsMode = AutoSizeColumnsMode.Fill; #endregion this.sfDataGrid1.HideEmptyGridViewDefinition = true; }
public void CurrencyGroupSizes_SetInvalid_ThrowsArgumentException(int[] value) { var format = new NumberFormatInfo(); AssertExtensions.Throws <ArgumentException>("value", "CurrencyGroupSizes", () => format.CurrencyGroupSizes = value); }
private void WriteValues(XmlTextWriter writer, NumberType numType, String[] elements, String[] values, NumberFormatInfo info){ switch(numType){ case NumberType.Int: { Int64 value; for(int i=0; i<numberTable.Length; i++){ value = numberTable[i]; writer.WriteStartElement("Table"); writer.WriteElementString("Number", value.ToString(info)); for(int j=0; j<elements.Length; j++){ writer.WriteElementString(elements[j], value.ToString(values[j], info)); } writer.WriteEndElement(); } break; } case NumberType.Decimal: { Decimal value; for(int i=0; i<decimalTable.Length; i++){ value = decimalTable[i]; writer.WriteStartElement("Table"); writer.WriteElementString("Number", value.ToString(info)); for(int j=0; j<elements.Length; j++){ writer.WriteElementString(elements[j], value.ToString(values[j], info)); } writer.WriteEndElement(); } break; } case NumberType.Double: { Double value; for(int i=0; i<doubleTable.Length; i++){ value = doubleTable[i]; writer.WriteStartElement("Table"); writer.WriteElementString("Number", value.ToString("R", info)); for(int j=0; j<elements.Length; j++){ writer.WriteElementString(elements[j], value.ToString(values[j], info)); } writer.WriteEndElement(); } break; } } writer.WriteEndElement(); writer.Flush(); writer.Close(); }
public Boolean runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; String strBaseLoc = "Loc_0000oo_"; String str1 = null; SByte[] sbytTestValues = {SByte.MinValue, -13, -5, -0, 0, 5, 13, 50, 101, SByte.MaxValue }; String[] strResultGFormat1 = {"^128", "^13", "^5", "0", "0", "5", "13", "50", "101", "127" }; NumberFormatInfo nfi1 = new NumberFormatInfo(); nfi1.NegativeSign = "^"; try { strBaseLoc = "Loc_1100ds_"; for (int i=0; i < sbytTestValues.Length;i++) { strLoc = strBaseLoc + i; iCountTestcases++; str1 = sbytTestValues[i].ToString(nfi1); if(!str1.Equals(strResultGFormat1[i])) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_293qu! , i=="+i+" str1=="+str1); } } strBaseLoc = "Loc_1200er_"; for (int i=0; i < sbytTestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; str1 = sbytTestValues[i].ToString(nfi1); if(!str1.Equals(strResultGFormat1[i])) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_347ew! , i=="+i+" str1=="+str1); } } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general); } if ( iCountErrors == 0 ) { Console.Error.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.Error.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
public DecimalConverter(string separator = null) { _formatInfo = new NumberFormatInfo { NumberDecimalSeparator = separator ?? "," }; }
internal void Export(XElement xParent, XDrawingExportFormat format) { var nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; switch (format) { case XDrawingExportFormat.Canvas: var xPath = new XElement("Path", new XAttribute("StrokeThickness", Path.StrokeThickness.ToString(nfi)), new XAttribute("StrokeDashArray", DashArrayToString(Path.StrokeDashArray)), new XAttribute("StrokeDashCap", Path.StrokeDashCap), new XAttribute("StrokeDashOffset", Path.StrokeDashOffset.ToString(nfi)), new XAttribute("StrokeStartLineCap", Path.StrokeStartLineCap), new XAttribute("StrokeEndLineCap", Path.StrokeEndLineCap), new XAttribute("StrokeLineJoin", Path.StrokeLineJoin), new XAttribute("StrokeMiterLimit", Path.StrokeMiterLimit.ToString(nfi))); ExportBrush(xPath, "Stroke", Path.Stroke); ExportBrush(xPath, "Fill", Path.Fill); var xPathData = new XElement("Path.Data"); xPath.Add(xPathData); ExportGeometry(xPathData); xParent.Add(xPath); break; case XDrawingExportFormat.DrawingImage: var xGeometryDrawing = new XElement("GeometryDrawing"); ExportBrush(xGeometryDrawing, "Brush", Path.Fill); if (Path.Stroke != null) { var xPen = new XElement("Pen", new XAttribute("Thickness", Path.StrokeThickness.ToString(nfi)), new XAttribute("DashCap", Path.StrokeDashCap), new XAttribute("StartLineCap", Path.StrokeStartLineCap), new XAttribute("EndLineCap", Path.StrokeEndLineCap), new XAttribute("LineJoin", Path.StrokeLineJoin), new XAttribute("MiterLimit", Path.StrokeMiterLimit.ToString(nfi))); if (Path.StrokeDashArray != null && Path.StrokeDashArray.Count > 0) { xPen.Add(new XElement("Pen.DashStyle", new XElement("DashStyle", new XAttribute("Dashes", DashArrayToString(Path.StrokeDashArray)), new XAttribute("Offset", Path.StrokeDashOffset.ToString(nfi))))); } ExportBrush(xPen, "Brush", Path.Stroke); xGeometryDrawing.Add(new XElement("GeometryDrawing.Pen", xPen)); } var xGeometry = new XElement("GeometryDrawing.Geometry"); xGeometryDrawing.Add(xGeometry); ExportGeometry(xGeometry); xParent.Add(xGeometryDrawing); break; default: throw new ArgumentException("format not supported"); } }
/// <devdoc> /// Convert the given value from a string using the given formatInfo /// </devdoc> internal override string ToString(object value, NumberFormatInfo formatInfo) { return(((UInt64)value).ToString("G", formatInfo)); }
public void CurrencyGroupSizes_SetNull_ThrowsArgumentNullException() { var format = new NumberFormatInfo(); AssertExtensions.Throws <ArgumentNullException>("value", "CurrencyGroupSizes", () => format.CurrencyGroupSizes = null); }
public void PercentPositivePattern_Get(NumberFormatInfo format, int expected) { Assert.Equal(expected, format.PercentPositivePattern); }
private static Address ExtractReponseAddress(XPathNavigator nav) { Address address = new Address(); // lat long NumberFormatInfo provider = new NumberFormatInfo() { NumberDecimalSeparator = ".", NumberGroupSeparator = "," }; string lat = nav.SelectSingleNode(@"//*[local-name()='latitude']").Value; if (lat != null && lat.Length > 0) { address.Position.Latitude = Convert.ToDouble(lat, provider); } string lng = nav.SelectSingleNode(@"//*[local-name()='longitude']").Value; if (lng != null && lng.Length > 0) { address.Position.Longitude = Convert.ToDouble(lng, provider); } try { address.Street = nav.SelectSingleNode(@"//*[local-name()='street']").Value.Trim(); } catch (Exception) { address.Street = string.Empty; } try { address.Number = nav.SelectSingleNode(@"//*[local-name()='houseNumber']").Value.Trim(); } catch (Exception) { address.Number = string.Empty; } try { address.ZIP = nav.SelectSingleNode(@"//*[local-name()='postcode']").Value.Trim(); } catch (Exception) { address.ZIP = string.Empty; } try { address.City = nav.SelectSingleNode(@"//*[local-name()='city']").Value.Trim(); } catch (Exception) { address.City = string.Empty; } try { address.Country = nav.SelectSingleNode(@"//*[local-name()='country']").Value.Trim(); } catch (Exception) { address.Country = string.Empty; } try { address.Geohash = nav.SelectSingleNode(@"//*[local-name()='geohash']").Value.Trim(); } catch (Exception) { address.Geohash = string.Empty; } try { address.Score = nav.SelectSingleNode(@"//*[local-name()='score']").Value.Trim(); } catch (Exception) { address.Score = string.Empty; } try { address.Confidence = nav.SelectSingleNode(@"//*[local-name()='confidence']").Value.Trim(); } catch (Exception) { address.Confidence = string.Empty; } // admin areas try { address.State = address.AdminArea1 = nav.SelectSingleNode(@"//*[local-name()='state']").Value.Trim(); } catch (Exception) { address.State = address.AdminArea1 = string.Empty; } try { address.District = address.AdminArea2 = nav.SelectSingleNode(@"//*[local-name()='district']").Value.Trim(); } catch (Exception) { address.District = address.AdminArea2 = string.Empty; } return(address); }
/// <summary> /// Tries to get a <see cref="NumberFormatInfo"/> from the format /// provider, returning the current culture if it fails. /// </summary> /// <param name="formatProvider"> /// An <see cref="IFormatProvider"/> that supplies culture-specific /// formatting information. /// </param> /// <returns>A <see cref="NumberFormatInfo"/> instance.</returns> internal static NumberFormatInfo GetNumberFormatInfo(this IFormatProvider formatProvider) { return(NumberFormatInfo.GetInstance(formatProvider)); }
public String guardar(bd_simaEntitie db, FormCollection datos_notas) { Sesion sesion = new Sesion(); String guardado = "OK"; String asignatura = sesion.getMateria_nota(); String programa = sesion.getPrgrama_notas(); String grupo = sesion.getGrupo_nota(); String id_docente = sesion.getIdUsuario(); try { using (var transaccion = new TransactionScope()) { using (var contestTransaccion = new bd_simaEntitie()) { // se comprueba que las columnas contenca una nota y las filas un estuniente como minimo // se bene de restar los datos difrente a los de la tabla que vengan (datos_notas.AllKeys.ToList().Count()-1) if ((datos_notas.GetValues(0).Count() - 1 > 2) && (datos_notas.AllKeys.ToList().Count() - 1 > 2)) { List <String> cabezaTabla = datos_notas.GetValues(0).ToList(); // no se permite q el nombre de las actividades sean las misma if (cabezaTabla.Distinct().Count() == cabezaTabla.Count()) { eliminaCalificaciones(db, id_docente, programa, grupo, asignatura); calificaciones_periodo calificacion = new calificaciones_periodo { asignatura = asignatura, corte = 1, fecha_registro = DateTime.Now, grupo = grupo, id_docente = id_docente, periodo = MConfiguracionApp.getPeridoActual(db), programa = programa }; db.calificaciones_periodo.Add(calificacion); db.SaveChanges(); List <String> claves = datos_notas.AllKeys.ToList(); // cabeceras tabla int n = datos_notas.GetValues(0).Count(); double valorNota = 0; NumberFormatInfo provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = ","; /// se recorren las filas de la tabla // si se envian otros valores en el formulario, se debe de restar en el (claves.Count()-n) del primer for // siempre se suma -1 porque la ultima fila siempre esta vacia // se inicia en 1 porque la primera fila es la que contiene el nombre de las actividades for (int i = 1; i < claves.Count() - 1; i++) { List <String> dato = datos_notas.GetValues(claves[i]).ToList(); guardado = validaFila(cabezaTabla.Count(), dato, provider); if (guardado.Equals("OK")) { /// se recorren las columnas, las dos primeras columnas no se toman /// //se suma -1 porque la ultma columna siempre esta vacia for (int j = 2; j < n - 1; j++) { valorNota = Convert.ToDouble(dato[j], provider); Notas nota = new Notas { id_calificaciones_periodo = calificacion.id, id_estudiante = dato[0], tipo = cabezaTabla[j], valor = valorNota }; db.Notas.Add(nota); db.SaveChanges(); } } else { break; } } if (guardado.Equals("OK")) { MAlerta alerta = new MAlerta { creador = "SIMA", eliminada = 0, fecha_creada = DateTime.Now, mensaje = "Actualización de calificaciones del estudiante ", perfil_ver = "Administrador", tipo_alerta = "Notas", titulo = "CALIFICACIONES " + asignatura, vista = 0 }; alerta.crearAlerta(db, alerta); transaccion.Complete(); } } else { guardado = "El nombre de las actividades no pueden ser el mismo."; } } else { guardado = "Se debe de registrar como minimo una nota y un estunate antes de guardar."; } } } } catch (Exception) { guardado = "Error al guardar"; } return(guardado); }
public String ToString(IFormatProvider provider) { Contract.Ensures(Contract.Result <String>() != null); return(Number.FormatInt32(m_value, null, NumberFormatInfo.GetInstance(provider))); }
public static bool TryParse(ReadOnlySpan <char> s, out byte result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null) { NumberFormatInfo.ValidateParseStyleInteger(style); return(TryParse(s, style, NumberFormatInfo.GetInstance(provider), out result)); }
private void takefile() { DataTable table = new DataTable("CPT_EXP"); table.Locale = System.Globalization.CultureInfo.CurrentCulture; table.Columns.Add("typ", typeof(String)); table.Columns.Add("kod", typeof(String)); table.Columns.Add("nazwa", typeof(String)); table.Columns.Add("stan", typeof(String)); table.Columns.Add("cenazk", typeof(String)); table.Columns.Add("cenasp", typeof(String)); table.Columns.Add("vat", typeof(String)); //start reading the textfile StreamReader reader = new StreamReader(filename); string line; NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; while ((line = reader.ReadLine()) != null) { string[] items = line.Split(','); //make sure it has 3 items DataRow row = table.NewRow(); row["typ"] = " "; row["kod"] = items[1]; row["nazwa"] = items[0]; row["stan"] = items[3]; row["cenazk"] = (decimal.Parse(items[2], CultureInfo.InvariantCulture) / 100).ToString(nfi); row["cenasp"] = "?"; row["vat"] = "?"; table.Rows.Add(row); } reader.Close(); StringBuilder sb = new StringBuilder(); foreach (DataRow row in table.Rows) { IEnumerable <string> fields = row.ItemArray.Select(field => field.ToString()); sb.AppendLine(string.Join(";", fields)); } File.WriteAllText("inwent.exp", sb.ToString()); byte[] SendingBuffer = null; TcpClient client = null; NetworkStream netstream = null; byte[] sendorec = new byte[1]; sendorec[0] = 11; try { client = new TcpClient(ip, int.Parse(port)); netstream = client.GetStream(); netstream.Write(sendorec, 0, 1); FileStream Fs = new FileStream("inwent.exp", FileMode.Open, FileAccess.Read); int NoOfPackets = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Fs.Length) / Convert.ToDouble(1024))); int TotalLength = (int)Fs.Length, CurrentPacketLength, counter = 0; for (int i = 0; i < NoOfPackets; i++) { if (TotalLength > 1024) { CurrentPacketLength = 1024; TotalLength = TotalLength - CurrentPacketLength; } else { CurrentPacketLength = TotalLength; } SendingBuffer = new byte[CurrentPacketLength]; Fs.Read(SendingBuffer, 0, CurrentPacketLength); netstream.Write(SendingBuffer, 0, (int)SendingBuffer.Length); } Fs.Close(); netstream.Close(); client.Close(); } catch (SocketException) { MessageBox.Show("Błąd sieci. Nie można połączyć się z agentem"); } // this.Close(); }
public static ulong Parse(String s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); return(Number.ParseUInt64(s, style, NumberFormatInfo.GetInstance(provider))); }
public static bool TryParse(ReadOnlySpan <char> s, NumberStyles style, IFormatProvider?provider, out long result) { NumberFormatInfo.ValidateParseStyleInteger(style); return(Number.TryParseInt64(s, style, NumberFormatInfo.GetInstance(provider), out result) == Number.ParsingStatus.OK); }
public static ulong Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); return(Number.ParseUInt64(s, style, NumberFormatInfo.CurrentInfo)); }
public static long Parse(ReadOnlySpan <char> s, NumberStyles style = NumberStyles.Integer, IFormatProvider?provider = null) { NumberFormatInfo.ValidateParseStyleInteger(style); return(Number.ParseInt64(s, style, NumberFormatInfo.GetInstance(provider))); }
private static XDrawingShape CreateShape(XDrawing drawing, Brush fillBrush, string penThickness, string penDashCap, string penStartLineCap, string penEndLineCap, string penLineJoin, string penMiterLimit, Brush penBrush, string penDashArray, string penDashOffset, XElement xGeometry) { var nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; var path = new Path(); path.Fill = fillBrush; if (penThickness != null) { path.StrokeThickness = Double.Parse(penThickness, nfi); } if (penDashCap != null) { path.StrokeDashCap = (PenLineCap)Enum.Parse(typeof(PenLineCap), penDashCap); } if (penStartLineCap != null) { path.StrokeStartLineCap = (PenLineCap)Enum.Parse(typeof(PenLineCap), penStartLineCap); } if (penEndLineCap != null) { path.StrokeEndLineCap = (PenLineCap)Enum.Parse(typeof(PenLineCap), penEndLineCap); } if (penLineJoin != null) { path.StrokeLineJoin = (PenLineJoin)Enum.Parse(typeof(PenLineJoin), penLineJoin); } if (penMiterLimit != null) { path.StrokeMiterLimit = Double.Parse(penMiterLimit, nfi); } path.Stroke = penBrush; if (penDashArray != null) { XDrawingShape.StringToDashArray(penDashArray, path.StrokeDashArray); } if (penDashOffset != null) { path.StrokeDashOffset = Double.Parse(penDashOffset, nfi); } var types = typeof(XDrawingShape).Assembly.GetTypes(); foreach (var type in types) { if (type.IsSubclassOf(typeof(XDrawingShape))) { var attributes = type.GetCustomAttributes(typeof(XDrawGeometryAttribute), false) as XDrawGeometryAttribute[]; var geomName = xGeometry.Name.LocalName; // check if we have a TextGeometry, which is no "real" XAML node type if (String.CompareOrdinal(geomName, "GeometryGroup") == 0) { var c = xGeometry.Parent.FirstNode as XComment; if (c != null && c.Value.StartsWith("<TextGeometry")) { geomName = "TextGeometry"; } } if (attributes.Length >= 1 && String.CompareOrdinal(geomName, attributes[0].GeometryName) == 0) { var mi = type.GetMethod( "CreateFromXml", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(XDrawing), typeof(Path), typeof(XElement) }, null); if (mi == null) { throw new Exception("shape type does not support static method CreateFromXml"); } return(mi.Invoke(null, new object[] { drawing, path, xGeometry }) as XDrawingShape); } } } throw new Exception("Unknown geometry type: " + xGeometry.Name); }
/// <summary> /// Writes the common/shared RSS channel element information to the specified <see cref="XmlWriter"/>. /// </summary> /// <param name="writer"> /// The <see cref="XmlWriter"/> to write channel element information to. /// </param> private void WriteRssChannelCommonElements(XmlWriter writer) { // ------------------------------------------------------------ // Write optional channel elements // ------------------------------------------------------------ // var url = Utils.FeedUrl; // if (HttpContext.Current != null) // { // url = HttpContext.Current.Request.Url.ToString(); // } writer.WriteElementString("docs", "http://www.rssboard.org/rss-specification"); writer.WriteElementString("generator", string.Format("BlogEngine.NET {0}", BlogSettings.Instance.Version())); // writer.WriteRaw("\n<atom:link href=\"" + url + "\" rel=\"self\" type=\"application/rss+xml\" />"); if (!String.IsNullOrEmpty(this.Settings.Language)) { writer.WriteElementString("language", this.Settings.Language); } // ------------------------------------------------------------ // Write blogChannel syndication extension elements // ------------------------------------------------------------ Uri blogRoll; if (Uri.TryCreate( String.Concat(Utils.AbsoluteWebRoot.ToString().TrimEnd('/'), "/opml.axd"), UriKind.RelativeOrAbsolute, out blogRoll)) { writer.WriteElementString( "blogChannel", "blogRoll", "http://backend.userland.com/blogChannelModule", blogRoll.ToString()); } if (!String.IsNullOrEmpty(this.Settings.Endorsement)) { Uri blink; if (Uri.TryCreate(this.Settings.Endorsement, UriKind.RelativeOrAbsolute, out blink)) { writer.WriteElementString( "blogChannel", "blink", "http://backend.userland.com/blogChannelModule", blink.ToString()); } } // ------------------------------------------------------------ // Write Dublin Core syndication extension elements // ------------------------------------------------------------ if (!String.IsNullOrEmpty(this.Settings.AuthorName)) { writer.WriteElementString("dc", "creator", "http://purl.org/dc/elements/1.1/", this.Settings.AuthorName); } // if (!String.IsNullOrEmpty(this.Settings.Description)) // { // writer.WriteElementString("dc", "description", "http://purl.org/dc/elements/1.1/", this.Settings.Description); // } if (!String.IsNullOrEmpty(this.Settings.Name)) { writer.WriteElementString("dc", "title", "http://purl.org/dc/elements/1.1/", this.Settings.Name); } // ------------------------------------------------------------ // Write basic geo-coding syndication extension elements // ------------------------------------------------------------ var decimalFormatInfo = new NumberFormatInfo { NumberDecimalDigits = 6 }; if (this.Settings.GeocodingLatitude != Single.MinValue) { writer.WriteElementString( "geo", "lat", "http://www.w3.org/2003/01/geo/wgs84_pos#", this.Settings.GeocodingLatitude.ToString("N", decimalFormatInfo)); } if (this.Settings.GeocodingLongitude != Single.MinValue) { writer.WriteElementString( "geo", "long", "http://www.w3.org/2003/01/geo/wgs84_pos#", this.Settings.GeocodingLongitude.ToString("N", decimalFormatInfo)); } }
public Boolean runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; String strBaseLoc = "Loc_0000oo_"; Int32 in4a = (Int32)0; Int32 in4b = (Int32)0; String strOut = null; String str2 = null; Int32[] in4TestValues = {Int32.MinValue, -1000, -99, -5, -0, 0, 5, 13, 101, 1000, Int32.MaxValue }; NumberFormatInfo nfi1 = new NumberFormatInfo(); nfi1.CurrencySymbol = "&"; nfi1.CurrencyDecimalDigits = 3; nfi1.NegativeSign = "^"; nfi1.NumberDecimalDigits = 3; try { LABEL_860_GENERAL: do { strBaseLoc = "Loc_1100ds_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc+ i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_293qu! , i=="+i+" in4a=="+in4a); } } strBaseLoc = "Loc_1200er_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "G", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_347ew! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_1300we_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "G10", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_349ex! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_1400fs_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "C", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_832ee! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_1500ez_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "C4", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_273oi! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_1600nd_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "D", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_901sn! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_1700eu_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "D4", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_172sn! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_1800ns_"; for (int i=1; i < in4TestValues.Length-1;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "E", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_347sq! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_1900wq_"; for (int i=1; i < in4TestValues.Length-1;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "e4", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_873op! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_2000ne_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "N", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_129we! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_2100qu_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "N4", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_321sj! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_2500qi_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "F", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_815jd! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strBaseLoc = "Loc_2600qi_"; for (int i=0; i < in4TestValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); iCountTestcases++; strOut = in4TestValues[i].ToString( "F4", nfi1); in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); if(in4a != in4TestValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_193jd! , i=="+i+" in4a=="+in4a+" strOut=="+strOut); } } strOut = null; iCountTestcases++; try { in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_273qp! , in4a=="+in4a); } catch (ArgumentException aExc) {} catch (Exception exc) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_982qo! ,exc=="+exc); } strOut = "2147483648"; iCountTestcases++; try { in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_481sm! , in4a=="+in4a); } catch (OverflowException fExc) {} catch (Exception exc) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_523eu! ,exc=="+exc); } strOut ="-2147483649"; iCountTestcases++; try { in4a = Int32.Parse(strOut, NumberStyles.Any, nfi1); iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_382er! ,in4a=="+in4a); } catch (FormatException fExc) {} catch (Exception exc) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_371jy! ,exc=="+exc); } } while (false); } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general); } if ( iCountErrors == 0 ) { Console.Error.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.Error.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
private static Brush CreateBrush(string solidBrushColor, XElement xComplexBrush) { if (solidBrushColor != null) { return(new SolidColorBrush((Color)ColorConverter.ConvertFromString(solidBrushColor))); } else if (xComplexBrush != null) { var nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; GradientBrush gBrush = null; if (String.CompareOrdinal(xComplexBrush.Name.LocalName, "LinearGradientBrush") == 0) { var lBrush = new LinearGradientBrush(); if (xComplexBrush.Attribute("StartPoint") != null) { var props = xComplexBrush.Attribute("StartPoint").Value.Split(',', ' '); lBrush.StartPoint = new Point(Double.Parse(props[0], nfi), Double.Parse(props[1], nfi)); } if (xComplexBrush.Attribute("EndPoint") != null) { var props = xComplexBrush.Attribute("EndPoint").Value.Split(',', ' '); lBrush.EndPoint = new Point(Double.Parse(props[0], nfi), Double.Parse(props[1], nfi)); } gBrush = lBrush; } else if (String.CompareOrdinal(xComplexBrush.Name.LocalName, "RadialGradientBrush") == 0) { var rBrush = new RadialGradientBrush(); if (xComplexBrush.Attribute("Center") != null) { var props = xComplexBrush.Attribute("Center").Value.Split(',', ' '); rBrush.Center = new Point(Double.Parse(props[0], nfi), Double.Parse(props[1], nfi)); } if (xComplexBrush.Attribute("GradientOrigin") != null) { var props = xComplexBrush.Attribute("GradientOrigin").Value.Split(',', ' '); rBrush.GradientOrigin = new Point(Double.Parse(props[0], nfi), Double.Parse(props[1], nfi)); } if (xComplexBrush.Attribute("RadiusX") != null) { rBrush.RadiusX = Double.Parse(xComplexBrush.Attribute("RadiusX").Value, nfi); } if (xComplexBrush.Attribute("RadiusY") != null) { rBrush.RadiusY = Double.Parse(xComplexBrush.Attribute("RadiusY").Value, nfi); } gBrush = rBrush; } else { throw new Exception("Unknwon complex brush type: " + xComplexBrush.Name.LocalName); } if (gBrush != null) { var xStops = from s in xComplexBrush.Elements("GradientStop") select new { Offset = (string)s.Attributes("Offset").FirstOrDefault(), Color = (string)s.Attributes("Color").FirstOrDefault() }; foreach (var s in xStops) { var stop = new GradientStop(); if (s.Offset != null) { stop.Offset = Double.Parse(s.Offset, nfi); } if (s.Color != null) { stop.Color = (Color)ColorConverter.ConvertFromString(s.Color); } gBrush.GradientStops.Add(stop); } return(gBrush); } } return(null); }
public Boolean runTest() { Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; String strBaseLoc = "Loc_0000oo_"; SByte sbyt1a = 0; String str1 = null; String str2 = null; SByte[] sbytExpValues = {SByte.MinValue, -13, -5, -0, 0, 5, 13, 50, 101, SByte.MaxValue }; String[] strCFormat1Values = {"(&128.000)", "(&13.000)", "(&5.000)", "&0.000", "&0.000", "&5.000", "&13.000", "&50.000", "&101.000", "&127.000", }; String[] strCFormat2Values = {"(&128.0000)", "(&13.0000)", "(&5.0000)", "&0.0000", "&0.0000", "&5.0000", "&13.0000", "&50.0000", "&101.0000", "&127.0000", }; String[] strDFormat1Values = {"^128", "^13", "^5", "0", "0", "5", "13", "50", "101", "127" }; String[] strDFormat2Values = {"^0128", "^0013", "^0005", "0000", "0000", "0005", "0013", "0050", "0101", "0127" }; String[] strEFormat1Values = {"^1.280000E+002", "^1.300000E+001", "^5.000000E+000", "0.000000E+000", "0.000000E+000", "5.000000E+000", "1.300000E+001", "5.000000E+001", "1.010000E+002", "1.270000E+002", }; String[] strEFormat2Values = {"^1.2800e+002", "^1.3000e+001", "^5.0000e+000", "0.0000e+000", "0.0000e+000", "5.0000e+000", "1.3000e+001", "5.0000e+001", "1.0100e+002", "1.2700e+002", }; String[] strFFormat1Values = {"^128.000", "^13.000", "^5.000", "0.000", "0.000", "5.000", "13.000", "50.000", "101.000", "127.000" }; String[] strFFormat2Values = {"^128.0000", "^13.0000", "^5.0000", "0.0000", "0.0000", "5.0000", "13.0000", "50.0000", "101.0000", "127.0000" }; String[] strGFormat1Values = {"^128", "^13", "^5", "0", "0", "5", "13", "50", "101", "127" }; String[] strGFormat2Values = {"^128", "^13", "^5", "0", "0", "5", "13", "50", "101", "127" }; String[] strNFormat1Values = {"^128.000", "^13.000", "^5.000", "0.000", "0.000", "5.000", "13.000", "50.000", "101.000", "127.000" }; String[] strNFormat2Values = {"^128.0000", "^13.0000", "^5.0000", "0.0000", "0.0000", "5.0000", "13.0000", "50.0000", "101.0000", "127.0000" }; NumberFormatInfo nfi1 = new NumberFormatInfo(); nfi1.CurrencyDecimalDigits = 3; nfi1.CurrencySymbol = "&"; nfi1.NegativeSign = "^"; nfi1.NumberDecimalDigits = 3; try { LABEL_860_GENERAL: do { strBaseLoc = "Loc_1100ds_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strGFormat1Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_293qu! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_1300we_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); sbyt1a = SByte.Parse(strGFormat2Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_349ex! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_1400fs_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strCFormat1Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_832ee! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_1500ez_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strCFormat2Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_273oi! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_1600nd_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strDFormat1Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_901sn! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_1700eu_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strDFormat2Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_172sn! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_1800ns_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strEFormat1Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_347sq! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_1900wq_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strEFormat2Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_873op! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_2000ne_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strNFormat1Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_129we! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_2100qu_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strNFormat2Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_321sj! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_2500qi_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i; sbyt1a = SByte.Parse(strFFormat1Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_815jd! , i==" + i + " sbyt1a==" + sbyt1a); } } strBaseLoc = "Loc_2600qi_"; for (int i=0; i < sbytExpValues.Length;i++) { strLoc = strBaseLoc + i.ToString(); sbyt1a = SByte.Parse(strFFormat2Values[i], NumberStyles.Any, nfi1); iCountTestcases++; if(sbyt1a != sbytExpValues[i]) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_193jd! , i==" + i + " sbyt1a==" + sbyt1a); } } try { str1 = null; sbyt1a = SByte.Parse(str1, NumberStyles.Any, nfi1); iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_903xr! Exception not thrown"); } catch (ArgumentException ex) { } catch (Exception ex) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_683dr! wrong exception thrown " + ex); } try { str1 = "1.300000E+001"; sbyt1a = SByte.Parse(str1, NumberStyles.Integer, nfi1); iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_932se! Exception not thrown"); } catch (FormatException ex) { } catch (Exception ex) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_015ze! wrong exception thrown " + ex); } try { str1 = "128"; sbyt1a = SByte.Parse(str1, NumberStyles.Any, nfi1); iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_867sq! Exception not thrown"); } catch (OverflowException ex) { } catch (Exception ex) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_106ep! wrong exception thrown " + ex); } try { str1 = "-129"; sbyt1a = SByte.Parse(str1, NumberStyles.Any, nfi1); iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_024xw! Exception not thrown"); } catch (FormatException ex) { } catch (Exception ex) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_105xp! wrong exception thrown " + ex); } try { str1 = "gibberish-129"; sbyt1a = SByte.Parse(str1, NumberStyles.Any, nfi1); iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_204es! Exception not thrown"); } catch (FormatException ex) { } catch (Exception ex) { iCountErrors++; Console.WriteLine(s_strTFAbbrev+ "Err_104nu! wrong exception thrown " + ex); } } while (false); } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general); } if ( iCountErrors == 0 ) { Console.Error.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.Error.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
public String ToString(String format, IFormatProvider provider) { Contract.Ensures(Contract.Result <String>() != null); return(ToString(format, NumberFormatInfo.GetInstance(provider))); }
public Boolean runTest() { Console.WriteLine( s_strTFPath +" "+ s_strTFName +" ,for "+ s_strComponentBeingTested +" ,Source ver "+ s_strDtTmVer ); try { m_strLoc = "Loc_normalTests"; NumberFormatInfo nfi = new NumberFormatInfo(); UInt16[] primativeUShort = { 0, 100, 1000, 10000, UInt16.MaxValue, UInt16.MinValue, unchecked((UInt16)(-10)), unchecked((UInt16)(-1 * UInt16.MaxValue)) }; String[] currencyResults = new String[ primativeUShort.Length ]; String[] decimalResults = new String[ primativeUShort.Length ]; String[] fixedResults = new String[ primativeUShort.Length ]; String[] generalResults = new String[ primativeUShort.Length ]; String[] numberResults = new String[ primativeUShort.Length ]; String[] sciResults = new String[ primativeUShort.Length ]; String[] hexResults = new String[ primativeUShort.Length ]; UInt16 bb; UInt16 div; UInt16 remainder; Char ch; int[] Cgroups = nfi.CurrencyGroupSizes; int[] Ngroups = nfi.NumberGroupSizes; String currencyTemp; String numberTemp; String sciTemp; String sciExp; int sciExponent; for( int i = 0; i < primativeUShort.Length; i++ ) { sciTemp = "" + primativeUShort[i] ; sciResults[i] = sciTemp[0] + nfi.NumberDecimalSeparator; sciTemp = sciTemp.Substring( 1 ); sciExponent = sciTemp.Length; sciTemp = sciTemp.PadRight( 6, '0' ); sciTemp = sciTemp.Substring( 0 , 6 ); sciExp = "" + sciExponent ; sciExp = sciExp.PadLeft( 3, '0' ); sciExp = sciExp.Substring( sciExp.Length - 3 ); sciResults[i] = sciResults[i] + sciTemp + "E" + nfi.PositiveSign + sciExp; currencyTemp = "" + primativeUShort[i] ; currencyResults[i] = currencyTemp; if ( Cgroups[0] > 0 ) { if ( currencyTemp.Length > Cgroups[0] ) { currencyResults[i] = ""; for( int j = (currencyTemp.Length - Cgroups[0]); j > 0; j = j - Cgroups[0] ) { currencyResults[i] = nfi.CurrencyGroupSeparator + currencyTemp.Substring( j, Cgroups[0] ) + currencyResults[i]; currencyTemp = currencyTemp.Substring(0,j); } currencyResults[i] = currencyTemp + currencyResults[i]; } } currencyResults[i] = nfi.CurrencySymbol + currencyResults[i] + nfi.CurrencyDecimalSeparator + "".PadRight( nfi.CurrencyDecimalDigits, '0' ) ; numberTemp = "" + primativeUShort[i] ; numberResults[i] = numberTemp; if ( Ngroups[0] > 0 ) { if ( numberTemp.Length > Ngroups[0] ) { numberResults[i] = ""; for( int j = (numberTemp.Length - Ngroups[0]); j > 0; j = j - Ngroups[0] ) { numberResults[i] = nfi.NumberGroupSeparator + numberTemp.Substring( j, Ngroups[0] ) + numberResults[i]; numberTemp = numberTemp.Substring(0,j); } numberResults[i] = numberTemp + numberResults[i]; } } numberResults[i] = numberResults[i] + nfi.NumberDecimalSeparator + "".PadRight( nfi.NumberDecimalDigits, '0' ); decimalResults[i] = primativeUShort[i] + ""; fixedResults[i] = primativeUShort[i] + "." + "".PadRight( nfi.NumberDecimalDigits, '0' ); generalResults[i] = primativeUShort[i] + ""; bb = primativeUShort[i]; hexResults[i] = "" ; while ( bb > 0 ) { div = (UInt16)(bb/16); remainder = (UInt16)(bb%16); if ( remainder < 10 ) hexResults[i] = remainder + hexResults[i]; else { switch( remainder ) { case 10 : ch = 'a'; break; case 11 : ch = 'b'; break; case 12 : ch = 'c'; break; case 13 : ch = 'd'; break; case 14 : ch = 'e'; break; case 15 : ch = 'f'; break; default: ch = ' '; break; } hexResults[i] = ch + hexResults[i]; } bb = div; } if ( hexResults[i].Equals( "" ) ) hexResults[i] = "0"; } for( int i = 0; i < primativeUShort.Length; i++ ) { try { iCountTestcases++; m_strLoc = "Starting testgroup #C." + iCountTestcases; m_strLoc = m_strLoc + "->" + currencyResults[i]; String strPrimitiveCurrency = primativeUShort[i].ToString( "C") ; strPrimitiveCurrency = strPrimitiveCurrency.Replace("$" , new String( new char[]{(char)164} ) ); if ( strPrimitiveCurrency.Equals( currencyResults[i] ) != true ) ErrorCode(primativeUShort[i].ToString( "C")); } catch( Exception e ) { iCountErrors++; Console.WriteLine( "Testcase["+iCountTestcases+"]" ); Console.WriteLine( "Exception:" + e ); Console.WriteLine( "StrLoc = '"+m_strLoc+"'" ); } } for( int i = 0; i < primativeUShort.Length; i++ ) { try { iCountTestcases++; m_strLoc = "Starting testgroup #D." + iCountTestcases; m_strLoc = m_strLoc + "->" + decimalResults[i]; if ( primativeUShort[i].ToString( "D").Equals( decimalResults[i] ) != true ) ErrorCode(primativeUShort[i].ToString( "d")); } catch( Exception e ) { iCountErrors++; Console.WriteLine( "Testcase["+iCountTestcases+"]" ); Console.WriteLine( "Exception:" + e ); Console.WriteLine( "StrLoc = '"+m_strLoc+"'" ); } } for( int i = 0; i < primativeUShort.Length; i++ ) { try { iCountTestcases++; m_strLoc = "Starting testgroup #E." + iCountTestcases; m_strLoc = m_strLoc + "->" + sciResults[i]; if ( primativeUShort[i].ToString( "E").Equals( sciResults[i] ) != true ) ErrorCode(primativeUShort[i].ToString( "E")); } catch( Exception e ) { iCountErrors++; Console.WriteLine( "Testcase["+iCountTestcases+"]" ); Console.WriteLine( "Exception:" + e ); Console.WriteLine( "StrLoc = '"+m_strLoc+"'" ); } } for( int i = 0; i < primativeUShort.Length; i++ ) { try { iCountTestcases++; m_strLoc = "Starting testgroup #F." + iCountTestcases; m_strLoc = m_strLoc + "->" + fixedResults[i]; if ( primativeUShort[i].ToString( "f").Equals( fixedResults[i] ) != true ) ErrorCode(primativeUShort[i].ToString( "F")); } catch( Exception e ) { iCountErrors++; Console.WriteLine( "Testcase["+iCountTestcases+"]" ); Console.WriteLine( "Exception:" + e ); Console.WriteLine( "StrLoc = '"+m_strLoc+"'" ); } } for( int i = 0; i < primativeUShort.Length; i++ ) { try { iCountTestcases++; m_strLoc = "Starting testgroup #G." + iCountTestcases; m_strLoc = m_strLoc + "->" + generalResults[i]; if ( primativeUShort[i].ToString( "G").Equals( generalResults[i] ) != true ) ErrorCode(primativeUShort[i].ToString( "g")); } catch( Exception e ) { iCountErrors++; Console.WriteLine( "Testcase["+iCountTestcases+"]" ); Console.WriteLine( "Exception:" + e ); Console.WriteLine( "StrLoc = '"+m_strLoc+"'" ); } } for( int i = 0; i < primativeUShort.Length; i++ ) { try { iCountTestcases++; m_strLoc = "Starting testgroup #N." + iCountTestcases; m_strLoc = m_strLoc + "->" + numberResults[i]; if ( primativeUShort[i].ToString( "n").Equals( numberResults[i] ) != true ) ErrorCode(primativeUShort[i].ToString( "n")); } catch( Exception e ) { iCountErrors++; Console.WriteLine( "Testcase["+iCountTestcases+"]" ); Console.WriteLine( "Exception:" + e ); Console.WriteLine( "StrLoc = '"+m_strLoc+"'" ); } } for( int i = 0; i < primativeUShort.Length; i++ ) { try { iCountTestcases++; m_strLoc = "Starting testgroup #X." + iCountTestcases; m_strLoc = m_strLoc + "->" + hexResults[i]; if ( primativeUShort[i].ToString( "x").Equals( hexResults[i] ) != true ) ErrorCode(primativeUShort[i].ToString( "X")); } catch( Exception e ) { iCountErrors++; Console.WriteLine( "Testcase["+iCountTestcases+"]" ); Console.WriteLine( "Exception:" + e ); Console.WriteLine( "hexResults[" + i + "] = '" + hexResults[i] + "'" ); Console.WriteLine( "StrLoc = '"+m_strLoc+"'" ); } } } catch( Exception exc_general ) { ++iCountErrors; Console.WriteLine( "Error Err_8888yyy ("+ s_strTFAbbrev +")! Unexpected exception thrown sometime after m_strLoc=="+ m_strLoc +" ,exc_general=="+ exc_general ); } Console.Write(Environment.NewLine); Console.WriteLine( "Total Tests Ran: " + iCountTestcases + " Failed Tests: " + iCountErrors ); if ( iCountErrors == 0 ) { Console.WriteLine( "paSs. "+ s_strTFPath +" "+ s_strTFName +" ,iCountTestcases=="+ iCountTestcases ); return true; } else { Console.WriteLine( "FAiL! "+ s_strTFPath +" "+ s_strTFName +" ,iCountErrors=="+ iCountErrors +" ,BugNums?: "+ s_strActiveBugNums ); return false; } }
public static sbyte Parse(String s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); return(Parse(s, style, NumberFormatInfo.CurrentInfo)); }