public EntityProperty(string name, FoxDataType type, FoxContainerType container = FoxContainerType.StaticArray, bool isDynamic = false) { Name = name; Type = type; Container = container; IsDynamic = isDynamic; }
private static IFoxContainer CreateContainer <T>(FoxContainerType containerType) where T : IFoxValue, new() { switch (containerType) { case FoxContainerType.StaticArray: return(new FoxStaticArray <T>()); case FoxContainerType.DynamicArray: return(new FoxDynamicArray <T>()); case FoxContainerType.StringMap: return(new FoxStringMap <T>()); case FoxContainerType.List: return(new FoxList <T>()); default: throw new ArgumentOutOfRangeException("containerType"); } }
private static string GetFieldName(Type propertyType, FoxContainerType containerType) { var typeName = GetRealTypeName(propertyType); switch (containerType) { case FoxContainerType.StaticArray: return(typeName); case FoxContainerType.DynamicArray: return("List<" + typeName + ">"); case FoxContainerType.StringMap: return("Dictionary<string, " + typeName + ">"); case FoxContainerType.List: return("List<" + typeName + ">"); default: throw new ArgumentOutOfRangeException(nameof(containerType), containerType, null); } }
public static IFoxContainer CreateTypedContainer(FoxDataType dataType, FoxContainerType containerType) { IFoxContainer container; switch (dataType) { case FoxDataType.FoxInt8: container = CreateContainer <FoxInt8>(containerType); break; case FoxDataType.FoxUInt8: container = CreateContainer <FoxUInt8>(containerType); break; case FoxDataType.FoxInt16: container = CreateContainer <FoxInt16>(containerType); break; case FoxDataType.FoxUInt16: container = CreateContainer <FoxUInt16>(containerType); break; case FoxDataType.FoxInt32: container = CreateContainer <FoxInt32>(containerType); break; case FoxDataType.FoxUInt32: container = CreateContainer <FoxUInt32>(containerType); break; case FoxDataType.FoxInt64: container = CreateContainer <FoxInt64>(containerType); break; case FoxDataType.FoxUInt64: container = CreateContainer <FoxUInt64>(containerType); break; case FoxDataType.FoxFloat: container = CreateContainer <FoxFloat>(containerType); break; case FoxDataType.FoxDouble: container = CreateContainer <FoxDouble>(containerType); break; case FoxDataType.FoxBool: container = CreateContainer <FoxBool>(containerType); break; case FoxDataType.FoxString: container = CreateContainer <FoxString>(containerType); break; case FoxDataType.FoxPath: container = CreateContainer <FoxPath>(containerType); break; case FoxDataType.FoxEntityPtr: container = CreateContainer <FoxEntityPtr>(containerType); break; case FoxDataType.FoxVector3: container = CreateContainer <FoxVector3>(containerType); break; case FoxDataType.FoxVector4: container = CreateContainer <FoxVector4>(containerType); break; case FoxDataType.FoxQuat: container = CreateContainer <FoxQuat>(containerType); break; case FoxDataType.FoxMatrix3: container = CreateContainer <FoxMatrix3>(containerType); break; case FoxDataType.FoxMatrix4: container = CreateContainer <FoxMatrix4>(containerType); break; case FoxDataType.FoxColor: container = CreateContainer <FoxColor>(containerType); break; case FoxDataType.FoxFilePtr: container = CreateContainer <FoxFilePtr>(containerType); break; case FoxDataType.FoxEntityHandle: container = CreateContainer <FoxEntityHandle>(containerType); break; case FoxDataType.FoxEntityLink: container = CreateContainer <FoxEntityLink>(containerType); break; case FoxDataType.FoxPropertyInfo: container = CreateContainer <FoxPropertyInfo>(containerType); break; case FoxDataType.FoxWideVector3: container = CreateContainer <FoxWideVector3>(containerType); break; default: throw new ArgumentOutOfRangeException("dataType"); } return(container); }
public static IFoxContainer ReadFoxContainer(Stream input, FoxDataType dataType, FoxContainerType containerType, short valueCount) { var container = CreateTypedContainer(dataType, containerType); container.Read(input, valueCount); return(container); }
private static string MakeFieldDeclaration(string propertyName, Type propertyType, FoxContainerType containerType) { return(" public " + GetFieldName(propertyType, containerType) + " " + char.ToUpper(propertyName[0]) + propertyName.Substring(1) + ";"); }
private static string MakeFieldAttribute(string propertyName, FoxDataType dataType, FoxContainerType containerType, bool isDynamic) { var attributeStringBuilder = new StringBuilder(" [EntityProperty(\""); attributeStringBuilder.Append(propertyName); attributeStringBuilder.Append("\", FoxDataType."); attributeStringBuilder.Append(dataType); attributeStringBuilder.Append(", FoxContainerType."); attributeStringBuilder.Append(containerType); if (isDynamic) { attributeStringBuilder.Append(", true"); } attributeStringBuilder.Append(")]"); return(attributeStringBuilder.ToString()); }