/// <summary> /// Lazy initialization for initables because the set refuses to initialize /// before callers call its add method if I initialize it in the fields. /// </summary> /// <param name="init">Initable content for Main.cs to load.</param> public static void AddInit(IInitable init) { if (initables == null) { initables = new HashSet <IInitable>(); } initables.Add(init); }
public bool Validate(IInitable initable, out string message) { var entry = initable as Entry; if (entry == null) { message = "The init section is only allowed for entries."; return(false); } message = null; return(true); }
public static bool Init(this IInitable initable) { if (initable == null) { throw new ArgumentNullException(nameof(initable)); } var instance = (Object)initable; var ret = g_initable_init(instance.Handle, IntPtr.Zero, out var errorPtr); GC.KeepAlive(instance); if (errorPtr != IntPtr.Zero) { var error = Opaque.GetInstance <Error> (errorPtr, Transfer.Full); throw new GErrorException(error); } return(ret); }
public void Execute(IInitable initable, IEnumerable <string> statements, Action <string> errorHandler) { var entry = initable as Entry; string name; if (entry.Variable.Value is Machine) { name = Machine.MachineKeyword; } else if (!machine.TryGetAnyName((IPeripheral)entry.Variable.Value, out name)) { errorHandler("The init section is only allowed for peripherals that are registered."); return; } foreach (var monitorCommand in statements.Select(x => string.Format("{0} {1}", name, x))) { monitor.Parse(monitorCommand); } }
void Awake () { menuBackgroundOverlayHidable = MenuBackgroundOverlayGameObject.GetComponent<IHidable>(); menuUiIconHidables = new IHidable[MenuUiIconGameObjects.Length]; for (int i = 0; i < menuUiIconHidables.Length; i++) { menuUiIconHidables[i] = MenuUiIconGameObjects[i].GetComponent<IHidable>(); } menuUiTitleHidables = new IHidable[MenuUiTitleGameObjects.Length]; for (int i = 0; i < menuUiTitleHidables.Length; i++) { menuUiTitleHidables[i] = MenuUiTitleGameObjects[i].GetComponent<IHidable>(); } menuUiPanelHidables = new IHidable[MenuUiPanelGameObjects.Length]; for (int i = 0; i < menuUiPanelHidables.Length; i++) { menuUiPanelHidables[i] = MenuUiPanelGameObjects[i].GetComponent<IHidable>(); } menuGameIconHidable = MenuGameIconGameObject.GetComponent<IHidable>(); menuBackIconHidable = MenuBackIconGameObject.GetComponent<IHidable>(); popupManager = PopupGameObject.GetComponent<IInitable<UiPopupInfo>>(); }
public bool Validate(IInitable initable, out string message) { message = null; return(true); }
public void Execute(IInitable initable, IEnumerable <string> statements, Action <string> errorHandler) { }
public InitableRunner(IInitable initable) { LogTo.Debug("InitableRunner created"); _initable = initable; }