Beispiel #1
0
        public bool TryGetDataSerializer(Type type, out DataSerializer dataSerializer, bool initializeDataSerializer = true)
        {
            if (_methods.TryGetValue(type, out dataSerializer))
            {
                return(dataSerializer != null);
            }

            foreach (var provider in _providers)
            {
                if (provider.TryGet(this, type, out dataSerializer) == false)
                {
                    continue;
                }

                _methods.Add(type, dataSerializer);

                if (initializeDataSerializer)
                {
                    dataSerializer.RootInitialize(this);
                }

                return(true);
            }

            dataSerializer = default;
            _methods.Add(type, dataSerializer);
            return(false);
        }
Beispiel #2
0
        protected override void Initialize(USerializer serializer)
        {
            _elementSerializer.RootInitialize(serializer);

            _elementDataType = _elementSerializer.GetDataType();

            if (_elementDataType == DataType.None)
            {
                serializer.Logger.Error("Element data type is none, something went wrong!");
            }
        }
Beispiel #3
0
        public bool TryGetNonCachedSerializationMethods(Type type, out DataSerializer dataSerializer, Func <ISerializationProvider, bool> shouldUse = null)
        {
            foreach (var provider in _providers)
            {
                if (shouldUse != null &&
                    shouldUse(provider) == false)
                {
                    continue;
                }

                if (provider.TryGet(this, type, out dataSerializer) == false)
                {
                    continue;
                }

                dataSerializer.RootInitialize(this);

                return(true);
            }

            dataSerializer = default;
            return(false);
        }
Beispiel #4
0
 protected override void Initialize(USerializer serializer)
 {
     _dataSerializer.RootInitialize(serializer);
 }