//Methods /// <summary> /// Checks consistency /// </summary> protected override void Check() { if (TestDataRatio <= 0 || TestDataRatio > MaxTestDataRatio) { throw new ArgumentException($"Invalid TestDataRatio {TestDataRatio.ToString(CultureInfo.InvariantCulture)}. TestDataRatio must be GT 0 and GE {MaxTestDataRatio.ToString(CultureInfo.InvariantCulture)}.", "TestDataRatio"); } if (Folds < 0) { throw new ArgumentException($"Invalid Folds {Folds.ToString(CultureInfo.InvariantCulture)}. Folds must be GE to 0 (0 means Auto folds).", "Folds"); } if (Repetitions < 1) { throw new ArgumentException($"Invalid Repetitions {Repetitions.ToString(CultureInfo.InvariantCulture)}. Repetitions must be GE to 1.", "Repetitions"); } foreach (ReadoutUnitSettings rus in ReadoutUnitsCfg.ReadoutUnitCfgCollection) { if (rus.TaskCfg.NetworkCfgCollection.Count == 0) { if (DefaultNetworksCfg.GetTaskNetworksCfgs(rus.TaskCfg.Type).Count == 0) { throw new ArgumentException($"Readout unit {rus.Name} has not associated network(s) settings.", "ReadoutUnitsCfg"); } } } return; }
/// <summary> /// The name last action in sequence. /// </summary> /// <param name="actionSequence"> /// The action sequence. /// </param> /// <returns> /// The name last action in sequence. /// </returns> /// <exception cref="NotSupportedException"></exception> public static string NameLastActionInSequence(ActionSequences actionSequence) { if (Folds.Contains(actionSequence)) { return("Fold"); } if (Calls.Contains(actionSequence)) { return("Call"); } if (Raises.Contains(actionSequence)) { return("Raise"); } if (Bets.Contains(actionSequence)) { return("Bet"); } if (actionSequence == ActionSequences.HeroX) { return("Check"); } throw new NotSupportedException("Cannot name last action of " + actionSequence); }
/// <summary> /// The get last action in. /// </summary> /// <param name="actionSequence"> /// The action sequence. /// </param> /// <returns></returns> /// <exception cref="ArgumentException"></exception> public static ActionTypes GetLastActionIn(ActionSequences actionSequence) { if (Folds.Contains(actionSequence)) { return(ActionTypes.F); } if (Calls.Contains(actionSequence)) { return(ActionTypes.C); } if (Raises.Contains(actionSequence)) { return(ActionTypes.R); } if (Checks.Contains(actionSequence)) { return(ActionTypes.X); } if (Bets.Contains(actionSequence)) { return(ActionTypes.B); } throw new ArgumentException(actionSequence + " has no last Action"); }
public static void Add(this Folds folds, int order, string name, bool enableFirst, params Type[] iDebugMenuTypes) { Assert.IsTrue(iDebugMenuTypes.All(type => type.GetInterfaces().Contains(typeof(IDebugMenu)))); var iDebugMenus = iDebugMenuTypes.Select(t => new LazyFindObject(t)).ToList() // exec once. .Select(lfo => lfo.GetObject()).Where(o => o != null).Cast <IDebugMenu>(); // exec every call. folds.Add(order, name, () => iDebugMenus.Any(), () => iDebugMenus.ToList().ForEach(idm => idm.DebugMenu()), enableFirst); }
//Methods /// <inheritdoc/> protected override void Check() { if (FoldDataRatio <= 0 || FoldDataRatio > MaxFoldDataRatio) { throw new ArgumentException($"Invalid FoldDataRatio {FoldDataRatio.ToString(CultureInfo.InvariantCulture)}. TestDataRatio must be GT 0 and GE {MaxFoldDataRatio.ToString(CultureInfo.InvariantCulture)}.", "FoldDataRatio"); } if (Folds < 0) { throw new ArgumentException($"Invalid Folds {Folds.ToString(CultureInfo.InvariantCulture)}. Folds must be GE to 0 (0 means Auto folds).", "Folds"); } if (Repetitions < 1) { throw new ArgumentException($"Invalid Repetitions {Repetitions.ToString(CultureInfo.InvariantCulture)}. Repetitions must be GE to 1.", "Repetitions"); } return; }
void InitFolds() { folds = new Folds(); // Add() returns Fold. so you can method chains. folds.Add("Simple Add()", () => GUILayout.Label("This is Folds.")) .SetTitleAction(() => GUILayout.Label("Title Action")) .Open(); // if name used already, it will margined. folds.Add("Simple Add()", () => GUILayout.Label("added by same name")); folds.Add("With checkEnableFunc.", () => isEnable, () => GUILayout.Label("Displayed only when checkEnableFunc return true.") ); folds.Add("finds the type of IDoGUI in the scene.", typeof(FieldExample_Part1)); }
public static void Add(this Folds folds, int order, string name, params Type[] iDebugMenuTypes) { folds.Add(order, name, false, iDebugMenuTypes); }
public static void Add(this Folds folds, string name, bool enableFirst, params Type[] iDebugMenuTypes) { folds.Add(0, name, enableFirst, iDebugMenuTypes); }
/// <inheritdoc/> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName); if (!suppressDefaults || !IsDefaultFoldDataRatio) { rootElem.Add(new XAttribute("foldDataRatio", FoldDataRatio.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultFolds) { rootElem.Add(new XAttribute("folds", Folds == DefaultFoldsNum ? DefaultFoldsString : Folds.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultRepetitions) { rootElem.Add(new XAttribute("repetitions", Repetitions.ToString(CultureInfo.InvariantCulture))); } Validate(rootElem, XsdTypeName); return(rootElem); }
public static Fold Add(this Folds folds, string name, params Type[] iDebugMenuTypes) { return(folds.Add(name, false, iDebugMenuTypes)); }
public void UnfoldOnce() { Unfold(); Folds.RemoveAt(0); }
/// <summary> /// Generates xml element containing the settings. /// </summary> /// <param name="rootElemName">Name to be used as a name of the root element.</param> /// <param name="suppressDefaults">Specifies whether to ommit optional nodes having set default values</param> /// <returns>XElement containing the settings</returns> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName); rootElem.Add(new XAttribute("testDataRatio", TestDataRatio.ToString(CultureInfo.InvariantCulture))); if (!suppressDefaults || !IsDefaultFolds) { rootElem.Add(new XAttribute("folds", Folds == DefaultFoldsNum ? DefaultFoldsString : Folds.ToString(CultureInfo.InvariantCulture))); } if (!suppressDefaults || !IsDefaultRepetitions) { rootElem.Add(new XAttribute("repetitions", Repetitions.ToString(CultureInfo.InvariantCulture))); } if (!DefaultNetworksCfg.ContainsOnlyDefaults) { rootElem.Add(DefaultNetworksCfg.GetXml(suppressDefaults)); } rootElem.Add(ReadoutUnitsCfg.GetXml(suppressDefaults)); Validate(rootElem, XsdTypeName); return(rootElem); }