public MMEChannel(MMEChannelMeta mMEChannelMeta) { ChannelFilePath = ""; Meta = mMEChannelMeta; InitializeAttributes(); InitializeComments(); InitializeValues(); IsLoaded = true; }
public MMEChannel(string channelFilePath, MMEChannelMeta mMEChannelMeta) { ChannelFilePath = Path.GetFullPath(channelFilePath); Meta = mMEChannelMeta; InitializeAttributes(); InitializeComments(); InitializeValues(); IsLoaded = File.Exists(channelFilePath); }
private MMEChannelMeta ParseToMMEMeta(MMEAttribute newAttribute) { string[] splittedValue = newAttribute.Value.Split(new[] { MME_CODE_NAME_SPLITTER }, 2); MMEChannelMeta mmeMeta = new MMEChannelMeta(); if (splittedValue.Length > 0) { mmeMeta.Code = splittedValue[0].Trim(); } if (splittedValue.Length > 1) { mmeMeta.Name = splittedValue[1].Trim(); } mmeMeta.Number = int.Parse(newAttribute.Name.Substring(MME_NAME_OF_CHANNEL_KEY_PREFIX.Length).Trim()); return(mmeMeta); }
private void LoadChannelsMetaData() { using (StreamReader reader = new StreamReader(ChannelInformationFilePath, Encoding.GetEncoding(MMEInformationFileHelper.DEFAULT_MME_ENCODING), true)) { while (!reader.EndOfStream) { MMEAttribute newAttribute = null; MMEAttribute.ParseFromStream(reader, out newAttribute); if (newAttribute == null) { continue; } if (newAttribute.Name == "" && newAttribute.Value == "") { Comments.AddRange(newAttribute.Comments); } else { if (newAttribute.Name.Equals(MME_NUMBER_OF_CHANNELS_KEY, StringComparison.InvariantCultureIgnoreCase)) { // do not add Number of channels to the attributes list } else if (newAttribute.Name.StartsWith(MME_NAME_OF_CHANNEL_KEY_PREFIX, StringComparison.InvariantCultureIgnoreCase)) { MMEChannelMeta metaInf = ParseToMMEMeta(newAttribute); string channelFilePath = Path.Combine(ChannelDirectoryPath, DataSet.Name + "." + metaInf.Number.ToString("D3")); this.Add(new MMEChannel(channelFilePath, metaInf)); } else { Attributes.Add(newAttribute.Name, newAttribute); } } } } }