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


C# DataTable.Set方法代码示例

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


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

示例1: DeserializeDataTableFromXML

            //public static BSETransform DeserializeTransformFromXML(ref XmlNode dataNode)
            //{
            //    XmlNode posNode = dataNode.ChildNodes[0];
            //    Vector3 pos = DeserializeVector3FromXML(ref posNode);
            //    XmlNode scaleNode = dataNode.ChildNodes[1];
            //    Vector3 scale = DeserializeVector3FromXML(ref scaleNode);
            //    XmlNode rotationNode = dataNode.ChildNodes[2];
            //    Quaternion rotation = DeserializeQuaternionFromXML(ref rotationNode);
            //    BSETransform trans;
            //    trans.position = pos;
            //    trans.localScale = scale;
            //    trans.rotation = rotation;
            //    return trans;
            //}

            #endregion Basic types deserialization

            #region Collections Deserialization

            /// <summary>
            /// DataTable deserialization from XML
            /// </summary>
            /// <param name="elementNode">XML node containing the DataTable</param>
            /// <returns>DataTable deserialized</returns>
            public static DataTable DeserializeDataTableFromXML(XmlNode elementNode)
            {
                //root node
                XmlNode tableNode = elementNode.FirstChild;//doc.CreateElement("DataTable");

                XmlNodeList nodeList = tableNode.ChildNodes;

                XmlNode nameNode = nodeList[0];
                XmlNode serializationModeNode = nodeList[1];
                XmlNode loadToBlackboardNode = nodeList[2];
                XmlNode dataNode = nodeList[3];

                string name = nameNode.InnerText;
                SerializationMode mode = (SerializationMode) Enum.Parse(typeof(SerializationMode), serializationModeNode.InnerText);
                bool loadToBlackboard = Boolean.Parse(loadToBlackboardNode.InnerText);

                DataTable res = new DataTable(name, mode, loadToBlackboard);

                foreach (XmlNode node in dataNode.ChildNodes)
                {
                    string dataName = node.Attributes["name"].Value;
                    Type type = Type.GetType(StringTypeToAssemblyQualifiedName(node.Attributes["type"].Value));

                    //object data = null;

                    if (Predicates.IsBasicType(type))
                    {
                        res.Set<object>(dataName, DeserializeBasicTypeFromXML(node, type));
                    }
                    else if (type == typeof(DataTable))
                    {
                        res.Set<object>(dataName, DeserializeDataTableFromXML(node));
                    }
                    //else if(Predicates.IsList(type))
                    //{
                    //    Debug.LogWarning("XML List deserialization only works with List<object>. You may not be able to recover all data properly. Use binary files instead");
                    //    res.Set<object>(dataName, DeserializeListFromXML(node));
                    //}
                    //else if(Predicates.IsDictionary(type))
                    //{
                    //    Debug.LogWarning("XML List deserialization only works with Dictionary<object, object>. You may not be able to recover all data properly. Use binary files instead");
                    //    res.Set<object>(dataName, DeserializeDictionaryFromXML(node));
                    //}
                    else
                    {
                        Debug.LogError("Type: " + type + " NOT supported on XML deserialization. Please use Binary files instead");
                    }
                }

                return res;
            }
开发者ID:albmarvil,项目名称:BattleChess,代码行数:75,代码来源:XMLSerializer.cs

示例2: ToDataTable

        /// <summary>
        /// Translates all the class info into a DataTable
        /// </summary>
        public DataTable ToDataTable()
        {
            DataTable data = new DataTable("MouseCfg", SerializationMode.NONE, false);

            data.Set<bool>("invertedX", m_invertedX == -1.0f);
            data.Set<bool>("invertedY", m_invertedY == -1.0f);
            data.Set<float>("sensivity", m_sensivity);
            data.Set<bool>("useUnityScreenPosition", m_useUnityScreenPosition);

            return data;
        }
开发者ID:albmarvil,项目名称:BattleChess,代码行数:14,代码来源:MouseCfg.cs


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