public EchonetObject(byte classGroupCode, byte classCode) { ClassGroup = SpecificationMaster.GetInstance().プロファイル.Where(p => p.ClassGroupCode == classGroupCode).FirstOrDefault(); if (ClassGroup == null) { ClassGroup = SpecificationMaster.GetInstance().機器.Where(p => p.ClassGroupCode == classGroupCode).FirstOrDefault(); } if (ClassGroup != null) { //スーパークラスのプロパティを列挙 var superClassFilePath = Path.Combine(Directory.GetCurrentDirectory(), "MasterData", $"{ClassGroup.SuperClass}.json"); if (File.Exists(superClassFilePath)) { var superClassProperties = JsonConvert.DeserializeObject <PropertyMaster>(File.ReadAllText(superClassFilePath, new UTF8Encoding(false))); Properties.AddRange(superClassProperties.Properties); } Class = ClassGroup.ClassList.Where(c => c.Status && c.ClassCode == classCode).FirstOrDefault(); if (Class.Status) { var classFilePath = Path.Combine(Directory.GetCurrentDirectory(), "MasterData", $"0x{ClassGroup.ClassGroupCode:X2}-{ClassGroup.ClassGroupName}", $"0x{Class.ClassCode:X2}-{Class.ClassName}.json"); if (File.Exists(classFilePath)) { //クラスのプロパティを列挙 var classProperties = JsonConvert.DeserializeObject <PropertyMaster>(File.ReadAllText(classFilePath, new UTF8Encoding(false))); Properties.AddRange(classProperties.Properties); } } } }
/// <summary> /// インスタンス取得 /// </summary> /// <returns></returns> public static SpecificationMaster GetInstance() { if (_Instance == null) { var filePath = Path.Combine(Directory.GetCurrentDirectory(), "MasterData", "SpecificationMaster.json"); _Instance = JsonConvert.DeserializeObject <SpecificationMaster>(File.ReadAllText(filePath, new UTF8Encoding(false))); } return(_Instance); }