public string Display() { if (string.IsNullOrEmpty(Title) || string.IsNullOrEmpty(Description) || string.IsNullOrEmpty(CreatedBy) || CreationDateTime.Equals(null)) { DisplayUtility.ErrorMessageForNullOrEmpty(); } return("Title: " + Title + "\n\nDescription: " + Description + "\n\nCreated By: " + CreatedBy + "\n" + CreationDateTime); }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { EditorGUI.BeginProperty(position, label, prop); prop.intValue = EditorGUI.IntPopup(position, label, prop.intValue, DisplayUtility.GetDisplayNames(), DisplayUtility.GetDisplayIndices()); EditorGUI.EndProperty(); }
/// <summary> /// Adds the specified IComment object to the Comments List of type IComment (i.e. List<IComment> Comments). /// </summary> /// <param name="comment">An IComment type object.</param> public void AddComment(IComment comment) { if (comment is null) { DisplayUtility.ErrorMessageForNullOrEmpty(); return; } Comments?.Add(comment); }
/// <summary> /// This is my Main method. /// </summary> /// <param name="args"></param> static void Main(string[] args) { var calculator = new Calculator(); var menuRecall = true; while (menuRecall) { DisplayUtility.Menu(out menuRecall, calculator); } }
static void Main(string[] args) { var provider = new ServiceCollection() .AddSingleton <IPostService, PostService>() .BuildServiceProvider(); var service = provider.GetService <IPostService>(); var posts = service.GetAll(); foreach (var post in posts) { DisplayUtility.OutputPostDisplay(post.Display()); DisplayUtility.OutputPostDisplay(post.DisplayVotes()); DisplayUtility.OutputPostDisplay("Number of Comments: " + post.TotalComments.ToString()); foreach (var comment in post.Comments) { DisplayUtility.OutputCommentDisplay(comment.DisplayComment()); } } }
public System.Object NewInstanceOf(System.Type clazz) { System.Reflection.ConstructorInfo constructor = null; constructor = classPool.GetConstrutor(OdbClassUtil.GetFullName(clazz)); if (constructor == null) { // Checks if exist a default constructor - with no parameters constructor = clazz.GetConstructor(Type.EmptyTypes); //UPGRADE_ISSUE: Method 'java.lang.reflect.AccessibleObject.setAccessible' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangreflectAccessibleObject'" //c by cristi //constructor.setAccessible(true); if (constructor != null) { classPool.AddConstrutor(OdbClassUtil.GetFullName(clazz), constructor); } } if (constructor != null) { System.Object o = constructor.Invoke(new System.Object[0]); return(o); } if (clazz.IsValueType) { return(Activator.CreateInstance(clazz)); } else { // else take the constructer with the smaller number of parameters // and call it will null values // @TODO Put this info in cache ! if (OdbConfiguration.IsDebugEnabled(LogId)) { DLogger.Debug(clazz + " does not have default constructor! using a 'with parameter' constructor will null values"); } System.Reflection.ConstructorInfo[] constructors = clazz.GetConstructors(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly); if (clazz.IsInterface) { //@TODO This is not a good solution to manage interface return(null); } if (constructors.Length == 0) { throw new ODBRuntimeException(NeoDatisError.ClassWithoutConstructor.AddParameter(clazz.AssemblyQualifiedName)); } int numberOfParameters = 1000; int bestConstructorIndex = 0; for (int i = 0; i < constructors.Length; i++) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" if (constructors[i].GetParameters().Length < numberOfParameters) { bestConstructorIndex = i; } } constructor = constructors[bestConstructorIndex]; //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" System.Object[] nulls = new System.Object[constructor.GetParameters().Length]; for (int i = 0; i < nulls.Length; i++) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //m by cristi if (constructor.GetParameters()[i].ParameterType == System.Type.GetType("System.Int32")) { nulls[i] = 0; } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" if (constructor.GetParameters()[i].ParameterType == System.Type.GetType("System.Int64")) { nulls[i] = 0; } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" if (constructor.GetParameters()[i].ParameterType == System.Type.GetType("System.Int16")) { nulls[i] = System.Int16.Parse("0"); } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //main by cristi if (constructor.GetParameters()[i].ParameterType == System.Type.GetType("System.SByte")) { nulls[i] = System.SByte.Parse("0"); } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //m by cristi if (constructor.GetParameters()[i].ParameterType == System.Type.GetType("System.Single")) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" nulls[i] = System.Single.Parse("0"); } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.reflect.Constructor.getParameterTypes' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //m by cristi if (constructor.GetParameters()[i].ParameterType == System.Type.GetType("System.Double")) { //UPGRADE_TODO: The differences in the format of parameters for constructor 'java.lang.Double.Double' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" nulls[i] = System.Double.Parse("0"); } else { nulls[i] = null; } } } } } } } System.Object object_Renamed = null; //UPGRADE_ISSUE: Method 'java.lang.reflect.AccessibleObject.setAccessible' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangreflectAccessibleObject'" //c by cristi //constructor.setAccessible(true); try { object_Renamed = constructor.Invoke(nulls); } catch (System.Exception e2) { throw new ODBRuntimeException(NeoDatisError.NoNullableConstructor.AddParameter("[" + DisplayUtility.ObjectArrayToString(constructor.GetParameters()) + "]").AddParameter(clazz.AssemblyQualifiedName), e2); } return(object_Renamed); } }
public void ConvertStringToInt_UserMenuOptionsPassedAndIntValueReturned_ReturnsValid(string input, int expectedResult) { var actual = DisplayUtility.ConvertStringToInt(input); Assert.Equal(actual, expectedResult); }
public void CheckUserInput_UserOptionOneThroughFiveInputted_ReturnsValid(string input, List <string> inputOptions) { var actual = DisplayUtility.CompareUserInputToAcceptedOptionsList(input, inputOptions); Assert.True(actual); }