/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Calories != null) { hashCode = hashCode * 59 + Calories.GetHashCode(); } if (DailyValues != null) { hashCode = hashCode * 59 + DailyValues.GetHashCode(); } if (Fat != null) { hashCode = hashCode * 59 + Fat.GetHashCode(); } if (Carbs != null) { hashCode = hashCode * 59 + Carbs.GetHashCode(); } if (Vitamins != null) { hashCode = hashCode * 59 + Vitamins.GetHashCode(); } return(hashCode); } }
public static List <Directory> Parse(FloppyHeader floppyHeader, byte[] floppyData) { var directories = new List <Directory>(); var sectorsToParse = floppyHeader.DirectoryEntries * 32 / floppyHeader.BytesPerSector; var initialOffset = (ushort)(floppyHeader.BytesPerSector + 2 * floppyHeader.BytesPerSector * floppyHeader.SectorsPerFat); var offset = initialOffset; for (var sector = 0; sector < sectorsToParse; sector++) { var data = floppyData.Skip(offset).Take(512).ToArray(); var fat = new Fat(); var size = Marshal.SizeOf(fat); var ptr = Marshal.AllocHGlobal(size); Marshal.Copy(data, 0, ptr, size); fat = (Fat)Marshal.PtrToStructure(ptr, fat.GetType()); Marshal.FreeHGlobal(ptr); directories.AddRange(fat.Directories); offset += floppyHeader.BytesPerSector; } return(directories); }
public void Can_Deserialize_Fat() { string content = File.ReadAllText(SampleData.PathFor("Fat.txt")); var deserializer = new RestSharp.Deserializers.XmlDeserializer(); deserializer.RootElement = "fat"; Fat result = deserializer.Deserialize <Fat>(new RestResponse() { Content = content }); Assert.IsNotNull(result); Assert.IsTrue(result.FatLogs.Count == 2); FatLog log = result.FatLogs[0]; Assert.AreEqual(log.LogId, 1330991999000); Assert.AreEqual(log.Date, new DateTime(2012, 3, 5)); Assert.AreEqual(log.Time, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59)); Assert.AreEqual(log.Fat, 14); Assert.AreEqual(log.DateTime, new DateTime(2012, 3, 5, 23, 59, 59)); log = result.FatLogs[1]; Assert.AreEqual(log.LogId, 1330991999000); Assert.AreEqual(log.Date, new DateTime(2012, 3, 5)); Assert.AreEqual(log.Time, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 21, 20, 59)); Assert.AreEqual(log.Fat, 13.5); Assert.AreEqual(log.DateTime, new DateTime(2012, 3, 5, 21, 20, 59)); }
public bool BeginIteration(int initialBlock) { PhysicalBlock = initialBlock; Fat.ReadEntry(initialBlock, out _nextBlock, out _prevBlock, out _currentSegmentSize); return(_prevBlock == -1); }
private void ValidateFat(Fat fat) { Assert.IsNotNull(fat); Assert.AreEqual(2, fat.FatLogs.Count); var log = fat.FatLogs.First(); Assert.IsNotNull(log); Assert.AreEqual(new DateTime(2012, 3, 5), log.Date); Assert.AreEqual(1330991999000, log.LogId); Assert.AreEqual(14, log.Fat); Assert.AreEqual(new DateTime(2012, 3, 5, 23, 59, 59).TimeOfDay, log.Time.TimeOfDay); fat.FatLogs.Remove(log); log = fat.FatLogs.First(); Assert.IsNotNull(log); Assert.AreEqual(new DateTime(2012, 3, 5), log.Date); Assert.AreEqual(1330991999000, log.LogId); Assert.AreEqual(13.5, log.Fat); Assert.AreEqual(new DateTime(2012, 3, 5, 21, 20, 59).TimeOfDay, log.Time.TimeOfDay); }
public override string ToString() { return ($"\nProteins {Proteins.ToString("0.##")} g = {(Proteins * 4).ToString("0.##")} Kcal" + $"\nFat {Fat.ToString("0.##")} g = {(Fat * 9).ToString("0.##")} Kcal" + $"\nCarbs {Carbs.ToString("0.##")} g = {(Carbs * 4).ToString("0.##")} Kcal" + $"\nTotalgram {TotalGrams.ToString("0.##")} g = {Kcal.ToString("0.##")} Kcal"); }
public async Task GetFatAsync_OneWeek_Success() { FitbitClient fitbitClient = SetupFitbitClient("https://api.fitbit.com/1/user/-/body/log/fat/date/2012-03-05/1w.json"); Fat response = await fitbitClient.GetFatAsync(new DateTime(2012, 3, 5), DateRangePeriod.OneWeek); ValidateFat(response); }
public async Task GetFatAsync_TimeSpan_Success() { FitbitClient fitbitClient = SetupFitbitClient("https://api.fitbit.com/1/user/-/body/log/fat/date/2012-03-05/2012-03-06.json"); Fat response = await fitbitClient.GetFatAsync(new DateTime(2012, 3, 5), new DateTime(2012, 3, 6)); ValidateFat(response); }
public void Can_Deserialize_Fat() { string content = SampleDataHelper.GetContent("GetFat.json"); var deserializer = new JsonDotNetSerializer(); Fat fat = deserializer.GetFat(content); ValidateFat(fat); }
public string ToInsert() { var kcal = Kcal.ToString().Replace(',', '.'); var protein = Protein.ToString().Replace(',', '.'); var fat = Fat.ToString().Replace(',', '.'); var carbs = Carbs.ToString().Replace(',', '.'); return($"('{ID}', '{Name}', '{kcal}', '{protein}', '{fat}', '{carbs}', '{Type}')"); }
private void LoadWeekFat() { var fat = MainWindow.UserNutritionRepository.GetSumsOfFat(MainWindow.UserId, 7); foreach (var i in fat) { Fat.Add(new GraphicPoint() { Date = i.Key.ToShortDateString(), Number = i.Value }); } }
public override int GetHashCode() { var hashCode = -9536604; hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Name); hashCode = hashCode * -1521134295 + Protein.GetHashCode(); hashCode = hashCode * -1521134295 + Carbohydrate.GetHashCode(); hashCode = hashCode * -1521134295 + Fat.GetHashCode(); hashCode = hashCode * -1521134295 + Calorific.GetHashCode(); return(hashCode); }
/// <summary> /// GetFat has to doe some custom manipulation with the returned representation /// </summary> /// <param name="serializer"></param> /// <param name="fatJson"></param> /// <returns></returns> internal static Fat GetFat(this JsonDotNetSerializer serializer, string fatJson) { if (string.IsNullOrWhiteSpace(fatJson)) { throw new ArgumentNullException(nameof(fatJson), "fatJson can not be empty, null or whitespace"); } var fatlogs = JToken.Parse(fatJson)["fat"]; var fat = new Fat(); fat.FatLogs = fatlogs.Children().Select(serializer.Deserialize <FatLog>).ToList(); return(fat); }
public bool MoveNext() { if (_nextBlock == -1) { return(false); } VirtualBlock += _currentSegmentSize; PhysicalBlock = _nextBlock; Fat.ReadEntry(_nextBlock, out _nextBlock, out _prevBlock, out _currentSegmentSize); return(true); }
//example using the direct API call getting all the individual logs public ActionResult MonthFat(string id) { DateTime dateStart = Convert.ToDateTime(id); FitbitClient client = GetFitbitClient(); Fat fat = client.GetFat(dateStart, DateRangePeriod.OneMonth); if (fat == null || fat.FatLogs == null) //succeeded but no records { fat = new Fat(); fat.FatLogs = new List <FatLog>(); } return(View(fat)); }
public bool MovePrevious() { if (_prevBlock == -1) { return(false); } PhysicalBlock = _prevBlock; Fat.ReadEntry(_prevBlock, out _nextBlock, out _prevBlock, out _currentSegmentSize); VirtualBlock -= _currentSegmentSize; return(true); }
private void AddRow() { var PillID = Int32.Parse(textBox1.Text); var store = comboBox1.Text; var dept = (from de in context.Pills where de.ID == PillID && de.Store == store select de).FirstOrDefault(); if (dept != null) { var emp = new Item() { ID = 0, ItemName = "", Unit = "", Price = 0, Qty = 0, Total = "", Discount = 0, Net = 0, PillID = PillID, }; context.items.Add(emp); context.SaveChanges(); MessageBox.Show("Added Successfully "); BindGrid(int.Parse(textBox1.Text), comboBox1.Text); } else { var pill = new Fat() { ID = PillID, Store = store, Date = dateTimePicker1.Value, }; context.Pills.Add(pill); context.SaveChanges(); MessageBox.Show("Pill Created successfully"); BindGrid(int.Parse(textBox1.Text), comboBox1.Text); } }
public void Retrieve_Fat_Last_Week() { DateTime startDate = DateTime.Now.AddDays(-7); DateTime endDate = DateTime.Now; Fat fat = client.GetFat(startDate, endDate); Assert.IsNotNull(fat); Assert.IsNotNull(fat.FatLogs); Assert.IsTrue(fat.FatLogs.Count > 0); FatLog firstFat = fat.FatLogs[0]; Assert.GreaterOrEqual(firstFat.DateTime, startDate.Date); Assert.Less(firstFat.DateTime, endDate.AddDays(1).Date); Assert.IsTrue(firstFat.LogId > 0); Assert.IsTrue(firstFat.Fat > 0); }
/// <summary> /// Returns true if RecipeObjectNutrients instances are equal /// </summary> /// <param name="other">Instance of RecipeObjectNutrients to be compared</param> /// <returns>Boolean</returns> public bool Equals(RecipeObjectNutrients other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Calories == other.Calories || Calories != null && Calories.SequenceEqual(other.Calories) ) && ( DailyValues == other.DailyValues || DailyValues != null && DailyValues.SequenceEqual(other.DailyValues) ) && ( Fat == other.Fat || Fat != null && Fat.SequenceEqual(other.Fat) ) && ( Carbs == other.Carbs || Carbs != null && Carbs.SequenceEqual(other.Carbs) ) && ( Vitamins == other.Vitamins || Vitamins != null && Vitamins.SequenceEqual(other.Vitamins) )); }
bool FinishCanExecute() { if (String.IsNullOrEmpty(Name)) { return(false); } if (BulkQuantity == 0) { return(false); } if (StartingAmountIsChecked) { if (StartingAmount.GetValueOrDefault() == 0) { return(false); } } if (NutritionIsChecked) { if (Calories.GetValueOrDefault() == 0) { return(false); } if (ComplexNutritionIsChecked) { if ((Protein.GetValueOrDefault() == 0) || (Fat.GetValueOrDefault() == 0) || (Carbohydrates.GetValueOrDefault() == 0)) { return(false); } } } return(true); }
/// <summary> /// Formats the media with the file system. /// </summary> /// <param name="settings">The settings for the file system to create.</param> /// <returns>The created and mounted file system.</returns> public bool Format(GenericFileSystemSettings settings) { return(Fat.Format(((FatSettings)settings))); }
/// <summary> /// Initializes a new instance of the <see cref="FatFileSystem"/> class. /// </summary> /// <param name="aDevice">The partition.</param> /// <param name="aRootPath">The root path.</param> /// <exception cref="Exception">FAT signature not found.</exception> public FatFileSystem(Partition aDevice, string aRootPath, long aSize) : base(aDevice, aRootPath, aSize) { if (aDevice == null) { throw new ArgumentNullException(nameof(aDevice)); } if (String.IsNullOrEmpty(aRootPath)) { throw new ArgumentException("Argument is null or empty", nameof(aRootPath)); } var xBPB = Device.NewBlockArray(1); Device.ReadBlock(0UL, 1U, ref xBPB); ushort xSig = BitConverter.ToUInt16(xBPB, 510); if (xSig != 0xAA55) { throw new Exception("FAT signature not found."); } BytesPerSector = BitConverter.ToUInt16(xBPB, 11); SectorsPerCluster = xBPB[13]; BytesPerCluster = BytesPerSector * SectorsPerCluster; ReservedSectorCount = BitConverter.ToUInt16(xBPB, 14); NumberOfFATs = xBPB[16]; RootEntryCount = BitConverter.ToUInt16(xBPB, 17); TotalSectorCount = BitConverter.ToUInt16(xBPB, 19); if (TotalSectorCount == 0) { TotalSectorCount = BitConverter.ToUInt32(xBPB, 32); } // FATSz FatSectorCount = BitConverter.ToUInt16(xBPB, 22); if (FatSectorCount == 0) { FatSectorCount = BitConverter.ToUInt32(xBPB, 36); } DataSectorCount = TotalSectorCount - (ReservedSectorCount + NumberOfFATs * FatSectorCount + ReservedSectorCount); // Computation rounds down. ClusterCount = DataSectorCount / SectorsPerCluster; // Determine the FAT type. Do not use another method - this IS the official and // proper way to determine FAT type. // Comparisons are purposefully < and not <= // FAT16 starts at 4085, FAT32 starts at 65525 if (ClusterCount < 4085) { mFatType = FatTypeEnum.Fat12; } else if (ClusterCount < 65525) { mFatType = FatTypeEnum.Fat16; } else { mFatType = FatTypeEnum.Fat32; } if (mFatType == FatTypeEnum.Fat32) { RootCluster = BitConverter.ToUInt32(xBPB, 44); } else { RootSector = ReservedSectorCount + NumberOfFATs * FatSectorCount; RootSectorCount = (RootEntryCount * 32 + (BytesPerSector - 1)) / BytesPerSector; } DataSector = ReservedSectorCount + NumberOfFATs * FatSectorCount + RootSectorCount; mFats = new Fat[NumberOfFATs]; for (ulong i = 0; i < NumberOfFATs; i++) { mFats[i] = new Fat(this, (ReservedSectorCount + i * FatSectorCount)); } }
public void toneDiet() //Tone muscle diet specifications { vegAmt = Vegetables.high; proAmt = Protein.medium; fatAmt = Fat.low; }
/// <summary> /// Initializes a new instance of the <see cref="FatFileSystem"/> class. /// </summary> /// <param name="aDevice">The partition.</param> /// <param name="aRootPath">The root path.</param> /// <exception cref="Exception">FAT signature not found.</exception> public FatFileSystem(Partition aDevice, string aRootPath) : base(aDevice, aRootPath) { if (aDevice == null) { throw new ArgumentNullException(nameof(aDevice)); } if (string.IsNullOrEmpty(aRootPath)) { throw new ArgumentException("Argument is null or empty", nameof(aRootPath)); } var xBPB = mDevice.NewBlockArray(1); mDevice.ReadBlock(0UL, 1U, xBPB); ushort xSig = xBPB.ToUInt16(510); if (xSig != 0xAA55) { throw new Exception("FAT signature not found."); } BytesPerSector = xBPB.ToUInt16(11); SectorsPerCluster = xBPB[13]; BytesPerCluster = BytesPerSector * SectorsPerCluster; ReservedSectorCount = xBPB.ToUInt16(14); NumberOfFATs = xBPB[16]; RootEntryCount = xBPB.ToUInt16(17); TotalSectorCount = xBPB.ToUInt16(19); if (TotalSectorCount == 0) { TotalSectorCount = xBPB.ToUInt32(32); } // FATSz FatSectorCount = xBPB.ToUInt16(22); if (FatSectorCount == 0) { FatSectorCount = xBPB.ToUInt32(36); } DataSectorCount = TotalSectorCount - (ReservedSectorCount + NumberOfFATs * FatSectorCount + ReservedSectorCount); // Computation rounds down. ClusterCount = DataSectorCount / SectorsPerCluster; // Determine the FAT type. Do not use another method - this IS the official and // proper way to determine FAT type. // Comparisons are purposefully < and not <= // FAT16 starts at 4085, FAT32 starts at 65525 if (ClusterCount < 4085) { mFatType = FatTypeEnum.Fat12; } else if (ClusterCount < 65525) { mFatType = FatTypeEnum.Fat16; } else { mFatType = FatTypeEnum.Fat32; } if (mFatType == FatTypeEnum.Fat32) { RootCluster = xBPB.ToUInt32(44); } else { RootSector = ReservedSectorCount + NumberOfFATs * FatSectorCount; RootSectorCount = (RootEntryCount * 32 + (BytesPerSector - 1)) / BytesPerSector; } DataSector = ReservedSectorCount + NumberOfFATs * FatSectorCount + RootSectorCount; mFats = new Fat[NumberOfFATs]; for (ulong i = 0; i < NumberOfFATs; i++) { mFats[i] = new Fat(this, (ReservedSectorCount + i * FatSectorCount)); } }
public void bulkDiet() // Bulking diet specifications { vegAmt = Vegetables.medium; proAmt = Protein.high; fatAmt = Fat.high; }
public override string ToString() { string str = ""; str += "&idserver=\"" + IDServer.ToString() + "\""; if (IDUnit != -1) { str += "&idunit=\"" + IDUnit.ToString() + "\""; } if (IDServerMeal != -1) { str += "&idmeal=\"" + IDServerMeal.ToString() + "\""; } if (IDUser != 0) { str += "&iduser=\"" + IDUser.ToString() + "\""; } if (Calories != -1) { str += "&calories=\"" + Calories.ToString() + "\""; } if (Protein != -1) { str += "&protein=\"" + Protein.ToString() + "\""; } if (Carb != -1) { str += "&carb=\"" + Carb.ToString() + "\""; } if (Fat != -1) { str += "&fat=\"" + Fat.ToString() + "\""; } if (SatFat != -1) { str += "&satfat=\"" + SatFat.ToString() + "\""; } if (UnSatFat != -1) { str += "&unsatfat=\"" + UnSatFat.ToString() + "\""; } if (Cholesterol != -1) { str += "&cholesterol=\"" + Cholesterol.ToString() + "\""; } if (Sugar != -1) { str += "&sugar=\"" + Sugar.ToString() + "\""; } if (Natrium != -1) { str += "&natrium=\"" + Natrium.ToString() + "\""; } if (Potassium != -1) { str += "&potassium=\"" + Potassium.ToString() + "\""; } if (Fiber != -1) { str += "&fiber=\"" + Fiber.ToString() + "\""; } if (Deleted != -1) { str += "&deleted=\"" + Deleted.ToString() + "\""; } if (InsertDate != null) { str += "&insertdate=\"" + InsertDate.ToString("yyyy-MM-dd HH:mm:ss") + "\""; } if (UpdateDate != null) { str += "&updatedate=\"" + UpdateDate.ToString("yyyy-MM-dd HH:mm:ss") + "\""; } return(str.Substring(1)); }