本文整理汇总了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;
}
示例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;
}