public static T GetEnum <T>(this IniKeyCollection keys, string key) where T : struct { var value = keys.GetString(key); return((T)Enum.Parse(typeof(T), value, true)); }
protected override CodeLayer Load(IniKeyCollection iniData, LayerHandlerContext context) { return(new CodeLayer { Name = iniData.GetString("name"), ByteCode = context.LoadExternalFile(ClassFileKey) }); }
protected override ActionLayer Load(IniKeyCollection iniData, LayerHandlerContext context) { var data = new ActionLayer(); data.Name = iniData.GetString("name"); data.Hotkey = iniData.GetChar("hotkey"); var parent = iniData.GetString("parent", ""); if (!string.IsNullOrEmpty(parent)) { var parts = parent.Split(':'); data.Parent = new ResourceRef(parts[0], ushort.Parse(parts[1])); } data.Prerequisite = iniData.GetString("prereq", string.Empty); data.Verbs = iniData.GetString("verbs", "")?.Split(','); return(data); }
protected override AudioLayer Load(IniKeyCollection iniData, LayerHandlerContext context) { return(new AudioLayer { Id = iniData.GetString("id"), BaseVolume = iniData.GetDouble("volume", 1.0), Data = context.LoadExternalFile(AudioFileKey) }); }
public static T GetEnum <T>(this IniKeyCollection keys, string key, T defaultValue) where T : struct { var value = keys.GetString(key, ""); try { return((T)Enum.Parse(typeof(T), value)); } catch (Exception) { return(defaultValue); } }