Example #1
0
        public IkonBaseObject Serialize(object originalValue, SaveSession session)
        {
            if (this.serializationMethod == null)
            {
                throw new InvalidOperationException("No serialization method defined for type " + originalValue.GetType().FullName);
            }

            return(this.serializationMethod(originalValue, session));
        }
Example #2
0
        public IkonBaseObject Save(object obj)
        {
            var session = new SaveSession(getTypeStrategy);

            var mainData       = session.Serialize(obj);
            var referencedData = session.GetSerialzedData();

            var result = new IkonComposite(MainGame.SaveGameTag);

            result.Add("references", new IkonArray(referencedData));
            result.Add(EntryPointKey, mainData);

            return(result);
        }
Example #3
0
        public IkonBaseObject Serialize(object originalValue, SaveSession session)
        {
            var data      = new IkonComposite(this.saveTag);
            var reference = session.SaveReference(originalValue, data, this.saveTag);

            foreach (var property in this.properties.Where(x => x.Attribute.DoSave))
            {
                if (property.Get(originalValue) != null)
                {
                    data.Add(property.Name, property.Serialize(originalValue, session));
                }
            }

            return(reference);
        }
Example #4
0
 public IkonBaseObject Serialize(object originalObject, SaveSession session)
 {
     return(session.Serialize(this.getter(originalObject)));
 }
Example #5
0
 public IkonBaseObject Serialize(object originalValue, SaveSession session)
 {
     return(this.serializeChildrenInvoker(this, originalValue, session));
 }
Example #6
0
        private IkonBaseObject serializeChildren <T>(ICollection <T> originalCollection, SaveSession session)
        {
            var data = new IkonArray();

            foreach (var element in originalCollection)
            {
                data.Add(session.Serialize(element));
            }

            return(data);
        }
Example #7
0
 private IkonBaseObject serializeChildren <T>(T[] originalArray, SaveSession session)
 {
     return(new IkonArray(originalArray.Select(x => session.Serialize(x))));
 }
Example #8
0
        private IkonBaseObject serializeChildren <K, V>(IDictionary <K, V> originalDictionary, SaveSession session)
        {
            var data = new IkonArray();

            foreach (var element in originalDictionary)
            {
                data.Add(session.Serialize(element.Key));
                data.Add(session.Serialize(element.Value));
            }

            return(data);
        }