TypeData MakeGenericTypeData(IReadOnlyList <TypeData> parameters) { if (!IsSupported) { return(this); } if (IsGenericParameter) { return(parameters[this.GenericParameterIndex]); } if (!IsGeneric) { return(this); } var result = new TypeData() { IsSupported = true, Kind = Kind, IsSealed = IsSealed, IsReference = IsReference, IsEnum = IsEnum, IsInterface = IsInterface, HasConverter = HasConverter, IsISerializable = IsISerializable, IsGeneric = true, IsGenericTypeDefinition = false, IsNullable = IsNullable, Element = this, GenericParameters = GenericParameters.Select(x => x.MakeGenericTypeData(parameters)).ToList().AsReadOnly(), }; result.BaseType = BaseType?.MakeGenericTypeData(parameters); result.Surrogate = Surrogate?.MakeGenericTypeData(parameters); if (Surrogate == null && !IsInterface && !IsArray && !IsEnum && !IsGenericParameter) { foreach (var m in Members) { var rm = new Member(result); rm.Name = m.Name; rm.Type = m.Type.MakeGenericTypeData(parameters); result.Members.Add(rm); } result.CollectionType = CollectionType; result.Collection1 = Collection1?.MakeGenericTypeData(parameters); result.Collection2 = Collection2?.MakeGenericTypeData(parameters); } return(result); }
public void RightOuterJoin_ReturnsJoin_OnKey() { var result = Collection1.GetMe().RightOuterJoin(Collection2.GetMe(), x => x.Id, y => y.Id, (i, j) => new { Id = j.Id, i?.Name, j?.Description }); Assert.True(result.Count() == 4); var bob = result.First(); Assert.True(bob.Id == 1 && bob.Name == "Bob" && bob.Description == "Blue"); var black = result.Last(); Assert.True(black.Id == 5 && black.Name == null && black.Description == "Black"); }
public void LeftOuterJoin_ReturnsJoin_OnKey() { var result = Collection1.GetMe().LeftOuterJoin(Collection2.GetMe(), x => x.Id, y => y.Id, (i, j) => new { Id = i.Id, i?.Name, j?.Description }); Assert.True(result.Count() == 4); var bob = result.First(); Assert.True(bob.Id == 1 && bob.Name == "Bob" && bob.Description == "Blue"); var sue = result.Last(); Assert.True(sue.Id == 4 && sue.Name == "Sue" && sue.Description == null); }
public unsafe void Initialize() { _keyIndices = new Dictionary <string, ushort>(); _keyTraits = new Dictionary <ushort, BlackboardKeyTraits>(); _cachedTotalSize = TotalSize; var sortedKeys = Collection1.OrderBy(k => k.SizeInBytes); _template = new NativeArray <byte>(_cachedTotalSize, Allocator.Persistent); var templatePtr = (byte *)_template.GetUnsafePtr(); ushort index = 0; foreach (var key in sortedKeys) { var keyName = key.name; // cache the string-to-id hash table if (!_keyIndices.ContainsKey(keyName)) { _keyIndices.Add(keyName, index); } else { Debug.LogError($"Blackboard contains multiple keys named {keyName}.", this); _keyIndices[keyName] = index; } // update the index on the key itself key.Index = index; // update instance syncing data _keyTraits.Add(index, key.Traits); // set the default value key.SetDefault(templatePtr + index); // get the next index index += key.SizeInBytes; } Assert.AreEqual(_cachedTotalSize, index); InitializationStatus = InitializationState.Active; }
public void AddToCollection(string key, List <Card> Cards) { Collection1.Add(key, Cards); }