コード例 #1
0
        private void insert(ref SLPointer ptr, SLComponent com)
        {
            if (null == com)
            {
                throw new ArgumentNullException($"[{this.ToString()}] this com can't link to null component.");
            }

            if (!_groups.TryGetValue(ptr, out SLWrapper wrapper))
            {
                wrapper = new SLWrapper(com);
                _groups.Add(ptr, wrapper);
            }
            else
            {
                wrapper.Add(com);
            }
        }
コード例 #2
0
        public void OnDeserialized(ref Library.Reader reader, SLComponent streamingComponent)
        {
            var read = true;

            read &= reader.ReadInt(out int groupCount);
            Library.Logger.Assert(read, "[OnDeserialized] fail to read component: linkedCount");

            for (int i = 0; i != groupCount; i++)
            {
                var ptr = new SLPointer();
                ptr.OnDeserialized(ref reader, null);

                read &= reader.ReadInt(out int childCount);
                Library.Logger.Assert(read, "[OnDeserialized] fail to read component: type|value|rootFakeIndex|childCount");

                var wrapper = new SLWrapper();
                for (int k = 0; k != childCount; k++)
                {
                    read &= reader.ReadInt(out int fakeIndex);
                    Library.Logger.Assert(read, "[OnDeserialized] fail to read component: fakeIndex");

                    var child = streamingComponent.Find(fakeIndex);
                    wrapper.Add(child.First());
                }

                _groups.Add(ptr, wrapper);
            }

            read &= reader.ReadInt(out int propCount);
            Library.Logger.Assert(read, "[OnDeserialized] fail to read component: propCount");

            for (int i = 0; i != propCount; i++)
            {
                read &= reader.ReadInt(out int propIndex);
                read &= reader.ReadInt(out int propSize);
                Library.Logger.Assert(read, "[OnDeserialized] fail to read component: propIndex|propSize");

                var propType = Property.PropertyAttribute.GetProperty(propIndex);
                unsafe
                {
                    var propPtr = this.Get(propType);
                    reader.ReadMemory((void *)propPtr, propSize);
                }
            }
        }
コード例 #3
0
 public bool TryFind(object key, out SLWrapper wrap) => _groups.TryGetValue(SLPointer.Reference(key), out wrap);
コード例 #4
0
 public bool TryFind(string key, out SLWrapper wrap) => _groups.TryGetValue(SLPointer.Text(key), out wrap);
コード例 #5
0
 public bool TryFind(int handle, out SLWrapper wrap) => _groups.TryGetValue(SLPointer.Handle(handle), out wrap);
コード例 #6
0
 public bool TryFind(ComponentType type, out SLWrapper wrap) => _groups.TryGetValue(SLPointer.Type(type), out wrap);