예제 #1
0
        public static IEnumerable <Tuple <PointF, Color> > StarsOf(IkonBaseObject previewData)
        {
            var starData = previewData.To <IkonComposite>()[StarsKey].To <IkonArray>();

            foreach (var item in starData.Select(x => x.To <IkonComposite>()))
            {
                var colorData = item[ColorKey].To <int[]>();
                yield return(new Tuple <PointF, Color>(
                                 new PointF(
                                     item["x"].To <float>(),
                                     -item["y"].To <float>()
                                     ),
                                 Color.FromArgb(colorData[0], colorData[1], colorData[2])
                                 ));
            }
        }
예제 #2
0
        public object Deserialize(IkonBaseObject rawData, LoadSession session)
        {
            var loadedValue = this.constructor();
            var saveData    = rawData.To <IkonComposite>();

            foreach (var property in this.properties.Where(x => x.Attribute.DoSave))
            {
                if (saveData.Keys.Contains(property.Name))
                {
                    property.Deserialize(loadedValue, saveData[property.Name].To <IkonBaseObject>(), session);
                }
                else
                {
                    property.SetNull(loadedValue);
                }
            }

            return(loadedValue);
        }
예제 #3
0
        public T Load <T>(IkonBaseObject data)
        {
            if (deserialized.ContainsKey(data))
            {
                return((T)deserialized[data]);
            }

            if (this.Deindexer.HasType(typeof(T)))
            {
                return(this.Deindexer.Get <T>(data.To <int>()));
            }

            var expert = this.expertGetter(typeof(T));
            var result = expert.Deserialize(data, this);

            if (postLoadActions.ContainsKey(typeof(T)))
            {
                postLoadActions[typeof(T)](result);
            }
            this.deserialized[data] = result;

            return((T)result);
        }
예제 #4
0
        public T Load <T>(IkonBaseObject data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (deserialized.ContainsKey(data))
            {
                return((T)deserialized[data]);
            }

            if (this.Deindexer.HasType(typeof(T)))
            {
                return(this.Deindexer.Get <T>(data.To <string>()));
            }

            var expert = this.expertGetter(typeof(T));
            var result = expert.Deserialize(data, this);

            this.deserialized[data] = result;

            return((T)result);
        }
예제 #5
0
 public static bool IsAutosave(IkonBaseObject previewData)
 {
     return(previewData.To <IkonComposite>().Keys.Contains(AutosaveKey));
 }
예제 #6
0
 public static int TurnOf(IkonBaseObject previewData)
 {
     return(previewData.To <IkonComposite>()[TurnKey].To <int>());
 }