当前位置: 首页>>代码示例>>C#>>正文


C# DataColumn.GetType方法代码示例

本文整理汇总了C#中System.Data.DataColumn.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.GetType方法的具体用法?C# DataColumn.GetType怎么用?C# DataColumn.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataColumn的用法示例。


在下文中一共展示了DataColumn.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AreEqual

		/// <summary>
		/// Asserts that two <see cref="DataColumn"/> are equal.
		/// </summary> 
		/// <param name="expected">Expected <see cref="DataColumn"/> instance.</param>
		/// <param name="actual">Actual <see cref="DataColumn"/> instance.</param>
		public static void AreEqual(DataColumn expected, DataColumn actual)
		{
			// null case, trivial comparaison
			if (expected==null)
				Assert.AreEqual(expected,actual);
			
			// check same type
			Assert.AreEqual(expected.GetType(), actual.GetType());

			foreach(PropertyInfo pi in expected.GetType().GetProperties())
			{
				switch(pi.Name)
				{
					case "Container": continue;
					case "Site" : continue;
				}
			
				Assert.AreValueEqual(pi, expected, actual);
			}
		}
开发者ID:timonela,项目名称:mb-unit,代码行数:25,代码来源:DataAssert.cs

示例2: run

	//Activate This Construntor to log All To Standard output
	//public TestClass():base(true){}

	//Activate this constructor to log Failures to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, false){}


	//Activate this constructor to log All to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, true){}

	//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES

	public void run()
	{
		Exception exp = null;
		DataColumn dc;
		Type myType;
		dc = new DataColumn();
		myType = dc.GetType();
	
		try
		{
			BeginCase("GetType");
			Compare(myType, typeof(DataColumn));
		} 
		catch(Exception ex)
		{
			exp = ex;
		}
		finally
		{
			EndCase(exp);
			exp = null;
		}
	}
开发者ID:nlhepler,项目名称:mono,代码行数:35,代码来源:DataColumn_GetType.cs

示例3: HandleColumn

        internal XmlElement HandleColumn(DataColumn col, XmlDocument dc, XmlElement schema, bool fWriteOrdinal) {
            XmlElement  root;
            int         minOccurs;

            Debug.Assert(col.ColumnMapping != MappingType.SimpleContent , "Illegal state");

            String refString = (col.ColumnMapping != MappingType.Element) ? Keywords.XSD_ATTRIBUTE : Keywords.XSD_ELEMENT;
            root = dc.CreateElement(Keywords.XSD_PREFIX, refString, Keywords.XSDNS);

            // First add any attributes.
            root.SetAttribute( Keywords.NAME, col.EncodedColumnName);

            if (col.Namespace.Length == 0) {
                DataTable _table = col.Table;
                // We need to travese the hirerarchy to find the targetnamepace
                string tgNamespace = FindTargetNamespace(_table);
                if (col.Namespace != tgNamespace) {
                    root.SetAttribute( Keywords.FORM, Keywords.UNQUALIFIED);
                }
            }

            if (col.GetType() != typeof(DataColumn))
                AddXdoProperties(col, root, dc);
            else
                AddColumnProperties(col, root);


            AddExtendedProperties(col.extendedProperties, root);
            HandleColumnType(col, dc, root, schema);
            if (col.ColumnMapping == MappingType.Hidden) { // CDT / UDT can not be mapped to Hidden column
                if (!col.AllowDBNull)
                    root.SetAttribute(Keywords.MSD_ALLOWDBNULL, Keywords.MSDNS, Keywords.FALSE);

                if (!col.DefaultValueIsNull)
                    if (col.DataType == typeof(bool))
                        root.SetAttribute(Keywords.MSD_DEFAULTVALUE, Keywords.MSDNS, (bool)(col.DefaultValue)? Keywords.TRUE : Keywords.FALSE);
                    else 
                    {
                    XmlTreeGen.ValidateColumnMapping(col.DataType);
                    root.SetAttribute(Keywords.MSD_DEFAULTVALUE, Keywords.MSDNS, col.ConvertObjectToXml(col.DefaultValue));
                    }
            }


            if ((!col.DefaultValueIsNull)&& (col.ColumnMapping != MappingType.Hidden)){
                XmlTreeGen.ValidateColumnMapping(col.DataType);
                if (col.ColumnMapping == MappingType.Attribute && !col.AllowDBNull ) {
                    if (col.DataType == typeof(bool)) {
                        root.SetAttribute(Keywords.MSD_DEFAULTVALUE, Keywords.MSDNS, (bool)(col.DefaultValue)? Keywords.TRUE : Keywords.FALSE);
                    }
                    else { // CDT / UDT columns cn not be mapped to Attribute also
                        root.SetAttribute(Keywords.MSD_DEFAULTVALUE, Keywords.MSDNS, col.ConvertObjectToXml(col.DefaultValue));
                    }
                }
                else { // Element Column : need to handle CDT
                    if (col.DataType == typeof(bool)) {
                        root.SetAttribute(Keywords.DEFAULT, (bool)(col.DefaultValue)? Keywords.TRUE : Keywords.FALSE);
                    }
                    else {
                        if (!col.IsCustomType) { // built in type
                            root.SetAttribute(Keywords.DEFAULT, col.ConvertObjectToXml(col.DefaultValue));
                        }
                        else { // UDT column
                        }
                    }
                }
            }

            if (schFormat == SchemaFormat.Remoting)
                root.SetAttribute( Keywords.TARGETNAMESPACE, Keywords.MSDNS, col.Namespace);

            else {

                if ((col.Namespace != (col.Table.TypeName.IsEmpty ? col.Table.Namespace : col.Table.TypeName.Namespace)) && (col.Namespace.Length != 0))
             {
                        XmlElement schNode = GetSchema(col.Namespace);
                        if (FindTypeNode(schNode, col.EncodedColumnName) == null)
                            schNode.AppendChild(root);
                        root = _dc.CreateElement(Keywords.XSD_PREFIX, refString, Keywords.XSDNS);
                        root.SetAttribute( Keywords.REF, prefixes[ col.Namespace]+":"+ col.EncodedColumnName);
                        if (col.Table.Namespace!=_ds.Namespace) {
                            string prefix = (string)prefixes[col.Namespace];
                            XmlElement tNode = GetSchema(col.Table.Namespace);
                    }
                    }
                }


            minOccurs = (col.AllowDBNull) ? 0 : 1;


            // [....] 2001 change
            if (col.ColumnMapping == MappingType.Attribute && minOccurs != 0)
                root.SetAttribute(Keywords.USE, Keywords.REQUIRED);


            if (col.ColumnMapping == MappingType.Hidden) {
                root.SetAttribute(Keywords.USE, Keywords.PROHIBITED);
            }
            else
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:xmlsaver.cs

示例4: TestGetType

		[Test] public void TestGetType()
		{
			DataColumn dc;
			Type myType;
			dc = new DataColumn();
			myType = dc.GetType();

			// GetType
			Assert.AreEqual(typeof(DataColumn), myType, "DC28");
		}
开发者ID:wamiq,项目名称:debian-mono,代码行数:10,代码来源:DataColumnTest2.cs

示例5: HandleColumn

 internal XmlElement HandleColumn(DataColumn col, XmlDocument dc, XmlElement schema, bool fWriteOrdinal)
 {
     string localName = (col.ColumnMapping != MappingType.Element) ? "attribute" : "element";
     XmlElement root = dc.CreateElement("xs", localName, "http://www.w3.org/2001/XMLSchema");
     root.SetAttribute("name", col.EncodedColumnName);
     if (col.Namespace.Length == 0)
     {
         DataTable table = col.Table;
         string str2 = this.FindTargetNamespace(table);
         if (col.Namespace != str2)
         {
             root.SetAttribute("form", "unqualified");
         }
     }
     if (col.GetType() != typeof(DataColumn))
     {
         this.AddXdoProperties(col, root, dc);
     }
     else
     {
         this.AddColumnProperties(col, root);
     }
     AddExtendedProperties(col.extendedProperties, root);
     this.HandleColumnType(col, dc, root, schema);
     if (col.ColumnMapping == MappingType.Hidden)
     {
         if (!col.AllowDBNull)
         {
             root.SetAttribute("AllowDBNull", "urn:schemas-microsoft-com:xml-msdata", "false");
         }
         if (!col.DefaultValueIsNull)
         {
             if (col.DataType == typeof(bool))
             {
                 root.SetAttribute("DefaultValue", "urn:schemas-microsoft-com:xml-msdata", ((bool) col.DefaultValue) ? "true" : "false");
             }
             else
             {
                 ValidateColumnMapping(col.DataType);
                 root.SetAttribute("DefaultValue", "urn:schemas-microsoft-com:xml-msdata", col.ConvertObjectToXml(col.DefaultValue));
             }
         }
     }
     if (!col.DefaultValueIsNull && (col.ColumnMapping != MappingType.Hidden))
     {
         ValidateColumnMapping(col.DataType);
         if ((col.ColumnMapping == MappingType.Attribute) && !col.AllowDBNull)
         {
             if (col.DataType == typeof(bool))
             {
                 root.SetAttribute("DefaultValue", "urn:schemas-microsoft-com:xml-msdata", ((bool) col.DefaultValue) ? "true" : "false");
             }
             else
             {
                 root.SetAttribute("DefaultValue", "urn:schemas-microsoft-com:xml-msdata", col.ConvertObjectToXml(col.DefaultValue));
             }
         }
         else if (col.DataType == typeof(bool))
         {
             root.SetAttribute("default", ((bool) col.DefaultValue) ? "true" : "false");
         }
         else if (!col.IsCustomType)
         {
             root.SetAttribute("default", col.ConvertObjectToXml(col.DefaultValue));
         }
     }
     if (this.schFormat == SchemaFormat.Remoting)
     {
         root.SetAttribute("targetNamespace", "urn:schemas-microsoft-com:xml-msdata", col.Namespace);
     }
     else if ((col.Namespace != (col.Table.TypeName.IsEmpty ? col.Table.Namespace : col.Table.TypeName.Namespace)) && (col.Namespace.Length != 0))
     {
         XmlElement node = this.GetSchema(col.Namespace);
         if (this.FindTypeNode(node, col.EncodedColumnName) == null)
         {
             node.AppendChild(root);
         }
         root = this._dc.CreateElement("xs", localName, "http://www.w3.org/2001/XMLSchema");
         root.SetAttribute("ref", this.prefixes[col.Namespace] + ":" + col.EncodedColumnName);
         if (col.Table.Namespace != this._ds.Namespace)
         {
             string text1 = (string) this.prefixes[col.Namespace];
             this.GetSchema(col.Table.Namespace);
         }
     }
     int num = col.AllowDBNull ? 0 : 1;
     if ((col.ColumnMapping == MappingType.Attribute) && (num != 0))
     {
         root.SetAttribute("use", "required");
     }
     if (col.ColumnMapping == MappingType.Hidden)
     {
         root.SetAttribute("use", "prohibited");
     }
     else if ((col.ColumnMapping != MappingType.Attribute) && (num != 1))
     {
         root.SetAttribute("minOccurs", num.ToString(CultureInfo.InvariantCulture));
     }
     if ((col.ColumnMapping == MappingType.Element) && fWriteOrdinal)
     {
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:XmlTreeGen.cs

示例6: GetFormatoCampo

        /// <summary>
        /// Devuelve el valor pasado por el parámetro sValorCampo formateado dependiendo del tipo 
        /// de datos para asignarlo como valor a un campo en una SQL.
        /// </summary>
        /// <param name="sTipoCampo">
        /// Tipo de datos del campo
        /// </param>
        /// <param name="sValorCampo">
        /// Valor que se devolverá formateado
        /// </param>
        /// <returns></returns>
        private String GetFormatoCampo(DataColumn sTipoCampo, String sValorCampo)
        {
            switch (sTipoCampo.GetType().ToString())
            {
                case "System.String":
                    if (String.IsNullOrEmpty(sValorCampo))
                        sValorCampo = "";

                    break;

                case "System.DateTime":
                    if (ClsGeneral.IsDate(sValorCampo) )
                        sValorCampo = DateTime.Parse(sValorCampo).ToString();
                    else
                        sValorCampo = "";

                    break;

                case "System.Decimal":
                    if (ClsGeneral.IsNumeric(sValorCampo) )
                        //convierte la coma en punto
                        sValorCampo = sValorCampo.Replace(",", ".");
                    else
                        sValorCampo = "0";

                    break;

                case "System.Int16":case "System.Int32":case "System.Int64":
                    if (ClsGeneral.IsNumeric(sValorCampo))
                        //si viene con decimales se los quita
                        sValorCampo = int.Parse(sValorCampo).ToString();
                    else
                        sValorCampo = "0";

                   break;

                case  "System.Double":
                    if (ClsGeneral.IsNumeric(sValorCampo))
                        sValorCampo = sValorCampo.Replace(",", ".");
                    else
                        sValorCampo = "0";

                    break;
                default:
                    //----------- NO COMENTAR ESTAS LINEAS -----------
                    //hay que definir el tipo de datos del campo para mayor seguridad
                    System.Windows.Forms.MessageBox.Show("El tipo de datos no esta definido en ClsTableStructure.");
                    break;

            //devuelve el valor entre comillas (si es varchar o datetime) y reemplazando todas las comillas simples por dobles

            }
            return sValorCampo;
        }
开发者ID:developerFranjfgcarmo,项目名称:SimpleDataMapper,代码行数:65,代码来源:ClsDataQuery.cs

示例7: PrintDataColumn

 /// <summary>
 /// 打印 DataColumn .
 /// </summary>
 /// <param name="sb">输出缓冲区.</param>
 /// <param name="indent">缩进.</param>
 /// <param name="obj">对象.</param>
 public static void PrintDataColumn(StringBuilder sb, int indent, DataColumn obj)
 {
     int indentnext = indent + 1;
     String indentstr = GetIndentStr(indent);
     sb.AppendLine(string.Format("{0}# <{1}>", indentstr, obj.GetType().FullName));
     sb.AppendLine(string.Format("{0}AllowDBNull:\t{1}", indentstr, obj.AllowDBNull));
     sb.AppendLine(string.Format("{0}AutoIncrement:\t{1}", indentstr, obj.AutoIncrement));
     sb.AppendLine(string.Format("{0}AutoIncrementSeed:\t{1}", indentstr, obj.AutoIncrementSeed));
     sb.AppendLine(string.Format("{0}AutoIncrementStep:\t{1}", indentstr, obj.AutoIncrementStep));
     sb.AppendLine(string.Format("{0}Caption:\t{1}", indentstr, obj.Caption));
     sb.AppendLine(string.Format("{0}ColumnMapping:\t{1}", indentstr, obj.ColumnMapping));
     sb.AppendLine(string.Format("{0}ColumnName:\t{1}", indentstr, obj.ColumnName));
     sb.AppendLine(string.Format("{0}DataType:\t{1}", indentstr, obj.DataType));
     sb.AppendLine(string.Format("{0}DateTimeMode:\t{1}", indentstr, obj.DateTimeMode));
     sb.AppendLine(string.Format("{0}DefaultValue:\t{1}", indentstr, obj.DefaultValue));
     sb.AppendLine(string.Format("{0}Expression:\t{1}", indentstr, obj.Expression));
     sb.AppendLine(string.Format("{0}MaxLength:\t{1}", indentstr, obj.MaxLength));
     sb.AppendLine(string.Format("{0}Namespace:\t{1}", indentstr, obj.Namespace));
     sb.AppendLine(string.Format("{0}Ordinal:\t{1}", indentstr, obj.Ordinal));
     sb.AppendLine(string.Format("{0}Prefix:\t{1}", indentstr, obj.Prefix));
     sb.AppendLine(string.Format("{0}ReadOnly:\t{1}", indentstr, obj.ReadOnly));
     sb.AppendLine(string.Format("{0}Unique:\t{1}", indentstr, obj.Unique));
     sb.AppendLine(string.Format("{0}ExtendedProperties:\t{1}", indentstr, obj.ExtendedProperties));
     PrintPropertyCollection(sb, indentnext, obj.ExtendedProperties);
 }
开发者ID:zyl910,项目名称:zdbviewcs,代码行数:31,代码来源:ZDbViewCsForm.cs


注:本文中的System.Data.DataColumn.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。