static void Main(string[] args) { Utility u = new Utility(); Console.WriteLine(u.Add(10, 20)); Console.WriteLine(u.Add("Hi", "Weirdo")); }
private Segment AddSegment(string name, Segment parent) { Segment segment = new Segment(name, parent, Segments.Length); Utility.Add(ref Segments, segment); return(segment); }
private Segment AddSegment(string name, Segment parent) { Segment segment = new Segment(name, parent, Hierarchy.Length); Utility.Add(ref Hierarchy, segment); return(segment); }
/// <summary> /// Calculate solution date by service term and time zone. /// </summary> /// <param name="startDate">Start date.</param> /// <param name="timeZone">Time zone info.</param> /// <returns>Solution date.</returns> public DateTime CalculateSolutionDate(DateTime startDate, TimeZoneInfo timeZone) { var responseCalculationParams = TermParameters.SolutionParams; TimeTerm timeTerm = new TimeTerm { Type = responseCalculationParams.Key, Value = responseCalculationParams.Value, CalendarId = TermParameters.CalendarId }; return(Utility.Add(startDate, timeTerm, timeZone)); }
public Segment(string name, Segment parent, int index) { Name = name; Index = index; if (parent != null) { Parent = parent.Index; Utility.Add(ref parent.Childs, index); } Childs = new int[0]; Transformation = Matrix4x4.identity; }
AudioSource CreateAudioSource(AudioEventArgs arg) { GameObject go = new GameObject(arg.AudioEventObject.AudioName); go.transform.SetParent(ModuleMountObject.transform); go.transform.RestLocalTransform(); //AudioSource audio = go.AddComponent<AudioSource>(); AudioSource audio = Utility.Add <AudioSource>(go); SetAudioProperties(ref audio, arg); return(audio); }
public void Un_Ordered_ListMethod() { string path = @"C:\Users\Bridgelabz\Desktop\bridgelabz\programming\dotnet\DataStructures\Un-Ordered List\Un_Ordered.txt"; T[] array = new T[50]; ////store file text into array Utility.ReadFileIntoArray(path, array); Utility.PrintArray(array); Console.WriteLine(" "); ListNode <T> Head = null; ////convert the array to linked list Head = Utility.ArrayToLinkedList(Head, array); ////print linked list Utility.PrintLinkedList(Head); Console.WriteLine(" "); Console.WriteLine("enter the item to search"); ////take the user input to search into linkedlist. String item = Utility.ReadString(); ListNode <T> newnode = new ListNode <T>(); newnode.data = (T)((object)item); ////search the item in list bool found = Utility.SearchItem(Head, item); Console.WriteLine(found); if (!found) { Head = Utility.Add(Head, newnode); } else { int index = Utility.Index(Head, newnode); Console.WriteLine(" index is : " + index); ListNode <T> data = Utility.Pop(ref Head, index); Console.WriteLine("popped data is : {0} ", data.data); } Console.WriteLine(" list to store in file is : "); Utility.PrintLinkedList(Head); Utility.LinkedListToFile <T>(Head, path); }
/// 创建新的monoController MonoController CreateMonoController() { ++monoControllerCount; GameObject go = new GameObject("MonoController" + "_Num_" + monoControllerCount); go.transform.SetParent(ModuleMountObject.transform); //MonoController mc = go.AddComponent<MonoController>(); MonoController mc = Utility.Add <MonoController>(go); mc.MonoID = monoControllerCount; Register(monoControllerCount, mc); return(mc); }
public string Sign_Up() { try { var typeStr = new Utility().GetPostedValue("type"); var userName = new Utility().GetPostedValue("userName"); var password = new Utility().GetPostedValue("password"); var confirmPassword = new Utility().GetPostedValue("confirmPassword"); var id = new Utility().GetPostedValue("id"); if (!int.TryParse(typeStr, out int type)) // تبدیل استرینگ به اینت { //GetAttack(); return("خطا در پردازش اطلاعات"); } if (string.IsNullOrEmpty(userName)) { return("وارد کردن نام کاربری اجباری است"); } if (string.IsNullOrEmpty(password)) { return("وارد کردن گذرواژه اجباری است"); } if (string.IsNullOrEmpty(confirmPassword)) { return("وارد کردن مجدد گذرواژه اجباری است"); } var UserAddress = HttpContext.Current.Server.MapPath("~/Json/variable/User.json");//برای آدرس دادن جیسون var UserList = new Utility().ReadJsonFile <DefineUser>(UserAddress); DefineUser item = new DefineUser(); if (id != "") //edit { item = UserList.SingleOrDefault(c => c.Id == id); //linq } item.UserName = userName; item.Password = password; item.ConfirmPassword = confirmPassword; item.SubmitDateTime = DateTime.Now.ToString(); if (id == "") { item.Id = DateTime.Now.Ticks.ToString(); UserList.Add(item); } new Utility().WriteJsonFile(UserList, UserAddress); return(item.Id); } catch { return("خطا در برقراری ارتباط با سرور"); } }
/// <summary> /// Calculate solution date after pause. /// </summary> /// <param name="startDate">Start date.</param> /// <param name="timeUnit">Time unit.</param> /// <param name="value">Time unit value.</param> /// <param name="timeZone">Time zone.</param> /// <returns>Solution date.</returns> public DateTime CalculateSolutionDateAfterPause(DateTime startDate, Calendars.TimeUnit timeUnit, int value, TimeZoneInfo timeZone) { if (_userConnection == null) { throw new ArgumentException(); } startDate = _userConnection.CurrentUser.GetCurrentDateTime(); var parameters = GetTimeUnitDifference(new KeyValuePair <Calendars.TimeUnit, int>(timeUnit, value)); TimeTerm timeTerm = new TimeTerm { Type = parameters.Key, Value = parameters.Value, CalendarId = TermParameters.CalendarId }; return(Utility.Add(startDate, timeTerm, timeZone)); }
private Transform AddControlPoint() { Transform cp = GameObject.CreatePrimitive(PrimitiveType.Sphere).transform; cp.localScale = 0.05f * Vector3.one; cp.position = Vector3.zero; cp.rotation = Quaternion.identity; Utility.Destroy(cp.gameObject.GetComponent <MeshRenderer>()); Utility.Destroy(cp.gameObject.GetComponent <MeshFilter>()); cp.gameObject.GetComponent <Collider>().isTrigger = true; cp.name = "ControlPoint"; cp.gameObject.AddComponent <MouseDrag>(); cp.SetParent(transform); Utility.Add(ref ControlPoints, cp); //Create(); return(ControlPoints[ControlPoints.Length - 1]); }
public string Add_Group() { try { var typeStr = new Utility().GetPostedValue("type"); var titleStr = new Utility().GetPostedValue("title"); var descriptionStr = new Utility().GetPostedValue("description"); var id = new Utility().GetPostedValue("id"); if (!int.TryParse(typeStr, out int type)) // تبدیل استرینگ به اینت { //GetAttack(); return("خطا در پردازش اطلاعات"); } if (string.IsNullOrEmpty(titleStr)) { return("وارد کردن عنوان اجباری است"); } var GroupAddress = HttpContext.Current.Server.MapPath("~/Json/variable/ProductType.json");//برای آدرس دادن جیسون var GroupList = new Utility().ReadJsonFile <Group>(GroupAddress); Group item = new Group(); if (id != "") //edit { item = GroupList.SingleOrDefault(c => c.Id == id); //linq } item.Title = titleStr; item.Description = descriptionStr; item.SubmitDateTime = DateTime.Now.ToString(); if (id == "") { item.Id = DateTime.Now.Ticks.ToString(); GroupList.Add(item); } new Utility().WriteJsonFile(GroupList, GroupAddress); //if (ok) //{ // return "1"; //} return(item.Id); } catch { return("خطا در برقراری ارتباط با سرور"); } }
private void InspectHierarchy(Transform root, Transform transform, int indent) { Segment segment = FindSegment(transform.name); Utility.SetGUIColor(segment == null ? UltiDraw.White : UltiDraw.LightGrey); using (new EditorGUILayout.HorizontalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.BeginHorizontal(); for (int i = 0; i < indent; i++) { EditorGUILayout.LabelField("|", GUILayout.Width(20f)); } EditorGUILayout.LabelField("-", GUILayout.Width(20f)); EditorGUILayout.LabelField(transform.name, GUILayout.Width(100f), GUILayout.Height(20f)); GUILayout.FlexibleSpace(); if (Utility.GUIButton("Bone", segment == null ? UltiDraw.White : UltiDraw.DarkGrey, segment == null ? UltiDraw.DarkGrey : UltiDraw.White)) { if (segment == null) { string[] names = GetBoneNames(); Utility.Add(ref names, transform.name); BuildHierarchy(root, names); } else { string[] names = GetBoneNames(); Utility.Remove(ref names, transform.name); BuildHierarchy(root, names); } } EditorGUILayout.EndHorizontal(); } for (int i = 0; i < transform.childCount; i++) { InspectHierarchy(root, transform.GetChild(i), indent + 1); } }
public string Add_Book() { try { var typeStr = new Utility().GetPostedValue("type"); var Title = new Utility().GetPostedValue("name"); var writer = new Utility().GetPostedValue("writer"); var printyear = new Utility().GetPostedValue("printyear"); var published = new Utility().GetPostedValue("published"); var translator = new Utility().GetPostedValue("translator"); var publisher = new Utility().GetPostedValue("publisher"); var Category = new Utility().GetPostedValue("group"); var status = new Utility().GetPostedValue("status"); var erae = new Utility().GetPostedValue("noeEraeKetab"); var id = new Utility().GetPostedValue("id"); if (!int.TryParse(typeStr, out int type)) // تبدیل استرینگ به اینت { //GetAttack(); return("خطا در پردازش اطلاعات"); } if (string.IsNullOrEmpty(Title)) { return("وارد کردن نام کتاب اجباری است"); } if (Category == "0") { return("لطفا دسته بندی را انتخاب کنید"); } if (string.IsNullOrEmpty(writer)) { return("وارد کردن نام نویسنده اجباری است"); } if (string.IsNullOrEmpty(printyear)) { return("وارد کردن سال چاپ اجباری است"); } if (string.IsNullOrEmpty(published)) { return("وارد کردن نوبت چاپ اجباری است"); } if (string.IsNullOrEmpty(publisher)) { return("وارد کردن ناشر اجباری است"); } if (string.IsNullOrEmpty(publisher)) { return("وارد کردن ناشر اجباری است"); } if (string.IsNullOrEmpty(erae)) { return("انتخاب نوع ارائه کتاب اجباری است"); } var BookAddress = HttpContext.Current.Server.MapPath("~/Json/variable/Book.json");//برای آدرس دادن جیسون var BookList = new Utility().ReadJsonFile <DefineBook>(BookAddress); DefineBook item = new DefineBook(); if (id != "") //edit { item = BookList.SingleOrDefault(c => c.Id == id); //linq } item.Name = Title; item.Writer = writer; item.Category = Category; item.publisher = publisher; item.published = published; item.erae = erae; item.status = status; item.Type = type; //item.trnaslator = translator; item.PrintYear = printyear; item.SubmitDateTime = DateTime.Now.ToString(); if (id == "") { item.Id = DateTime.Now.Ticks.ToString(); BookList.Add(item); } new Utility().WriteJsonFile(BookList, BookAddress); //if (ok) //{ // return "1"; //} return(item.Id); } catch (Exception err) { return(err.Message); } }
public void AddMultiplier() { Utility.Add(ref Multipliers, new Multiplier()); }
private IEnumerator Record() { Data = ScriptableObject.CreateInstance <BVHAnimation>(); Data.Character = Animation.Character; Data.FrameTime = FrameTime; Data.Trajectory = new Trajectory(0, Animation.Controller.Styles.Length); Data.PhaseFunction = new BVHAnimation.BVHPhaseFunction(Data); Data.MirroredPhaseFunction = new BVHAnimation.BVHPhaseFunction(Data); Data.StyleFunction = new BVHAnimation.BVHStyleFunction(Data); for (int i = 0; i < Animation.Controller.Styles.Length; i++) { Data.StyleFunction.AddStyle(Animation.Controller.Styles[i].Name); } //Data.StyleFunction.SetStyle(BVHAnimation.BVHStyleFunction.STYLE.Quadruped); int index = 0; while (Recording && Application.isPlaying) { yield return(new WaitForEndOfFrame()); //Frames BVHAnimation.BVHFrame frame = new BVHAnimation.BVHFrame(Data, Data.GetTotalFrames() + 1, Data.GetTotalFrames() * FrameTime); frame.Local = Data.Character.GetLocalTransformations(); frame.World = Data.Character.GetWorldTransformations(); Utility.Add(ref Data.Frames, frame); //Trajectory Trajectory.Point point = new Trajectory.Point(Data.Trajectory.Points.Length, Animation.Controller.Styles.Length); point.SetTransformation(Animation.GetTrajectory().Points[60].GetTransformation()); point.SetLeftsample(Animation.GetTrajectory().Points[60].GetLeftSample()); point.SetRightSample(Animation.GetTrajectory().Points[60].GetRightSample()); point.SetSlope(Animation.GetTrajectory().Points[60].GetSlope()); for (int i = 0; i < Animation.Controller.Styles.Length; i++) { point.Styles[i] = Animation.GetTrajectory().Points[60].Styles[i]; } Utility.Add(ref Data.Trajectory.Points, point); //Phase Function /* * Utility.Add(ref Data.PhaseFunction.Phase, Mathf.Repeat(Animation.GetPhase() / (2f*Mathf.PI), 1f)); * Utility.Add(ref Data.PhaseFunction.Keys, index == 0 ? true : Data.PhaseFunction.Phase[index-1] > Data.PhaseFunction.Phase[index]); * Utility.Add(ref Data.PhaseFunction.Cycle, 0f); * Utility.Add(ref Data.PhaseFunction.NormalisedCycle, 0f); * Utility.Add(ref Data.PhaseFunction.Velocities, 0f); * Utility.Add(ref Data.PhaseFunction.NormalisedVelocities, 0f); * Utility.Add(ref Data.PhaseFunction.Heights, 0f); */ Utility.Add(ref Data.PhaseFunction.Phase, 0f); Utility.Add(ref Data.PhaseFunction.Keys, false); Utility.Add(ref Data.PhaseFunction.Cycle, 0f); Utility.Add(ref Data.PhaseFunction.NormalisedCycle, 0f); Utility.Add(ref Data.PhaseFunction.Velocities, 0f); Utility.Add(ref Data.PhaseFunction.NormalisedVelocities, 0f); Utility.Add(ref Data.PhaseFunction.Heights, 0f); Utility.Add(ref Data.PhaseFunction.RootVelocities, 0f); Utility.Add(ref Data.PhaseFunction.NormalisedRootVelocities, 0f); //Mirrored Phase Function Utility.Add(ref Data.MirroredPhaseFunction.Phase, 0f); Utility.Add(ref Data.MirroredPhaseFunction.Keys, false); Utility.Add(ref Data.MirroredPhaseFunction.Cycle, 0f); Utility.Add(ref Data.MirroredPhaseFunction.NormalisedCycle, 0f); Utility.Add(ref Data.MirroredPhaseFunction.Velocities, 0f); Utility.Add(ref Data.MirroredPhaseFunction.NormalisedVelocities, 0f); Utility.Add(ref Data.MirroredPhaseFunction.Heights, 0f); Utility.Add(ref Data.MirroredPhaseFunction.RootVelocities, 0f); Utility.Add(ref Data.MirroredPhaseFunction.NormalisedRootVelocities, 0f); //Style Function bool styleUpdate = false; for (int i = 0; i < Animation.Controller.Styles.Length; i++) { Utility.Add(ref Data.StyleFunction.Styles[i].Flags, Animation.Controller.Styles[i].Query()); Utility.Add(ref Data.StyleFunction.Styles[i].Values, Animation.GetTrajectory().Points[60].Styles[i]); if (index == 0) { styleUpdate = true; } else { if (Data.StyleFunction.Styles[i].Flags[index - 1] != Data.StyleFunction.Styles[i].Flags[index]) { styleUpdate = true; } } } Utility.Add(ref Data.StyleFunction.Keys, styleUpdate); index += 1; } //Setup Data.TimeWindow = Data.GetTotalTime(); Data.Corrections = new Vector3[Animation.Character.Hierarchy.Length]; Data.DetectSymmetry(); //Postprocess Data.PhaseFunction.Keys[index - 1] = true; Data.StyleFunction.Keys[index - 1] = true; Data.PhaseFunction.Recompute(); Data.StyleFunction.Recompute(); //Finish Recording = false; }
static void Main(string[] args) { bool valid = false; do { Console.Clear(); double num1, num2; string operation; Operation op; Console.WriteLine("\t\t\t\t\t\tCALCULATOR"); Console.Write("Enter the first number: "); if (Double.TryParse(Console.ReadLine(), out num1)) { valid = true; Console.Write("Enter the second number: "); if (Double.TryParse(Console.ReadLine(), out num2)) { Console.Write("Enter an operation(A for addition, S for substraction, M for multiplication, D for division): "); operation = Console.ReadLine(); if (operation == "A" || operation == "a") { op = Operation.A; } else if (operation == "S" || operation == "s") { op = Operation.S; } else if (operation == "D" || operation == "d") { op = Operation.D; } else if (operation == "M" || operation == "m") { op = Operation.M; } else { Console.WriteLine("Please enter a valid operation."); valid = false; Console.ReadKey(); continue; } switch (op) { case Operation.A: Console.WriteLine(Utility.Add(num1, num2)); break; case Operation.D: Console.WriteLine(Utility.Division(num1, num2)); break; case Operation.M: Console.WriteLine(Utility.Multiplication(num1, num2)); break; case Operation.S: Console.WriteLine(Utility.Substraction(num1, num2)); break; default: break; } } else { Console.WriteLine("Please enter a valid number."); valid = false; Console.ReadKey(); continue; } } else { Console.WriteLine("Please enter a valid number."); Console.ReadKey(); continue; } } while (!valid); }
/* * public void StoreVector(string fn, int dim) { * Utility.Add(ref Vectors, LoadVector(fn, dim)); * } */ public void StoreMatrix(string fn, int rows, int cols) { Utility.Add(ref Matrices, LoadMatrix(fn, rows, cols)); }
protected override Size MeasureOverride(Size constraint) { return(Utility.GetSize(base.MeasureOverride(constraint), Utility.Add(BorderThickness, Padding), constraint)); }