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]) )); } }
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); }
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); }
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); }
public static bool IsAutosave(IkonBaseObject previewData) { return(previewData.To <IkonComposite>().Keys.Contains(AutosaveKey)); }
public static int TurnOf(IkonBaseObject previewData) { return(previewData.To <IkonComposite>()[TurnKey].To <int>()); }