/// <summary> /// Adds a file master. If the master's key or filename is equivalent to any existing /// master, this will fail /// </summary> /// <param name="master">New master to add</param> /// public static void AddMaster(JsonToSimplMaster master) { if (master == null) { throw new ArgumentNullException("master"); } if (string.IsNullOrEmpty(master.UniqueID)) { throw new InvalidOperationException("JSON Master cannot be added with a null UniqueId"); } Debug.Console(1, "JSON Global adding master {0}", master.UniqueID); if (Masters.Contains(master)) { return; } var existing = Masters.FirstOrDefault(m => m.UniqueID.Equals(master.UniqueID, StringComparison.OrdinalIgnoreCase)); if (existing == null) { Masters.Add(master); } else { var msg = string.Format("Cannot add JSON Master with unique ID '{0}'.\rID is already in use on another master.", master.UniqueID); CrestronConsole.PrintLine(msg); ErrorLog.Warn(msg); } }
/// <summary> /// Call this before doing anything else /// </summary> /// <param name="file"></param> /// <param name="key"></param> /// <param name="pathPrefix"></param> /// <param name="pathSuffix"></param> public void Initialize(string masterUniqueId, string key, string pathPrefix, string pathSuffix) { Key = key; PathPrefix = pathPrefix; PathSuffix = pathSuffix; Master = J2SGlobal.GetMasterByFile(masterUniqueId); if (Master != null) { Master.AddChild(this); } else { Debug.Console(1, "JSON Child [{0}] cannot link to master {1}", key, masterUniqueId); } }