Exemple #1
0
    public static void Main()
    {
        int   n1 = 10; // 결국 .net Framework 의 Int32입니다.
        Int32 n2 = 10; // CTS : Common Type System
                       // CLR 에서 정의된 타입

        // C++ int => CLR Int32
        // C#  int => CLR Int32

        Type t1 = n1.GetType();
        Type t2 = n2.GetType();

        Console.WriteLine(t1.Name);
        Console.WriteLine(t2.Name);
    }
    public static void Main(string[] args)
    {
        var price = 10000; // int price = 10000;

        Console.WriteLine(price == 10000);
        Console.WriteLine(price.GetType().ToString() == "System.Int32");

        Int32 i32 = 10000;

        Console.WriteLine(i32.GetType().ToString() == "System.Int32");

        object obj = 70;

        Console.WriteLine(obj.GetType().ToString() == "System.Int32");
    }
Exemple #3
0
        static void Main(string[] args)
        {
            string name     = "What's ur name?";
            Int32  length   = 32;
            bool   isRabbit = true;

            Type nameType     = name.GetType();
            Type lenType      = length.GetType();
            Type isRabbitType = isRabbit.GetType();

            Console.WriteLine("name's type is: " + nameType.ToString());
            Console.WriteLine("length's type is: " + lenType.ToString());
            Console.WriteLine("isRabbit's type is: " + isRabbitType.ToString());
            Console.ReadLine();
            return;
        }
Exemple #4
0
        public void TestInt32()
        {
            FileStream       stream     = new FileStream("Prova.bin", System.IO.FileMode.Create);
            CompactFormatter CFormatter = new CompactFormatter();

            long start = DateTime.Now.Ticks;

            Int32 s = 0;

            Console.WriteLine(
                "Serializing and Deserializing {0} instances of type {1}",
                max, s.GetType().ToString()
                );

            for (int i = 0; i < max; i++)
            {
                CFormatter.Serialize(stream, s);
                //Console.WriteLine("Serialized {0}",s);
                s++;
            }
            stream.Flush();
            stream.Close();

            stream = new FileStream("Prova.bin", System.IO.FileMode.Open);
            CompactFormatter CFormatter2 = new CompactFormatter();

            Int32[] temp = new Int32[max];

            for (int i = 0; i < max; i++)
            {
                temp[i] = (Int32)CFormatter2.Deserialize(stream);
            }
            stream.Close();

            long stop = DateTime.Now.Ticks;
            long ts   = stop - start;

            Console.WriteLine("Elapsed Time:{0},{1},{2}", ts, start, stop);

            s = 0;
            for (int i = 0; i < max; i++)
            {
                //Console.WriteLine("Deserialized {0}",temp[i]);
                Assert.AreEqual(temp[i], s);
                s++;
            }
        }
Exemple #5
0
        public static void GetInstanceInformation()
        {
            String  dataSource        = Utility.DBConnection.DataSource;
            Int32   packetSize        = Utility.DBConnection.PacketSize;
            String  serverVersion     = Utility.DBConnection.ServerVersion;
            Boolean statisticsEnabled = Utility.DBConnection.StatisticsEnabled;
            String  workstationId     = Utility.DBConnection.WorkstationId;

            instanceInformation.Columns.Clear();
            instanceInformation.Columns.Add("dataSource", dataSource.GetType());
            instanceInformation.Columns.Add("packetSize", packetSize.GetType());
            instanceInformation.Columns.Add("serverVersion", serverVersion.GetType());
            instanceInformation.Columns.Add("statisticsEnabled", statisticsEnabled.GetType());
            instanceInformation.Columns.Add("workstationId", workstationId.GetType());
            instanceInformation.Rows.Add(dataSource, packetSize, serverVersion, statisticsEnabled, workstationId);
            //Utility.PrintDatatable(instanceInformation);
        }
    public static void Main(string [] args)
    {
        var price = 10000; // => int price = 10000; value type <<

        // 컴파일 시점에 자동으로 변경

        Console.WriteLine(price == 10000);
        Console.WriteLine(price.GetType().ToString() == "System.Int32");

        Int32 i32 = 10000;

        Console.WriteLine(i32.GetType().ToString() == "System.Int32");

        object obj = 70;  // ref type <<

        Console.WriteLine(obj.GetType().ToString() == "System.Int32");
    }
Exemple #7
0
        public void SystemType6_GetElementType_Test()
        {
            OutputHelper.WriteLine("This tests the GetElementType() method");

            //Assigned and manipulated to avoid compiler warning
            Int32 testInt32 = -1;

            testInt32++;

            Type myType1 = Type.GetType("System.Int32");

            OutputHelper.WriteLine("The full name is " + myType1.FullName);
            Int32[] int32Arr     = new Int32[] { };
            Type    int32ArrType = int32Arr.GetType();

            Assert.IsType(myType1, int32ArrType.GetElementType());

            Assert.True(myType1.GetElementType() == null);
        }
Exemple #8
0
        internal int SetPrjSch_Insert(string EnvironmentName, string insertSetPrjSch, int CKy, int UsrKy)
        {
            string actionUri = "SetPrjSch_Insert";
            Dictionary <string, object> paramDictionary = new Dictionary <string, object>();

            paramDictionary.Add("insertSetPrjSch", insertSetPrjSch);
            paramDictionary.Add("CKy", CKy);
            paramDictionary.Add("UsrKy", UsrKy);

            Int32  listInt32 = new Int32();
            object list      = RunApiOperation(
                ganttChartBaseUri,
                actionUri,
                EnvironmentName,
                paramDictionary,
                listInt32.GetType());

            listInt32 = Convert.ToInt32(list);
            return(listInt32);
        }
Exemple #9
0
        internal int ProjectsHeader_InsertWeb(string EnvironmentName, int CKy, int UsrKy, string ProjectsHeaderDetails)
        {
            string actionUri = "ProjectsHeader_InsertWeb";
            Dictionary <string, object> paramDictionary = new Dictionary <string, object>();

            paramDictionary.Add("CKy", CKy);
            paramDictionary.Add("UsrKy", UsrKy);
            paramDictionary.Add("ProjectsHeaderDetails", ProjectsHeaderDetails);

            Int32  listInt32 = new Int32();
            object list      = RunApiOperation(
                ganttChartBaseUri,
                actionUri,
                EnvironmentName,
                paramDictionary,
                listInt32.GetType());

            listInt32 = Convert.ToInt32(list);
            return(listInt32);
        }
Exemple #10
0
 public void FillData(DataRow row)
 {
     mvarProductID           = Int32.Parse(clsCommon.GetValue(row["ProductID"], mvarProductID.GetType().FullName).ToString());
     mvarProductTypeID       = Int32.Parse(clsCommon.GetValue(row["ProductTypeID"], mvarProductTypeID.GetType().FullName).ToString());
     mvarProductCategoryID   = Int32.Parse(clsCommon.GetValue(row["ProductCategoryID"], mvarProductCategoryID.GetType().FullName).ToString());
     mvarProductGroupID      = Int32.Parse(clsCommon.GetValue(row["ProductGroupID"], mvarProductGroupID.GetType().FullName).ToString());
     mvarProductName         = clsCommon.GetValue(row["ProductName"], mvarProductName.GetType().FullName).ToString();
     mvarLeavingFrom         = Int32.Parse(clsCommon.GetValue(row["LeavingFrom"], mvarLeavingFrom.GetType().FullName).ToString());
     mvarGoingTo             = Int32.Parse(clsCommon.GetValue(row["GoingTo"], mvarGoingTo.GetType().FullName).ToString());
     mvarBrandID             = Int32.Parse(clsCommon.GetValue(row["BrandID"], mvarBrandID.GetType().FullName).ToString());
     mvarProductEffectedDate = DateTime.Parse(clsCommon.GetValue(row["ProductEffectedDate"], mvarProductEffectedDate.GetType().FullName).ToString());
     mvarProductPrice        = float.Parse(clsCommon.GetValue(row["ProductPrice"], mvarProductPrice.GetType().FullName).ToString());
     mvarProductContent      = clsCommon.GetValue(row["ProductContent"], mvarProductContent.GetType().FullName).ToString();
     mvarProductImage        = clsCommon.GetValue(row["ProductImage"], mvarProductImage.GetType().FullName).ToString();
     mvarProductStatus       = Int32.Parse(clsCommon.GetValue(row["ProductStatus"], mvarProductStatus.GetType().FullName).ToString());
     mvarCreatedBy           = Int32.Parse(clsCommon.GetValue(row["CreatedBy"], mvarCreatedBy.GetType().FullName).ToString());
     mvarCreatedDate         = DateTime.Parse(clsCommon.GetValue(row["CreatedDate"], mvarCreatedDate.GetType().FullName).ToString());
     mvarLastUpdatedBy       = Int32.Parse(clsCommon.GetValue(row["LastUpdatedBy"], mvarLastUpdatedBy.GetType().FullName).ToString());
     mvarLastUpdatedDate     = DateTime.Parse(clsCommon.GetValue(row["LastUpdatedDate"], mvarLastUpdatedDate.GetType().FullName).ToString());
 }
Exemple #11
0
        public MFTestResults SystemType10_GetMethod_Test()
        {
            /// <summary>
            ///  1. Test the GetMethod(String) method
            ///  2. Test the GetMethod(String,BindingFlags) method
            ///  This test is currently a stub
            ///  TODO: Write test #2 once bug 17246 is resolved
            /// </summary>
            ///
            bool testResult = true;

            try
            {
                Log.Comment("This tests the GetMethod(String) method");
                Log.Comment("This test must be re-written once BindingFlags is working, ");
                Log.Comment("see 17246 for more details.");

                Int32 I = 0;
                I++;
                TestObject2 testTestObject2 = new TestObject2(5);
                Type        myType2         = testTestObject2.GetType();
                Log.Comment("The full name is " + myType2.FullName);
                MethodInfo methodInfo1 = myType2.GetMethod("Method2");
                testResult &= (methodInfo1.IsAbstract == false);
                testResult &= (methodInfo1.IsFinal == false);
                testResult &= (methodInfo1.IsPublic == true);
                testResult &= (methodInfo1.IsStatic == false);
                testResult &= (methodInfo1.IsVirtual == false);
                testResult &= (methodInfo1.MemberType == MemberTypes.Method);
                testResult &= (methodInfo1.Name == "Method2");
                testResult &= (methodInfo1.ReturnType == I.GetType());
                testResult &= (methodInfo1.DeclaringType == myType2);
                testResult &=
                    ((int)(methodInfo1.Invoke(testTestObject2, new object[] { 1 })) == 1);
            }
            catch (Exception e)
            {
                Log.Comment("Typeless " + e.Message); testResult = false;
            }
            return(testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
Exemple #12
0
        //PrcsSch_DeleteWeb(HTNSession.Environment, PrjKy, PrcsSchKy, CKy, UsrKy)
        internal int PrcsSchHdr_DeleteWeb(string EnvironmentName, int PrjKy, int PrcsSchKy, int CKy, int UsrKy)
        {
            string actionUri = "PrcsSchHdr_DeleteWeb";
            Dictionary <string, object> paramDictionary = new Dictionary <string, object>();

            paramDictionary.Add("PrjKy", PrjKy);
            paramDictionary.Add("PrcsSchKy", PrcsSchKy);
            paramDictionary.Add("CKy", CKy);
            paramDictionary.Add("UsrKy", UsrKy);

            Int32  listInt32 = new Int32();
            object list      = RunApiOperation(
                ganttChartBaseUri,
                actionUri,
                EnvironmentName,
                paramDictionary,
                listInt32.GetType());

            listInt32 = Convert.ToInt32(list);
            return(listInt32);
        }
Exemple #13
0
            public GetModelResponse(string hexString)
            {
                hexAddress = new List <String>();
                types      = new List <Type>
                {
                    address.GetType(),
                        bounty.GetType(),
                        initialError.GetType(),
                        targetError.GetType(),
                        hexAddress.GetType()
                };

                var objects = EthereumAbiUtil.GetParametersHex(hexString, numParameters, types);

                address      = (String)objects[0];
                bounty       = (Int32)objects[1];
                initialError = (Int32)objects[2];
                targetError  = (Int32)objects[3];
                hexAddress   = (List <String>)objects[4];
                MakeIPFSHash();
            }
 public void FillData(DataRow row)
 {
     mvarUserID           = Int32.Parse(clsCommon.GetValue(row["UserID"], mvarUserID.GetType().FullName).ToString());
     mvarUserName         = clsCommon.GetValue(row["UserName"], mvarUserName.GetType().FullName).ToString();
     mvarSALT             = clsCommon.GetValue(row["SALT"], mvarSALT.GetType().FullName).ToString();
     mvarUserPassword     = clsCommon.GetValue(row["UserPassword"], mvarUserPassword.GetType().FullName).ToString();
     mvarFullName         = clsCommon.GetValue(row["FullName"], mvarFullName.GetType().FullName).ToString();
     mvarOriginalPassword = clsCommon.GetValue(row["OriginalPassword"], mvarOriginalPassword.GetType().FullName).ToString();
     mvarGender           = Boolean.Parse(clsCommon.GetValue(row["Gender"], mvarGender.GetType().FullName).ToString());
     mvarUserAddress      = clsCommon.GetValue(row["UserAddress"], mvarUserAddress.GetType().FullName).ToString();
     mvarDeskphoneNo      = clsCommon.GetValue(row["DeskphoneNo"], mvarDeskphoneNo.GetType().FullName).ToString();
     mvarPhoneNo          = clsCommon.GetValue(row["PhoneNo"], mvarPhoneNo.GetType().FullName).ToString();
     mvarEmailAddress     = clsCommon.GetValue(row["EmailAddress"], mvarEmailAddress.GetType().FullName).ToString();
     mvarSkypeAccount     = clsCommon.GetValue(row["SkypeAccount"], mvarSkypeAccount.GetType().FullName).ToString();
     mvarIsConsultant     = Boolean.Parse(clsCommon.GetValue(row["IsConsultant"], mvarIsConsultant.GetType().FullName).ToString());
     mvarUserImage        = clsCommon.GetValue(row["UserImage"], mvarUserImage.GetType().FullName).ToString();
     mvarCreatedBy        = Int32.Parse(clsCommon.GetValue(row["CreatedBy"], mvarCreatedBy.GetType().FullName).ToString());
     mvarCreatedDate      = DateTime.Parse(clsCommon.GetValue(row["CreatedDate"], mvarCreatedDate.GetType().FullName).ToString());
     mvarLastUpdatedBy    = Int32.Parse(clsCommon.GetValue(row["LastUpdatedBy"], mvarLastUpdatedBy.GetType().FullName).ToString());
     mvarLastUpdatedDate  = DateTime.Parse(clsCommon.GetValue(row["LastUpdatedDate"], mvarLastUpdatedDate.GetType().FullName).ToString());
 }
Exemple #15
0
        static void Main(string[] args)
        {
            bool    isTrue  = true;
            Boolean isFalse = false;
            short   sh1     = 5;
            Int16   sh2     = 6;
            int     i1      = 33;
            Int32   i2      = 22;
            long    l1      = 4444;
            Int64   l2      = 5555;
            byte    b1      = 12;
            Byte    b2      = 13;
            float   f1      = 66.66f;
            Single  f2      = 77.77f;
            double  d1      = 888.888;
            Double  d2      = 878.788;
            decimal dec1    = 99999999.99M;
            Decimal dec2    = 9888999.98M;
            object  o1      = new object[1, 2, 3];
            Object  o2      = new Object[3, 2, 1];
            char    ch1     = 'A';
            Char    ch2     = 'B';
            string  s1      = "Hello there!";
            String  s2      = "General Kenobi!";

            Console.WriteLine($"Bool:\n C#: {isTrue.GetType()}\n CLR: {isFalse.GetType()}");
            Console.WriteLine($"Short:\n C#: {sh1.GetType()}\n CLR: {sh2.GetType()}");
            Console.WriteLine($"Int:\n C#: {i1.GetType()}\n CLR: {i2.GetType()}");
            Console.WriteLine($"Long:\n C#: {l1.GetType()}\n CLR: {l2.GetType()}");
            Console.WriteLine($"Byte:\n C#: {b1.GetType()}\n CLR: {b2.GetType()}");
            Console.WriteLine($"Float:\n C#: {f1.GetType()}\n CLR: {f2.GetType()}");
            Console.WriteLine($"Double:\n C#: {d1.GetType()}\n CLR: {d2.GetType()}");
            Console.WriteLine($"Decimal:\n C#: {dec1.GetType()}\n CLR: {dec2.GetType()}");
            Console.WriteLine($"Object (array):\n C#: {o1.GetType()}\n CLR: {o2.GetType()}");
            Console.WriteLine($"Char:\n C#: {ch1.GetType()}\n CLR: {ch2.GetType()}");
            Console.WriteLine($"String:\n C#: {s1.GetType()}\n CLR: {s2.GetType()}");


            Console.ReadKey();
        }
Exemple #16
0
    static void Main()
    {
        Int32 a = new Int32();

        a = 12;
        Object b = new Object();

        b = null;
        b = a;
        int c = (int)b;

        Console.WriteLine(a.GetType());
        Console.WriteLine(b.GetType());
        Console.WriteLine(c.GetType());

        Console.WriteLine($"c = {c}");

        Console.WriteLine(a.CompareTo(a));
        Console.WriteLine(12.Equals(a));

        Console.ReadLine();
    }
Exemple #17
0
        public void SystemType11_GetMethods_Test()
        {
            OutputHelper.WriteLine("This tests the GetMethods() method");
            OutputHelper.WriteLine("This test must be re-written once BindingFlags is working, ");
            OutputHelper.WriteLine("see 17246 for more details.");

            //Assigned and manipulated to avoid compiler warning
            Int32 I = 0;

            I++;

            TestObject2 testTestObject2 = new TestObject2(5);
            Type        myType2         = testTestObject2.GetType();

            OutputHelper.WriteLine("The full name is " + myType2.FullName);
            MethodInfo[] methodInfoArr1 = myType2.GetMethods();
            MethodInfo   methodInfo1    = null;

            if (methodInfoArr1[0].Name == "Method2")
            {
                methodInfo1 = methodInfoArr1[0];
                OutputHelper.WriteLine("Method2 found in position 0");
            }
            else if (methodInfoArr1[1].Name == "Method2")
            {
                methodInfo1 = methodInfoArr1[1];
                OutputHelper.WriteLine("Method2 found in position 1");
            }
            Assert.Equal(methodInfo1.IsAbstract, false);
            Assert.Equal(methodInfo1.IsFinal, false);
            Assert.Equal(methodInfo1.IsPublic, true);
            Assert.Equal(methodInfo1.IsStatic, false);
            Assert.Equal(methodInfo1.IsVirtual, false);
            Assert.True(methodInfo1.MemberType == MemberTypes.Method);
            Assert.Equal(methodInfo1.Name, "Method2");
            Assert.IsType(methodInfo1.ReturnType, I.GetType());
            Assert.IsType(methodInfo1.DeclaringType, myType2);
            Assert.Equal((int)(methodInfo1.Invoke(testTestObject2, new object[] { 1 })), 1);
        }
Exemple #18
0
        public static List <CSVData> getData(String path)
        {
            List <CSVData> n = new List <CSVData>();

            try
            {
                using (var reader = new StreamReader(path))
                {
                    while (!reader.EndOfStream)
                    {
                        lineError++;
                        var    line      = reader.ReadLine();
                        var    values    = line.Split(',');
                        String Employee1 = values[0];
                        String Employee2 = values[1];
                        Int32  Salary    = Int32.Parse(values[2]);

                        Type a = Salary.GetType();
                        Type b = typeof(System.Int32);
                        //Before any addition happens there is need for validation
                        if (a.Equals(b))
                        {
                            n.Add(new CSVData(Employee1, Employee2, Salary));
                        }
                        else
                        {
                            //There is an error stop the loop
                            Console.WriteLine("Salary is not Integer on line: " + lineError);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error Occurred while reading data at line " + lineError);
            }
            return(n);
        }
 public TestMatPropDrawer(Int32 i)
 {
     isArgumentGiven = true;
     Debug.Log(" ========int=====" + i.GetType().ToString());
     //argValue = i;
 }
Exemple #20
0
 public void FillData(DataRow row)
 {
     mvarVisaID          = Int32.Parse(clsCommon.GetValue(row["VisaID"], mvarVisaID.GetType().FullName).ToString());
     mvarVisaCountryID   = Int32.Parse(clsCommon.GetValue(row["VisaCountryID"], mvarVisaCountryID.GetType().FullName).ToString());
     mvarVisaTitle       = clsCommon.GetValue(row["VisaTitle"], mvarVisaTitle.GetType().FullName).ToString();
     mvarVisaContent     = clsCommon.GetValue(row["VisaContent"], mvarVisaContent.GetType().FullName).ToString();
     mvarVisaImage       = clsCommon.GetValue(row["VisaImage"], mvarVisaImage.GetType().FullName).ToString();
     mvarCreatedBy       = Int32.Parse(clsCommon.GetValue(row["CreatedBy"], mvarCreatedBy.GetType().FullName).ToString());
     mvarCreatedDate     = DateTime.Parse(clsCommon.GetValue(row["CreatedDate"], mvarCreatedDate.GetType().FullName).ToString());
     mvarLastUpdatedBy   = Int32.Parse(clsCommon.GetValue(row["LastUpdatedBy"], mvarLastUpdatedBy.GetType().FullName).ToString());
     mvarLastUpdatedDate = DateTime.Parse(clsCommon.GetValue(row["LastUpdatedDate"], mvarLastUpdatedDate.GetType().FullName).ToString());
 }
 public void FillData(DataRow row)
 {
     mvarProductStatusID   = Int32.Parse(clsCommon.GetValue(row["ProductStatusID"], mvarProductStatusID.GetType().FullName).ToString());
     mvarProductStatusName = clsCommon.GetValue(row["ProductStatusName"], mvarProductStatusName.GetType().FullName).ToString();
 }
 public void FillData(DataRow row)
 {
     mvarAbout             = clsCommon.GetValue(row["About"], mvarAbout.GetType().FullName).ToString();
     mvarBookingAndPayment = clsCommon.GetValue(row["BookingAndPayment"], mvarBookingAndPayment.GetType().FullName).ToString();
     mvarHotelBooking      = clsCommon.GetValue(row["HotelBooking"], mvarHotelBooking.GetType().FullName).ToString();
     mvarTravelInsurance   = clsCommon.GetValue(row["TravelInsurance"], mvarTravelInsurance.GetType().FullName).ToString();
     mvarAgencyPolicy      = clsCommon.GetValue(row["AgencyPolicy"], mvarAgencyPolicy.GetType().FullName).ToString();
     mvarCompanyName       = clsCommon.GetValue(row["CompanyName"], mvarCompanyName.GetType().FullName).ToString();
     mvarTaxNumber         = clsCommon.GetValue(row["TaxNumber"], mvarTaxNumber.GetType().FullName).ToString();
     mvarCompanyAddress    = clsCommon.GetValue(row["CompanyAddress"], mvarCompanyAddress.GetType().FullName).ToString();
     mvarCompanyMail       = clsCommon.GetValue(row["CompanyMail"], mvarCompanyMail.GetType().FullName).ToString();
     mvarHotline           = clsCommon.GetValue(row["Hotline"], mvarHotline.GetType().FullName).ToString();
     mvarCompanyPhone      = clsCommon.GetValue(row["CompanyPhone"], mvarCompanyPhone.GetType().FullName).ToString();
     mvarCompanyFax        = clsCommon.GetValue(row["CompanyFax"], mvarCompanyFax.GetType().FullName).ToString();
     mvarLogo            = clsCommon.GetValue(row["Logo"], mvarLogo.GetType().FullName).ToString();
     mvarLastUpdatedBy   = Int32.Parse(clsCommon.GetValue(row["LastUpdatedBy"], mvarLastUpdatedBy.GetType().FullName).ToString());
     mvarLastUpdatedDate = DateTime.Parse(clsCommon.GetValue(row["LastUpdatedDate"], mvarLastUpdatedDate.GetType().FullName).ToString());
 }
Exemple #23
0
        public void OpenTR2(string TR2fileName)
        {
            tr2Path   = TR2fileName;
            loadedTR2 = new TR2(tr2Path);

            // Adding header column
            DataGridViewTextBoxColumn headColumn = new DataGridViewTextBoxColumn();

            headColumn.ValueType = Type.GetType("System.Int32");
            headColumn.Name      = loadedTR2.fileName;
            dataTable.Columns.Add(headColumn);
            columnListBox.Items.Add(loadedTR2.fileName);

            // Adding dynamic columns
            for (int i = 0; i < loadedTR2.columnNum; i++)
            {
                DataGridViewTextBoxColumn currColumn = new DataGridViewTextBoxColumn();
                if (loadedTR2.columnsList[i].dataLenght == loadedTR2.columnsList[i].singleDataLenght)
                {
                    int    int8   = 0;
                    Int16  int16  = 0;
                    Int32  int32  = 0;
                    UInt16 uint16 = 0;

                    switch (loadedTR2.columnsList[i].dataType.ToLower())
                    {
                    case "int8":
                        currColumn.ValueType = int8.GetType();
                        break;

                    case "uint8":
                        currColumn.ValueType = int8.GetType();
                        break;

                    case "int16":
                        currColumn.ValueType = int16.GetType();
                        break;

                    case "uint16":
                        currColumn.ValueType = uint16.GetType();
                        break;

                    case "int32":
                        currColumn.ValueType = int32.GetType();
                        break;

                    case "utf-8":
                        currColumn.ValueType = "".GetType();
                        break;

                    case "ascii":
                        currColumn.ValueType = "".GetType();
                        break;

                    default:
                        currColumn.ValueType = Type.GetType(loadedTR2.columnsList[i].dataType);
                        break;
                    }
                }
                else
                {
                    currColumn.ValueType = "".GetType();
                }
                currColumn.Name = loadedTR2.columnsList[i].name;
                dataTable.Columns.Add(currColumn);

                columnListBox.Items.Add(currColumn.Name);
            }

            columnListBox.SelectedIndex = 0;

            // Adding Rows
            for (int i = 0; i < loadedTR2.rowNum; i++)
            {
                DataGridViewRow           row   = new DataGridViewRow();
                DataGridViewTextBoxCell[] cells = new DataGridViewTextBoxCell[loadedTR2.columnNum + 1];

                cells[0]       = new DataGridViewTextBoxCell();
                cells[0].Value = loadedTR2.rowHeaderValues[i];

                for (int j = 1; j <= loadedTR2.columnNum; j++)
                {
                    cells[j] = new DataGridViewTextBoxCell();
                    if (loadedTR2.columnsList[j - 1].dataLenght != loadedTR2.columnsList[j - 1].singleDataLenght)
                    {
                        int    doneTot    = 0;
                        string currValue  = "";
                        byte[] dataBuffer = (byte[])loadedTR2.columnsList[j - 1].data[i];
                        if (dataBuffer != null)
                        {
                            while (doneTot != dataBuffer.Length)
                            {
                                byte[] valueBuffer = new byte[loadedTR2.columnsList[j - 1].singleDataLenght];
                                Buffer.BlockCopy(dataBuffer, doneTot, valueBuffer, 0, valueBuffer.Length);
                                currValue += TR2Utils.ConvertNumber(valueBuffer);
                                doneTot   += valueBuffer.Length;

                                if (doneTot != dataBuffer.Length)
                                {
                                    currValue += " | ";
                                }
                            }
                        }
                        else
                        {
                            currValue = null;
                        }
                        cells[j].Value = currValue;
                    }
                    else
                    {
                        if (loadedTR2.columnsList[j - 1].dataLenght == -1)
                        {
                            string laStringa = (string)loadedTR2.columnsList[j - 1].data[i];
                            cells[j].Value = laStringa.Replace("\n", "\\n");
                        }
                        else
                        {
                            cells[j].Value = loadedTR2.columnsList[j - 1].data[i];
                        }
                    }
                }
                row.Cells.AddRange(cells);
                dataTable.Rows.Add(row);
            }
        }
        public void Load(DBHelper _DBHelper, IDbTransaction Trans, Int32 Id_Value)
        {
            DataTable             dt        = new DataTable();
            DBParameterCollection Parameter = new DBParameterCollection();

            Parameter.Add(new DBParameter("@Id", Id_Value, (DbType)Enum.Parse(typeof(DbType), Id_Value.GetType().Name, true)));

            dt = _DBHelper.ExecuteDataTable("SELECT * FROM REM_Master_Project WHERE Id=@Id", "REM_Master_Project", Parameter, CommandType.Text, Trans);
            if (dt.Rows.Count > 0)
            {
                Load(dt.Rows[0]);
            }
        }
        public void Load(DBHelper _DBHelper, IDbTransaction Trans, Int32 TranID_Value)
        {
            DataTable             dt        = new DataTable();
            DBParameterCollection Parameter = new DBParameterCollection();

            Parameter.Add(new DBParameter("@TranID", TranID_Value, (DbType)Enum.Parse(typeof(DbType), TranID_Value.GetType().Name, true)));

            dt = _DBHelper.ExecuteDataTable("SELECT * FROM SAP_Interface_Log WHERE TranID=@TranID", "SAP_Interface_Log", Parameter, CommandType.Text, Trans);
            if (dt.Rows.Count > 0)
            {
                Load(dt.Rows[0]);
            }
        }
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
        Console.WriteLine();
        int    iCountErrors    = 0;
        int    iCountTestcases = 0;
        String strLoc          = "Loc_000oo";
        Int32  iValue          = 0;
        Object objValue        = null;

        MemberInfo[] members = null;
        Object[]     data    = null;
        try {
            do
            {
                members  = FormatterServices.GetSerializableMembers(iValue.GetType());
                data     = new Object[members.Length];
                data[0]  = 10;
                objValue = FormatterServices.GetUninitializedObject(iValue.GetType());
                iValue   = (Int32)FormatterServices.PopulateObjectMembers(objValue, members, data);
                iCountTestcases++;
                if (iValue != 10)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_753dw! Wrong Value returned," + iValue.ToString());
                }
                data[0] = "Hello World";
                try
                {
                    iCountTestcases++;
                    iValue = (Int32)FormatterServices.PopulateObjectMembers(objValue, members, data);
                    iCountErrors++;
                    Console.WriteLine("Err_045fcd! Excepion not thrown");
                }
                catch (ArgumentException) {}
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_369sq! Wrong excepion thrown, " + ex.ToString());
                }
                baloney bal = new baloney();
                members = FormatterServices.GetSerializableMembers(bal.GetType());
                data    = new Object[members.Length];
                for (int i = 0; i < members.Length; i++)
                {
                    if (members[i].Name.Equals("str_Humpty"))
                    {
                        data[i] = "Anything";
                    }
                    else if (members[i].Name.Equals("i_spy"))
                    {
                        data[i] = 3;
                    }
                    else
                    {
                        Console.WriteLine("i scream");
                    }
                }
                objValue = FormatterServices.GetUninitializedObject(bal.GetType());
                baloney bal1 = (baloney)FormatterServices.PopulateObjectMembers(objValue, members, data);
                iCountTestcases++;
                if (!bal1.str_Humpty.Equals("Anything"))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_9564fd! Wrong Value returned," + bal1.str_Humpty);
                }
                iCountTestcases++;
                if (bal1.i_spy != 3)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_863cd! Wrong Value returned," + bal1.i_spy.ToString());
                }
                try
                {
                    iCountTestcases++;
                    FormatterServices.PopulateObjectMembers(null, members, data);
                    iCountErrors++;
                    Console.WriteLine("Err_058fd! Excepion not thrown");
                }
                catch (ArgumentNullException) {}
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_105ds! Wrong excepion thrown, " + ex.ToString());
                }
                try
                {
                    iCountTestcases++;
                    FormatterServices.PopulateObjectMembers(objValue, null, data);
                    iCountErrors++;
                    Console.WriteLine("Err_9662dsd! Excepion not thrown");
                }
                catch (ArgumentNullException) {}
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_937sd! Wrong excepion thrown, " + ex.ToString());
                }
                try
                {
                    iCountTestcases++;
                    FormatterServices.PopulateObjectMembers(objValue, members, null);
                    iCountErrors++;
                    Console.WriteLine("Err_1057ds! Excepion not thrown");
                }
                catch (ArgumentNullException) {}
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0572ds! Wrong excepion thrown, " + ex.ToString());
                }
                members  = FormatterServices.GetSerializableMembers(iValue.GetType());
                data     = new Object[3];
                data[0]  = 10;
                objValue = FormatterServices.GetUninitializedObject(iValue.GetType());
                try
                {
                    iCountTestcases++;
                    iValue = (Int32)FormatterServices.PopulateObjectMembers(objValue, members, data);
                    iCountErrors++;
                    Console.WriteLine("Err_054xs! Excepion not thrown");
                }
                catch (ArgumentException) {}
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_1067fs! Wrong excepion thrown, " + ex.ToString());
                }
                members    = FormatterServices.GetSerializableMembers(iValue.GetType());
                members[0] = null;
                data       = new Object[1];
                data[0]    = 10;
                objValue   = FormatterServices.GetUninitializedObject(iValue.GetType());
                try
                {
                    iCountTestcases++;
                    FormatterServices.PopulateObjectMembers(objValue, members, data);
                    iCountErrors++;
                    Console.WriteLine("Err_935cd! Excepion not thrown");
                }
                catch (ArgumentNullException) {}
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_105xs! Wrong excepion thrown, " + ex.ToString());
                }
                members = typeof(Guid).GetConstructors();
                data    = new Object[members.Length];
                for (int i = 0; i < data.Length; i++)
                {
                    data[i] = i + 10;
                }
                objValue = FormatterServices.GetUninitializedObject(typeof(Guid));
                try
                {
                    iCountTestcases++;
                    FormatterServices.PopulateObjectMembers(objValue, members, data);
                    iCountErrors++;
                    Console.WriteLine("Err_046fcsd! Excepion not thrown");
                }
                catch (SerializationException) {}
                catch (Exception ex)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_9453cdf! Wrong excepion thrown, " + ex.ToString());
                }
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.StackTrace);
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases.ToString());
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors.ToString() + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Exemple #27
0
    public bool PosTest2(int id, String curValue, Int32 expValue)
    {
        bool            retVal = true;
        Int32           newValue;
        IFormatProvider myfp;

        TestLibrary.TestFramework.BeginScenario("PosTest" + id + ": Convert.ToInt32(...) (curValue:string " + curValue + " newType:" + expValue.GetType() + ")");

        try
        {
            newValue = Convert.ToInt32(curValue);

            if (!newValue.Equals(expValue))
            {
                TestLibrary.TestFramework.LogError("003", "Value mismatch: Expected(" + expValue + ") Actual(" + newValue + ")");
                retVal = false;
            }

            myfp     = null;
            newValue = Convert.ToInt32(curValue, myfp);

            if (!newValue.Equals(expValue))
            {
                TestLibrary.TestFramework.LogError("004", "Value mismatch: Expected(" + expValue + ") Actual(" + newValue + ")");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("005", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
 public void FillData(DataRow row)
 {
     mvarDomesticPlaceID   = Int32.Parse(clsCommon.GetValue(row["DomesticPlaceID"], mvarDomesticPlaceID.GetType().FullName).ToString());
     mvarDomesticPlaceName = clsCommon.GetValue(row["DomesticPlaceName"], mvarDomesticPlaceName.GetType().FullName).ToString();
 }
 public void FillData(DataRow row)
 {
     mvarCustomer_PriceQuotation_ID         = Int32.Parse(clsCommon.GetValue(row["Customer_PriceQuotation_ID"], mvarCustomer_PriceQuotation_ID.GetType().FullName).ToString());
     mvarCustomer_PriceQuotation_Name       = clsCommon.GetValue(row["Customer_PriceQuotation_Name"], mvarCustomer_PriceQuotation_Name.GetType().FullName).ToString();
     mvarCustomer_PriceQuotation_Phone      = clsCommon.GetValue(row["Customer_PriceQuotation_Phone"], mvarCustomer_PriceQuotation_Phone.GetType().FullName).ToString();
     mvarCustomer_PriceQuotation_Email      = clsCommon.GetValue(row["Customer_PriceQuotation_Email"], mvarCustomer_PriceQuotation_Email.GetType().FullName).ToString();
     mvarCustomer_PriceQuotation_Content    = clsCommon.GetValue(row["Customer_PriceQuotation_Content"], mvarCustomer_PriceQuotation_Content.GetType().FullName).ToString();
     mvarCustomer_PriceQuotation_DateFlight = DateTime.Parse(clsCommon.GetValue(row["Customer_PriceQuotation_DateFlight"], mvarCustomer_PriceQuotation_DateFlight.GetType().FullName).ToString());
     mvarCreatedDate = DateTime.Parse(clsCommon.GetValue(row["CreatedDate"], mvarCreatedDate.GetType().FullName).ToString());
 }
Exemple #30
0
        static void Main(string[] args)
        {
            Debug.WriteLine("hi");
            int   i = 1234567890;
            Int16 j = 12345;
            Int32 k = 1234567890;
            Int64 l = 1234567890123456789;

            float  f = 1.23456789023456789F; // F mandatory
            double d = 1.23456789023456789D; // D optional

            Console.WriteLine(double.MaxValue);
            Console.WriteLine(double.MinValue);
            decimal dd = 1.2345678902345678901234M;  // M optional


            Console.WriteLine("Integers by default are 32 bits long.");
            Console.WriteLine("Example of int is {0}", i);
            Console.WriteLine("Example of {0} is {1}", j.GetType(), j);
            Console.WriteLine("Example of {0} is {1}", k.GetType(), k);
            Console.WriteLine("Example of {0} is {1}", l.GetType(), l);
            Console.WriteLine("Float f is 32 bits long.  Example is " + f + ".  Note that floats have 7 digit precision");
            Console.WriteLine("Double d is 64 bits long.  Example is " + d + ".  Note that doubles have 15 digit precision");
            Console.WriteLine("Decimal dd is 128 bit long.  Example is " + dd);


            long lg = 1234567890123456789;

            Console.WriteLine("Long lg is " + lg);

            bool b = true;

            Console.WriteLine("Boolean b is " + b);



            string x = "h";
            char   c = Convert.ToChar(x);

            Console.WriteLine("Char c is " + c);



            Console.WriteLine();
            Console.WriteLine();
            Char char01 = 'a';

            Console.WriteLine(char01);

            Console.WriteLine("== Char From ASCII number ==");
            Char char02 = (char)121;

            Console.WriteLine(char02);

            Console.WriteLine();
            Console.WriteLine("== Char Array From Letters ==");
            Char[] charArray01 = { 'a', 'b', 'c' };
            foreach (char charItem in charArray01)
            {
                Console.WriteLine(charItem.ToString());
            }


            Char[] charArray02 = new char[10];  // blank char array


            Console.WriteLine();
            Console.WriteLine("== Char Array From Letters ==");
            Char[] charArray03 = new char[] { 'a', 'b', 'c' };
            foreach (char charItem in charArray02)
            {
                Console.WriteLine(charItem.ToString());
            }



            Console.WriteLine();
            Console.WriteLine("== Char Array From Numbers ==");
            char[] charArray04 = new char[] { (char)121, (char)122, (char)123 };
            foreach (char charItem in charArray04)
            {
                Console.WriteLine(charItem.ToString());
            }

            Console.WriteLine("== Convert.ToChar(x)==");
            var char05 = Convert.ToChar(121);

            Console.WriteLine(char05);



            byte byte01 = 248;

            Console.WriteLine("Byte bb is " + byte01);
            Byte byte02 = Convert.ToByte(255);



            Console.WriteLine();
            Console.WriteLine("==Bytes==");
            var byteArray = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 255, 232 };

            foreach (byte bbb in byteArray)
            {
                Console.WriteLine(bbb.ToString());
            }


            foreach (byte bbb in byteArray)
            {
                Console.Write(Convert.ToChar(bbb));
            }



            int[] array01 = new int[10];        // 1d
            int[] array02 = { 1, 2, 3 };        // literals
            Console.WriteLine("array length is " + array02.Length);
            Console.WriteLine("array count is " + array02.Count());
            int[,] arraygrid = new int[5, 5];    // 2d

            DateTime date01 = new DateTime();

            Console.WriteLine(date01);

            DateTime date02 = DateTime.Today;

            Console.WriteLine(date02);

            DateTime date03 = DateTime.Now;

            Console.WriteLine(date03);

            date03.AddDays(7);
            date03.AddDays(7.0);
            date03.Add(new TimeSpan(2000));
            Console.WriteLine(date03);
            date03.AddYears(24);
            Console.WriteLine(date03);

            var Interval01 = date03 - date02;

            Console.WriteLine(Interval01);

            Console.WriteLine();

            Console.WriteLine("Byte uses {0} bytes", sizeof(byte));
            Console.WriteLine("with min value {0}", byte.MinValue);
            Console.WriteLine("and max value {0}", byte.MaxValue);


            Console.WriteLine("Int uses {0} bytes", sizeof(int));
            Console.WriteLine("with min value {0}", int.MinValue);
            Console.WriteLine("and max value {0}", int.MaxValue);

            Console.WriteLine("Short uses {0} bytes", sizeof(short));
            Console.WriteLine("with min value {0}", short.MinValue);
            Console.WriteLine("and max value {0}", short.MaxValue);

            Console.WriteLine("Int uses {0} bytes", sizeof(long));
            Console.WriteLine("with min value {0}", long.MinValue);
            Console.WriteLine("and max value {0}", long.MaxValue);

            Console.WriteLine();
            Console.WriteLine("==Checked vs Not Checked==");
            // Not checked : i2 overflows
            int i1 = 2147483647;

            Console.WriteLine("Not checked : " + i1);
            int i2 = i1 * 2;

            Console.WriteLine("Not checked : {0}", i2);


            checked
            {
                int i3 = 2147483647;
                Console.WriteLine("Not checked : " + i3);
                // uncomment to create a runtime exception    int i4 = i1 * 2;
                //    Console.WriteLine("Not checked : {0}", i4);
            }

            //     Console.WriteLine(checked(3245234523453245324*100));

            Console.WriteLine(unchecked (3245234523453245324 * 100));



            var plainText = "hello world…";
            var rawBytes  = Encoding.Default.GetBytes(plainText);



            // view details class t : Type { }


            // using letters to define
            var money01 = 1.27M;

            Console.WriteLine($"money01 = { money01}");
            var uu = 123L;

            Console.WriteLine($"uu = {uu}");
            var ss = (Int16)123;

            Console.WriteLine($"ss = {ss}");
            var ff = 1.23F;

            Console.WriteLine($"ff = {ff}");

            var y = 0f; // y is single

            Console.WriteLine($"y = {y}");
            var z = 0d; // z is double

            Console.WriteLine($"z = {z}");
            var r = 0m; // r is decimal

            Console.WriteLine($"r = {r}");
            var iii = 0U; // i is unsigned int

            Console.WriteLine($"iii = {iii}");
            var jjjj = 0L; // j is long (note capital L for clarity)

            Console.WriteLine($"jjj = {jjjj}");
            var kkkk = 0UL; // k is unsigned long (note capital L for clarity)

            Console.WriteLine($"kkkk = {kkkk}");



            // Default values
            Console.WriteLine("== default values == ");
            int myNum01 = new int();

            Console.WriteLine(myNum01);
            int myNum02 = default(int);

            Console.WriteLine(myNum02);

            string myString01 = default(string);

            Console.WriteLine(myString01);
            string myString02 = null;

            Console.WriteLine(myString02);



            //int.TryParse
            string myNumberAsString = "1234";
            int    myNumber;

            int.TryParse(myNumberAsString, out myNumber);
            Console.WriteLine(myNumber);
            Console.WriteLine(myNumber.GetType());



            Console.ReadLine();
        }