private void OutputProperty(JObject iCurrent, string lLine, string iComment) { int lPos = lLine.IndexOf('='); bool lKomma = true; string lProperty = lLine.Substring(0, lPos).Trim(); string lValue = lLine.Substring(lPos + 1).Trim(); if (lProperty == "cache" || lProperty == "enforce_updates") { lValue = lValue.ToLower(); AddProperty(iCurrent, lProperty, "1|yes|true|y|on".Contains(lValue), iComment); } else if (lProperty == "sqlite") { lValue = lValue.ToLower(); lKomma = !"0|no|false|n|off".Contains(lValue); if (lKomma) { AddProperty(iCurrent, lProperty, "1|yes|true|y|on".Contains(lValue) ? "yes" : "init", iComment); } } else if (lProperty == "knx_listen" && lValue.Contains("|")) { JArray lArray = new JArray(); string[] lEntries = lValue.Split('|'); foreach (var lEntry in lEntries) { lArray.Add(lEntry.Trim()); } AddProperty(iCurrent, lProperty, lArray, iComment); } else if (lProperty == "knx_dpt") { if (mDptMapping.ContainsKey(lValue)) lValue = mDptMapping[lValue]; AddProperty(iCurrent, lProperty, lValue, iComment); } else if (lProperty == "autotimer") { string[] lEntries = lValue.Split('='); JObjectComment lAutotimer = new JObjectComment(); string lTime = lEntries[0].Trim(); if (lTime.EndsWith("m")) { lAutotimer.Add("minutes", int.Parse(lTime.TrimEnd('m'))); } else { lAutotimer.Add("seconds", int.Parse(lTime)); } lAutotimer.Add("value", lEntries[1].Trim()); AddProperty(iCurrent, lProperty, lAutotimer, iComment); } else AddProperty(iCurrent,lProperty, lValue, iComment); }
public conf2json(StreamReader iFile) { mFile = iFile; mOut = new JObjectComment(); mOut.Add("$schema", "../schema/ItemSchema.json"); }