本文整理汇总了C#中CryEngine.Serialization.ObjectReference类的典型用法代码示例。如果您正苦于以下问题:C# ObjectReference类的具体用法?C# ObjectReference怎么用?C# ObjectReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectReference类属于CryEngine.Serialization命名空间,在下文中一共展示了ObjectReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WriteDelegate
void WriteDelegate(ObjectReference objectReference)
{
var _delegate = objectReference.Value as Delegate;
WriteType(_delegate.GetType());
WriteMemberInfo(_delegate.Method);
if (_delegate.Target != null)
{
WriteLine("target");
StartWrite(new ObjectReference("delegateTarget", _delegate.Target));
}
else
WriteLine("null_target");
}
开发者ID:BenChung,项目名称:CryMono,代码行数:13,代码来源:CrySerializer.cs
示例2: WriteReference
void WriteReference(ObjectReference objReference, int line)
{
WriteLine(SerializationType.Reference);
WriteLine(line);
}
开发者ID:RogierWV,项目名称:315GR,代码行数:5,代码来源:CrySerializer.cs
示例3: WriteType
void WriteType(ObjectReference objectReference)
{
WriteType(objectReference.Value as Type);
}
开发者ID:RogierWV,项目名称:315GR,代码行数:4,代码来源:CrySerializer.cs
示例4: WriteGenericEnumerable
void WriteGenericEnumerable(ObjectReference objectReference)
{
var enumerable = (objectReference.Value as IEnumerable).Cast<object>();
WriteLine(enumerable.Count());
var type = objectReference.Value.GetType();
WriteType(type);
if (type.Implements<IDictionary>())
{
int i = 0;
foreach (var element in enumerable)
{
StartWrite(new ObjectReference("key_" + i.ToString(), element.GetType().GetProperty("Key").GetValue(element, null)));
StartWrite(new ObjectReference("value_" + i.ToString(), element.GetType().GetProperty("Value").GetValue(element, null)));
i++;
}
}
else
{
for (int i = 0; i < enumerable.Count(); i++)
StartWrite(new ObjectReference(i.ToString(), enumerable.ElementAt(i)));
}
}
开发者ID:RogierWV,项目名称:315GR,代码行数:25,代码来源:CrySerializer.cs
示例5: WriteMemberInfo
void WriteMemberInfo(ObjectReference objectReference)
{
var memberInfo = objectReference.Value as MemberInfo;
WriteMemberInfo(memberInfo);
}
开发者ID:RogierWV,项目名称:315GR,代码行数:5,代码来源:CrySerializer.cs
示例6: WriteArray
void WriteArray(ObjectReference objectReference)
{
var array = objectReference.Value as Array;
var numElements = array.Length;
WriteLine(numElements);
WriteType(array.GetType().GetElementType());
for (int i = 0; i < numElements; i++)
StartWrite(new ObjectReference(i.ToString(), array.GetValue(i)));
}
开发者ID:RogierWV,项目名称:315GR,代码行数:11,代码来源:CrySerializer.cs
示例7: WriteEnum
void WriteEnum(ObjectReference objectReference)
{
WriteType(objectReference.Value.GetType());
WriteLine(objectReference.Value);
}
开发者ID:RogierWV,项目名称:315GR,代码行数:5,代码来源:CrySerializer.cs
示例8: ReadEnum
void ReadEnum(ObjectReference objReference)
{
var type = ReadType();
string valueString = ReadLine();
objReference.Value = Enum.Parse(type, valueString);
}
开发者ID:RogierWV,项目名称:315GR,代码行数:7,代码来源:CrySerializer.cs
示例9: ReadEnumerable
void ReadEnumerable(ObjectReference objReference)
{
var numElements = int.Parse(ReadLine());
var type = ReadType();
objReference.Value = Array.CreateInstance(type, numElements);
var array = objReference.Value as Array;
for (int i = 0; i != numElements; ++i)
array.SetValue(StartRead().Value, i);
}
开发者ID:RogierWV,项目名称:315GR,代码行数:11,代码来源:CrySerializer.cs
示例10: ReadAny
void ReadAny(ObjectReference objReference)
{
var type = ReadType();
string valueString = ReadLine();
if (!string.IsNullOrEmpty(valueString))
objReference.Value = Converter.Convert(valueString, type);
else
objReference.Value = 0;
}
开发者ID:RogierWV,项目名称:315GR,代码行数:10,代码来源:CrySerializer.cs
示例11: ReadDelegate
void ReadDelegate(ObjectReference objReference)
{
objReference.Value = ReadDelegate();
}
开发者ID:RogierWV,项目名称:315GR,代码行数:4,代码来源:CrySerializer.cs
示例12: StartWrite
/// <summary>
/// Starts writing the specified reference.
/// </summary>
/// <param name="objectReference"></param>
public void StartWrite(ObjectReference objectReference)
{
WriteLine(objectReference.Name);
if (TryWriteReference(objectReference))
return;
WriteLine((int)objectReference.SerializationType);
switch(objectReference.SerializationType)
{
case SerializationType.Null:
break;
case SerializationType.IntPtr:
WriteIntPtr(objectReference);
break;
case SerializationType.Any:
WriteAny(objectReference);
break;
case SerializationType.String:
WriteString(objectReference);
break;
case SerializationType.Array:
WriteArray(objectReference);
break;
case SerializationType.Enumerable:
WriteEnumerable(objectReference);
break;
case SerializationType.GenericEnumerable:
WriteGenericEnumerable(objectReference);
break;
case SerializationType.Enum:
WriteEnum(objectReference);
break;
case SerializationType.Type:
WriteType(objectReference);
break;
case SerializationType.Delegate:
WriteDelegate(objectReference);
break;
case SerializationType.MemberInfo:
WriteMemberInfo(objectReference);
break;
case SerializationType.Object:
WriteObject(objectReference);
break;
case SerializationType.UnusedMarker:
WriteUnusedMarker(objectReference);
break;
}
}
开发者ID:RogierWV,项目名称:315GR,代码行数:55,代码来源:CrySerializer.cs
示例13: StartRead
/// <summary>
/// Starts reading an reference that was written with <see cref="StartWrite"/>.
/// </summary>
/// <returns></returns>
public ObjectReference StartRead()
{
var name = ReadLine();
int line = m_currentLine;
var serializationType = (SerializationType)Enum.Parse(typeof(SerializationType), ReadLine());
var objReference = new ObjectReference(name, serializationType);
if (serializationType > SerializationType.ReferenceTypes)
ObjectReferences.Add(line, objReference);
switch (serializationType)
{
case SerializationType.Null: break;
case SerializationType.Reference: ReadReference(objReference); break;
case SerializationType.Object: ReadObject(objReference); break;
case SerializationType.Array: ReadArray(objReference); break;
case SerializationType.GenericEnumerable: ReadGenericEnumerable(objReference); break;
case SerializationType.Enumerable: ReadEnumerable(objReference); break;
case SerializationType.Enum: ReadEnum(objReference); break;
case SerializationType.Any: ReadAny(objReference); break;
case SerializationType.String: ReadString(objReference); break;
case SerializationType.MemberInfo: ReadMemberInfo(objReference); break;
case SerializationType.Type: ReadType(objReference); break;
case SerializationType.Delegate: ReadDelegate(objReference); break;
case SerializationType.IntPtr: ReadIntPtr(objReference); break;
case SerializationType.UnusedMarker: ReadUnusedMarker(objReference); break;
}
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
if (!objReference.AllowNull && objReference.Value == null && serializationType != SerializationType.Null)
throw new SerializationException(string.Format("Failed to deserialize object of type {0} {1} at line {2}!", objReference.SerializationType, objReference.Name, line));
#endif
return objReference;
}
开发者ID:RogierWV,项目名称:315GR,代码行数:41,代码来源:CrySerializer.cs
示例14: WriteObject
void WriteObject(ObjectReference objectReference)
{
var type = objectReference.Value.GetType();
WriteType(type);
while (type != null)
{
var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
WriteLine(fields.Length);
foreach (var field in fields)
StartWrite(new ObjectReference(field.Name, field.GetValue(objectReference.Value)));
type = type.BaseType;
}
}
开发者ID:BenChung,项目名称:CryMono,代码行数:15,代码来源:CrySerializer.cs
示例15: ReadUnusedMarker
void ReadUnusedMarker(ObjectReference objReference)
{
var type = ReadType();
if (type == typeof(int))
objReference.Value = UnusedMarker.Integer;
if (type == typeof(uint))
objReference.Value = UnusedMarker.UnsignedInteger;
else if (type == typeof(float))
objReference.Value = UnusedMarker.Float;
else if (type == typeof(Vec3))
objReference.Value = UnusedMarker.Vec3;
}
开发者ID:RogierWV,项目名称:315GR,代码行数:12,代码来源:CrySerializer.cs
示例16: ReadGenericEnumerable
void ReadGenericEnumerable(ObjectReference objReference)
{
int elements = int.Parse(ReadLine());
var type = ReadType();
objReference.Value = Activator.CreateInstance(type);
if (type.Implements<IDictionary>())
{
var dict = objReference.Value as IDictionary;
for (int i = 0; i < elements; i++)
{
var key = StartRead().Value;
var value = StartRead().Value;
dict.Add(key, value);
}
}
else if (type.Implements<IList>())
{
var list = objReference.Value as IList;
for (int i = 0; i < elements; i++)
list.Add(StartRead().Value);
}
else if (type.ImplementsGeneric(typeof(ISet<>)) || type.ImplementsGeneric(typeof(ICollection<>)))
{
var set = objReference.Value;
MethodInfo addMethod = null;
var baseType = type;
while (baseType != null)
{
addMethod = type.GetMethod("Add", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
if (addMethod != null)
break;
baseType = baseType.BaseType;
}
for (int i = 0; i < elements; i++)
{
addMethod.Invoke(objReference.Value, new object[] { StartRead().Value });
}
}
else if (IsDebugModeEnabled)
throw new SerializationException(string.Format("Failed to serialize generic enumerable of type {0}, not supported by implementation", type.Name));
}
开发者ID:RogierWV,项目名称:315GR,代码行数:51,代码来源:CrySerializer.cs
示例17: TryWriteReference
/// <summary>
/// Checks if this object has already been serialized.
/// </summary>
/// <param name="objectReference"></param>
/// <returns>true if object had already been serialized.</returns>
bool TryWriteReference(ObjectReference objectReference)
{
if(objectReference.SerializationType > SerializationType.ReferenceTypes)
{
foreach (var pair in ObjectReferences)
{
if (pair.Value.Value.Equals(objectReference.Value))
{
WriteReference(objectReference, pair.Key);
return true;
}
}
ObjectReferences.Add(m_currentLine, objectReference);
}
return false;
}
开发者ID:RogierWV,项目名称:315GR,代码行数:23,代码来源:CrySerializer.cs
示例18: ReadIntPtr
void ReadIntPtr(ObjectReference objReference)
{
objReference.Value = new IntPtr(Int64.Parse(ReadLine()));
}
开发者ID:RogierWV,项目名称:315GR,代码行数:4,代码来源:CrySerializer.cs
示例19: WriteDelegate
void WriteDelegate(ObjectReference objectReference)
{
WriteDelegate(objectReference.Value as Delegate);
}
开发者ID:RogierWV,项目名称:315GR,代码行数:4,代码来源:CrySerializer.cs
示例20: ReadMemberInfo
void ReadMemberInfo(ObjectReference objReference)
{
objReference.Value = ReadMemberInfo();
}
开发者ID:RogierWV,项目名称:315GR,代码行数:4,代码来源:CrySerializer.cs
注:本文中的CryEngine.Serialization.ObjectReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论