BTDB.EventStore2Layer.EventSerializer.MergeTypesByShapeAndStoreNew C# (CSharp) Method

MergeTypesByShapeAndStoreNew() private method

private MergeTypesByShapeAndStoreNew ( ) : bool
return bool
        bool MergeTypesByShapeAndStoreNew()
        {
            List<SerializerTypeInfo> toStore = null;
            foreach (var typeDescriptor in _typeOrDescriptor2InfoNew)
            {
                var info = typeDescriptor.Value;
                if (info.Id == 0)
                {
                    var d = info.Descriptor;
                    foreach (var existingTypeDescriptor in _typeOrDescriptor2Info)
                    {
                        if (d.Equals(existingTypeDescriptor.Value.Descriptor))
                        {
                            info.Id = existingTypeDescriptor.Value.Id;
                            break;
                        }
                    }
                }
                if (info.Id == 0)
                {
                    if (toStore == null) toStore = new List<SerializerTypeInfo>();
                    toStore.Add(info);
                    info.Id = -toStore.Count;
                }
                else if (info.Id > 0)
                {
                    if (typeDescriptor.Key is Type)
                    {
                        _typeOrDescriptor2Info[typeDescriptor.Key] = _id2Info[info.Id];
                    }
                }
            }
            if (toStore != null)
            {
                for (int i = toStore.Count - 1; i >= 0; i--)
                {
                    _writer.WriteVInt32(toStore[i].Id);
                    StoreDescriptor(toStore[i].Descriptor, _writer);
                }
                _writer.WriteVInt32(0);
                return true;
            }
            return false;
        }