/// <summary> /// Tries the select read only variable at random. /// </summary> /// <returns><c>true</c>, if select read only variable at random was tryed, <c>false</c> otherwise.</returns> /// <param name="returnType">Return type.</param> /// <param name="signatureOut">Signature out.</param> public static bool TrySelectReadOnlyVariableAtRandom( Type returnType, out VariableSignature signatureOut) { if (readOnlyVariableList == null) { throw new InvalidOperationException("readOnlyVariableList is null"); } List <VariableSignature> candidates = new List <VariableSignature> (); foreach (VariableSignature signature in readOnlyVariableList) { if (signature.VariableType == returnType) { candidates.Add(signature); } } foreach (VariableSignature signature in readWriteVariableList) { if (signature.VariableType == returnType) { candidates.Add(signature); } } if (candidates.Count == 0) { signatureOut = null; return(false); } int index = CommonHelperMethods.GetRandomPositiveInt0ToValue(candidates.Count - 1); signatureOut = candidates [index]; return(true); }
/// <summary> /// Adds a read write variable. /// </summary> /// <param name="signature">Signature.</param> public static void AddReadWriteVariable(EntVariableEnum variableId, Type variableType) { VariableSignature signature = new VariableSignature(variableId, variableType); readWriteVariableList.Add(signature); }