using System; using System.Linq; using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Properties; namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Consts { /// /// Concatenation of state and string /// public static class FwUpdateStateInfo { /// /// Build state information /// private static readonly FwUpdateStateText[] StateInfos; /// /// Ctor /// static FwUpdateStateInfo() { StateInfos = new FwUpdateStateText[(Int32)FwUpdateState.FwUpdateStateListDelimiter]; StateInfos[(Int32)FwUpdateState.Idle].State = FwUpdateState.Idle; StateInfos[(Int32)FwUpdateState.Idle].Message = Resources.StrFwUpdateStateIdle; StateInfos[(Int32)FwUpdateState.StepFailed].State = FwUpdateState.StepFailed; StateInfos[(Int32)FwUpdateState.StepFailed].Message = Resources.StrFwUpdateStateStepFailed; StateInfos[(Int32)FwUpdateState.UpdateFailed].State = FwUpdateState.UpdateFailed; StateInfos[(Int32)FwUpdateState.UpdateFailed].Message = Resources.StrFwUpdateStateUpdateFailed; StateInfos[(Int32)FwUpdateState.StartInitial].State = FwUpdateState.StartInitial; StateInfos[(Int32)FwUpdateState.StartInitial].Message = Resources.StrFwUpdateStateStartInitial; StateInfos[(Int32)FwUpdateState.EraseTstFile].State = FwUpdateState.EraseTstFile; StateInfos[(Int32)FwUpdateState.EraseTstFile].Message = Resources.StrEraseTstFile; StateInfos[(Int32)FwUpdateState.RepeatFwUpdate].State = FwUpdateState.RepeatFwUpdate; StateInfos[(Int32)FwUpdateState.RepeatFwUpdate].Message = Resources.StrFwUpdateStateRepeatFwUpdate; StateInfos[(Int32)FwUpdateState.UploadFileApps].State = FwUpdateState.UploadFileApps; StateInfos[(Int32)FwUpdateState.UploadFileApps].Message = Resources.StrFwUpdateStateUploadFileApps; StateInfos[(Int32)FwUpdateState.DownloadFileApps].State = FwUpdateState.DownloadFileApps; StateInfos[(Int32)FwUpdateState.DownloadFileApps].Message = Resources.StrFwUpdateStateDownloadFileApps; StateInfos[(Int32)FwUpdateState.CompareFileApps].State = FwUpdateState.CompareFileApps; StateInfos[(Int32)FwUpdateState.CompareFileApps].Message = Resources.StrFwUpdateStateCompareFileApps; StateInfos[(Int32)FwUpdateState.DownloadUpgradeControlFile].State = FwUpdateState.DownloadUpgradeControlFile; StateInfos[(Int32)FwUpdateState.DownloadUpgradeControlFile].Message = Resources.StrFwUpdateStateDownloadUpgradeControlFile; StateInfos[(Int32)FwUpdateState.BuildUpgradeControlFile].State = FwUpdateState.BuildUpgradeControlFile; StateInfos[(Int32)FwUpdateState.BuildUpgradeControlFile].Message = Resources.StrFwUpdateStateBuildUpgradeControlFile; StateInfos[(Int32)FwUpdateState.BuildFileApps].State = FwUpdateState.BuildFileApps; StateInfos[(Int32)FwUpdateState.BuildFileApps].Message = Resources.StrFwUpdateStateBuildFileApps; StateInfos[(Int32)FwUpdateState.TriggerUpgrade].State = FwUpdateState.TriggerUpgrade; StateInfos[(Int32)FwUpdateState.TriggerUpgrade].Message = Resources.StrFwUpdateStateTriggerUpgrade; StateInfos[(Int32)FwUpdateState.EraseUpdateFile].State = FwUpdateState.EraseUpdateFile; StateInfos[(Int32)FwUpdateState.EraseUpdateFile].Message = Resources.StrFwUpdateStateEraseUpdateFile; StateInfos[(Int32)FwUpdateState.PrepareUpdate].State = FwUpdateState.PrepareUpdate; StateInfos[(Int32)FwUpdateState.PrepareUpdate].Message = Resources.StrFwUpdateStatePrepareUpdate; } /// /// Get the current information /// /// state to search for information text public static String GetTextFromState(FwUpdateState state) { return (from stateInfo in StateInfos where stateInfo.State == state select stateInfo.Message).FirstOrDefault(); } /// /// Get the state of the text /// /// information text to search if state is assigned public static FwUpdateState GetStateFromText(String text) { return (from stateInfo in StateInfos where stateInfo.Message == text select stateInfo.State).FirstOrDefault(); } } }