本文整理汇总了C#中SerializationInfo.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# SerializationInfo.AddChild方法的具体用法?C# SerializationInfo.AddChild怎么用?C# SerializationInfo.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializationInfo
的用法示例。
在下文中一共展示了SerializationInfo.AddChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
void IMobileObject.GetChildren(SerializationInfo info, MobileFormatter formatter)
{
foreach (string key in this.Keys)
{
object value = this[key];
IMobileObject mobile = value as IMobileObject;
if (mobile != null)
{
SerializationInfo si = formatter.SerializeObject(mobile);
info.AddChild(key, si.ReferenceId);
}
}
}
示例2: Read
/// <summary>
/// Read a data from a stream, typically MemoryStream, and convert it into
/// a list of SerializationInfo objects
/// </summary>
/// <param name="serializationStream">Stream to read the data from</param>
/// <returns>List of SerializationInfo objects</returns>
public List<SerializationInfo> Read(Stream serializationStream)
{
var returnValue = new List<SerializationInfo>();
int childCount, valueCount, referenceId;
string systemName, enumTypeName;
bool isDirty;
object value;
keywordsDictionary.Clear();
using (var reader = new BinaryReader(serializationStream))
{
int totalCount = reader.ReadInt32();
for (int counter = 0; counter < totalCount; counter++)
{
var info = new SerializationInfo();
info.ReferenceId = reader.ReadInt32();
info.TypeName = (string)ReadObject(reader);
childCount = reader.ReadInt32();
for (int childCounter = 0; childCounter < childCount; childCounter++)
{
systemName = (string)ReadObject(reader);
isDirty = (bool)ReadObject(reader);
referenceId = (int)ReadObject(reader);
info.AddChild(systemName, referenceId, isDirty);
}
valueCount = reader.ReadInt32();
for (int valueCounter = 0; valueCounter < valueCount; valueCounter++)
{
systemName = (string)ReadObject(reader);
enumTypeName = (string)ReadObject(reader);
isDirty = (bool)ReadObject(reader);
value = ReadObject(reader);
info.AddValue(systemName, value, isDirty, string.IsNullOrEmpty(enumTypeName) ? null : enumTypeName);
}
returnValue.Add(info);
}
}
return returnValue;
}
示例3: OnGetChildren
/// <summary>
/// Override this method to insert your child object
/// references into the MobileFormatter serialzation stream.
/// </summary>
/// <param name="info">
/// Object containing the data to serialize.
/// </param>
/// <param name="formatter">
/// Reference to MobileFormatter instance. Use this to
/// convert child references to/from reference id values.
/// </param>
protected override void OnGetChildren(SerializationInfo info, MobileFormatter formatter)
{
if (_brokenRules != null && _brokenRules.Count > 0)
{
SerializationInfo brInfo = formatter.SerializeObject(_brokenRules);
info.AddChild("_brokenRules", brInfo.ReferenceId);
}
base.OnGetChildren(info, formatter);
}
示例4: GetChildren
/// <summary>
/// Method called by MobileFormatter when an object should serialize its child references. The data should be serialized into the SerializationInfo parameter.
/// </summary>
/// <param name="info">Object to contain the serialized data.</param>
/// <param name="formatter">Reference to the formatter performing the serialization.</param>
public void GetChildren(SerializationInfo info, MobileFormatter formatter)
{
if (info == null)
throw new ArgumentNullException("info");
if (formatter == null)
throw new ArgumentNullException("formatter");
if (BuildFailure != null)
{
var childInfo = formatter.SerializeObject(BuildFailure);
info.AddChild("BuildFailure", childInfo.ReferenceId);
}
}