public static ParameterKey <T[]> NewDynamic <T>(int arraySize, ParameterDynamicValue <T[]> dynamicValue, string name = null) where T : struct { if (name == null) { name = string.Empty; } var metadata = new ParameterKeyValueMetadata <T[]>(dynamicValue); var result = new ParameterKey <T[]>(name, arraySize, metadata); return(result); }
public static ParameterKey <T> NewDynamic <T>(ParameterDynamicValue <T> dynamicValue, string name = null) { if (name == null) { name = string.Empty; } var metadata = new ParameterKeyValueMetadata <T>(dynamicValue); var result = new ParameterKey <T>(name, 1, metadata); return(result); }
public override void Serialize(ref ParameterKey <T> obj, ArchiveMode mode, SerializationStream stream) { if (mode == ArchiveMode.Serialize) { stream.Write(obj.Name); stream.Write(obj.Length); } else { var parameterName = stream.ReadString(); var parameterLength = stream.ReadInt32(); obj = (ParameterKey <T>)ParameterKeys.FindByName(parameterName); // If parameter could not be found, create one matching this type. if (obj == null) { var metadata = new ParameterKeyValueMetadata <T>(); obj = new ParameterKey <T>(parameterName, parameterLength, metadata); ParameterKeys.Merge(obj, null, parameterName); } } }