/// <summary> /// Unloads the additive scene matching name to 'scene'. /// </summary> /// <returns>Suscribe to AsyncOperation[n].completed event to know when it ends.</returns> /// <param name="scene">Scene to unload.</param> /// <param name="all">If set to <c>true</c> unloads all the scenes with the same name.</param> public static List <AsyncOperation> UnloadSceneAdditive(string scene, bool all) { List <AsyncOperation> list = new List <AsyncOperation> (); for (int i = additiveScenes.Count - 1; i >= 0; --i) { if (scene == additiveScenes [i].name) { if (!all) { Additive a = additiveScenes [i]; additiveScenes.Remove(a); list.Add(SceneManager.UnloadSceneAsync(a.scene)); return(list); } else { Additive a = additiveScenes [i]; additiveScenes.Remove(a); list.Add(SceneManager.UnloadSceneAsync(a.scene)); } } } return(list); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 19, Configuration.FieldSeparator), Id, SequenceNumberTestObservationMasterFile.HasValue ? SequenceNumberTestObservationMasterFile.Value.ToString(Consts.NumericFormat, culture) : null, DerivedSpecimen, ContainerDescription != null ? string.Join(Configuration.FieldRepeatSeparator, ContainerDescription.Select(x => x.ToDelimitedString())) : null, ContainerVolume != null ? string.Join(Configuration.FieldRepeatSeparator, ContainerVolume.Select(x => x.ToString(Consts.NumericFormat, culture))) : null, ContainerUnits != null ? string.Join(Configuration.FieldRepeatSeparator, ContainerUnits.Select(x => x.ToDelimitedString())) : null, Specimen?.ToDelimitedString(), Additive?.ToDelimitedString(), Preparation?.ToDelimitedString(), SpecialHandlingRequirements?.ToDelimitedString(), NormalCollectionVolume?.ToDelimitedString(), MinimumCollectionVolume?.ToDelimitedString(), SpecimenRequirements?.ToDelimitedString(), SpecimenPriorities != null ? string.Join(Configuration.FieldRepeatSeparator, SpecimenPriorities) : null, SpecimenRetentionTime?.ToDelimitedString(), SpecimenHandlingCode != null ? string.Join(Configuration.FieldRepeatSeparator, SpecimenHandlingCode.Select(x => x.ToDelimitedString())) : null, SpecimenPreference, PreferredSpecimenAttribtureSequenceId.HasValue ? PreferredSpecimenAttribtureSequenceId.Value.ToString(Consts.NumericFormat, culture) : null, TaxonomicClassificationCode != null ? string.Join(Configuration.FieldRepeatSeparator, TaxonomicClassificationCode.Select(x => x.ToDelimitedString())) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public void CreateCheckout(IEnumerable <int> ListIdComdiments, int bevId, string UserId) { Beverage bev = _UoW.BeverageDAO.FindById(bevId); List <Condiment> CondList = new List <Condiment>(); // Использую шаблон проектирования "Декоратор" AbstractBeverage tempCofee = new Coffee(bev); if (ListIdComdiments != null) { foreach (int i in ListIdComdiments) { Condiment con = _UoW.CondimentDAO.FindById(i); tempCofee = new Additive(tempCofee, con); } } int sumCost = tempCofee.Cost(); Checkout check = new Checkout(); check.Description = tempCofee.GetDescription(); check.AllCost = tempCofee.Cost(); check.IsActive = true; check.Id = _UoW.CheckoutDAO.GetNextId(); check.UserId = UserId; _UoW.CheckoutDAO.create(check); _UoW.Commit(); }
public void GetAdditives_ManyOrDuplicated_ReturnsManyOrDuplicativeAdditives() { //given var beverage = new Beverage { Id = 1, Group = AdditiveGroup.Coffe }; var additive4 = new Additive { Id = 4, Group = AdditiveGroup.Tea | AdditiveGroup.Coffe }; var additive3 = new Additive { Id = 3, Group = AdditiveGroup.Tea | AdditiveGroup.Coffe }; var barService = Mock.Of <IBarService>(s => s.GetAdditives(new[] { 4, 3, 4 }) == new[] { additive4, additive3, additive4 }); var bartender = new Bartender("Test Bot", barService); //when var result = bartender.GetAdditives(beverage, "4,3,4"); //then Assert.That(result, Is.Not.Null); Assert.That(result.Count, Is.EqualTo(3)); Assert.That(result[0], Is.EqualTo(additive4)); Assert.That(result[1], Is.EqualTo(additive3)); Assert.That(result[2], Is.EqualTo(additive4)); }
public override int GetHashCode() { int hashCode = 1713062080; hashCode = hashCode * -1521134295 + Additive.GetHashCode(); hashCode = hashCode * -1521134295 + Multiplicative.GetHashCode(); return(hashCode); }
public void Test_RemoveSameObject() { var prod = new Additive(); collection.Add(prod); collection.Remove(prod); Assert.AreEqual(0, collection.GetLength()); }
public void Test_AddSameObjectMultiply() { var product = new Additive(); collection.Add(product); collection.Add(product); Assert.True(collection.GetLength() == 1); }
/// <summary> /// Loads the scene additively. /// </summary> /// <param name="scene">Scene to load.</param> /// <param name="clearOnChangeScene">If set to <c>true</c> clear on change scene.</param> public static void LoadSceneAdditive(string scene, bool clearOnChangeScene) { SceneManager.LoadScene(scene, LoadSceneMode.Additive); Additive a = new Additive(scene, lastAdditive, clearOnChangeScene); additiveScenes.Add(a); }
public void Test_AddSameProductMultiply() { var prod1 = new Additive(); var prod2 = new Additive(); collection.Add(prod1); collection.Add(prod2); Assert.True(collection.GetLength() == 1, String.Format("Collection length: {0}.", collection.GetLength())); }
// Methods internal Animate(string prefix, string localname, string ns, SvgDocument doc) : base(prefix, localname, ns, doc) { this.values = new ArrayList(); this.keyTimes = new ArrayList(); this.realdur = 0f; this.Additive = Additive.replace; this.Accumulate = Accumulate.none; this.Speed = 10; }
/// <summary> /// Serialize to a JSON object /// </summary> public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } ((Fhir.R4.Models.BackboneElement) this).SerializeJson(writer, options, false); if (!string.IsNullOrEmpty(Description)) { writer.WriteString("description", (string)Description !); } if (_Description != null) { writer.WritePropertyName("_description"); _Description.SerializeJson(writer, options); } if (Procedure != null) { writer.WritePropertyName("procedure"); Procedure.SerializeJson(writer, options); } if (Additive != null) { writer.WritePropertyName("additive"); Additive.SerializeJson(writer, options); } if (!string.IsNullOrEmpty(TimeDateTime)) { writer.WriteString("timeDateTime", (string)TimeDateTime !); } if (_TimeDateTime != null) { writer.WritePropertyName("_timeDateTime"); _TimeDateTime.SerializeJson(writer, options); } if (TimePeriod != null) { writer.WritePropertyName("timePeriod"); TimePeriod.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }
public int SaveItem(Additive item) //сохраняет строчку { if (item.Id != 0) //если объект существует (id>0) значит обновляет объект { database.Update(item); return(item.Id); } else //если не существует (с id=0, значит добавляет в конец). для добавления в конец используется id=0. { return(database.Insert(item)); } }
public static T Sum <T, TSummator, TIndexable>( this Indexable <T, int, TIndexable> indexable, Additive <T, TSummator> initial) where TIndexable : struct, IIndexable <T, int> where TSummator : ISummator <T> { var result = initial; for (var i = 0; i < indexable.Count; i++) { result += indexable[i]; } return(result); }
public void Add(Additive in_Additive)//添加元素 { //扩充数组 Additive[] tem = additives; Total++; additives = new Additive[Total]; for (int i = 0; i < Total - 1; i++) { additives[i] = tem[i]; } //添加元素 additives[Total - 1] = in_Additive; }
private void SetNextColor() { foreach (var i in _filterComponent) { ref var blocks = ref _filterComponent.Get1(i); var newColor = Additive.GetRandomColor(_gameConfiguration, out ushort numberNewColor); blocks.CurrentBlock.Color = Additive.SetColor(_gameConfiguration, blocks.PreviewBlock.NumberColor); blocks.CurrentBlock.NumberColor = blocks.PreviewBlock.NumberColor; blocks.PreviewBlock.Color = newColor; blocks.PreviewBlock.NumberColor = numberNewColor; }
public ActionResult AdditiveDetails([Bind(Exclude = "Units")] Additive additive) { if (ModelState.IsValid) { var dto = CalorieCalc.UpdateAdditive(additive); if (dto.ReturnValue == 1) { TempData.Add("additive", additive); return(RedirectToAction("AdditiveConfirmation")); } } IEnumerable <IDandName> units = DbUtils.GetLookupItems("Units"); additive.Units = units; return(View(additive)); }
public static void SendAdditiveAddeddMail(string[] toAddress, string[] ccAddress, Additive additive, string name, string siteName, HttpServerUtilityBase server, string url) { string subject = "Halfpint - New Additive Added"; var sbBody = new StringBuilder("<p>" + name + " from " + siteName + " has added a new additive:</p>"); sbBody.Append("<table><tr><th>Name</th><th>" + additive.Name + "</th></tr>"); sbBody.Append("<tr><td>CHO %</td><td>" + additive.ChoKcal + "</td></tr>"); sbBody.Append("<tr><td>Lipid %</td><td>" + additive.LipidKcal + "</td></tr>"); sbBody.Append("<tr><td>Protein %</td><td>" + additive.ProteinKcal + "</td></tr>"); sbBody.Append("<tr><td>Unit</td><td>" + additive.UnitName + "</td></tr>"); sbBody.Append("<tr><td>kCal/unit </td><td>" + additive.Kcal_unit + "</td></tr>"); sbBody.Append("</table>"); string siteUrl = "Website: <a href='" + url + "'>HalfpintStudy.org</a>"; SendHtmlEmail(subject, toAddress, ccAddress, sbBody.ToString(), server, siteUrl); }
public void GetAdditives_AdditivesStringIsNotValid_Throws(string value) { //given var beverage = new Beverage { Id = 1, Group = AdditiveGroup.Coffe }; var additive = new Additive { Id = 1, Group = AdditiveGroup.Tea | AdditiveGroup.Coffe }; var barService = Mock.Of <IBarService>(s => s.GetAdditives(new[] { 1 }) == new[] { additive }); var bartender = new Bartender("Test Bot", barService); //when //then var ex = Assert.Throws <InvalidOperationException>(() => bartender.GetAdditives(beverage, $"1, {value},2")); Assert.That(ex.Message, Is.EqualTo($"Failed to parse string '{value}', integer value expected\n")); }
public void GetAdditives_BeverageIsCompatible_ReturnsAdditive() { //given var beverage = new Beverage { Id = 1, Group = AdditiveGroup.Coffe }; var additive = new Additive { Id = 1, Group = AdditiveGroup.Tea | AdditiveGroup.Coffe }; var barService = Mock.Of <IBarService>(s => s.GetAdditives(new[] { 1 }) == new[] { additive }); var bartender = new Bartender("Test Bot", barService); //when var result = bartender.GetAdditives(beverage, "1"); //then Assert.That(result, Is.Not.Null); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result[0], Is.EqualTo(additive)); }
public JsonResult AddNewAdditive([Bind(Exclude = "ID")] Additive add) { if (ModelState.IsValid) { DTO dto = new DTO(); if (CalorieCalc.IsAdditiveNameDuplicate(add.Name) == 1) { dto.ReturnValue = 0; dto.Message = add.Name + " is already in the list!"; } else { dto = CalorieCalc.AddAdditive(add); var siteId = DbUtils.GetSiteidIdForUser(User.Identity.Name); var staff = NotificationUtils.GetStaffForEvent(5, siteId); string siteName = DbUtils.GetSiteNameForUser(User.Identity.Name); var u = new UrlHelper(this.Request.RequestContext); string url = "http://" + this.Request.Url.Host + u.RouteUrl("Default", new { Controller = "Account", Action = "Logon" }); Utility.SendAdditiveAddeddMail(staff.ToArray(), null, add, User.Identity.Name, siteName, Server, url); } if (dto.ReturnValue == -1) { dto.Message = "There was an error adding this additive. It has been reported to the web master!"; } dto.Bag = add; return(Json(dto)); } else { return(null); } }
public void GetAdditives_BeverageIsNotCompatible_Throws() { //given var beverage = new Beverage { Id = 1, Name = "Test Name", Group = AdditiveGroup.Coffe }; var additive4 = new Additive { Id = 4, Group = AdditiveGroup.Tea | AdditiveGroup.Coffe }; var additive3 = new Additive { Id = 3, Group = AdditiveGroup.Tea }; var barService = Mock.Of <IBarService>(s => s.GetAdditives(new[] { 4, 3, 4 }) == new[] { additive4, additive3, additive4 }); var bartender = new Bartender("Test Bot", barService); //when //then var ex = Assert.Throws <InvalidOperationException>(() => bartender.GetAdditives(beverage, "4,3,4")); Assert.That(ex.Message, Is.EqualTo($"Some of the additives is not be compatible with Test Name\n")); }
void IEcsInitSystem.Init() { var entity = _world.NewEntity(); var color1 = Additive.GetRandomColor(_gameConfiguration, out ushort numberColor1); var color2 = Additive.GetRandomColor(_gameConfiguration, out ushort numberColor2); entity.Get <MainBlockComponent>().CurrentBlock = new Blockube(_sceneData.CurrentBlock, color1, numberColor1); entity.Get <MainBlockComponent>().PreviewBlock = new Blockube(_sceneData.PreviewBlock, color2, numberColor2); entity.Get <RotateComponent>().CurrentBlockRotate = new Blockube(_sceneData.CurrentBlockRotate, color1, numberColor1); entity.Get <RotateComponent>().PreviewBlockRotate = new Blockube(_sceneData.PreviewBlockRotate, color2, numberColor2); entity.Get <RotateComponent>().MainPlace = _sceneData.MainBlocksPlace; entity.Get <RotateComponent>().RotationPlace = _sceneData.RotatePlace; //entity.Get<ColorChargeComponent>().Current = _sceneData.CurrentBlock.transform.position; //entity.Get<ColorChargeComponent>().Preview = _sceneData.PreviewBlock.transform.position; entity.Get <MoveComponent>(); entity.Get <IsCanFallComponent>(); entity.Get <TimerFallingSetupComponent>().FallTimeSec = _gameConfiguration.DelayFall; entity.Get <TimerFallingSetupComponent>().FallUnit = _gameConfiguration.SpeedFall; entity.Get <TimerMergingSetupComponent>().MergeTimeSec = _gameConfiguration.DelayMerge; entity.Get <TimerRemoveLineSetupComponent>().RemoveTimeSec = _gameConfiguration.DelayMerge * 2; }
public static Additive <int, IntSummator> AsAdditive(this int value) => Additive <int, IntSummator> .Wrap(value);
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 45, Configuration.FieldSeparator), Id, ExternalAccessionIdentifier?.ToDelimitedString(), AccessionIdentifier?.ToDelimitedString(), ContainerIdentifier?.ToDelimitedString(), PrimaryParentContainerIdentifier?.ToDelimitedString(), EquipmentContainerIdentifier?.ToDelimitedString(), SpecimenSource?.ToDelimitedString(), RegistrationDateTime.HasValue ? RegistrationDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, ContainerStatus?.ToDelimitedString(), CarrierType?.ToDelimitedString(), CarrierIdentifier?.ToDelimitedString(), PositionInCarrier?.ToDelimitedString(), TrayTypeSac?.ToDelimitedString(), TrayIdentifier?.ToDelimitedString(), PositionInTray?.ToDelimitedString(), Location != null ? string.Join(Configuration.FieldRepeatSeparator, Location.Select(x => x.ToDelimitedString())) : null, ContainerHeight.HasValue ? ContainerHeight.Value.ToString(Consts.NumericFormat, culture) : null, ContainerDiameter.HasValue ? ContainerDiameter.Value.ToString(Consts.NumericFormat, culture) : null, BarrierDelta.HasValue ? BarrierDelta.Value.ToString(Consts.NumericFormat, culture) : null, BottomDelta.HasValue ? BottomDelta.Value.ToString(Consts.NumericFormat, culture) : null, ContainerHeightDiameterDeltaUnits?.ToDelimitedString(), ContainerVolume.HasValue ? ContainerVolume.Value.ToString(Consts.NumericFormat, culture) : null, AvailableSpecimenVolume.HasValue ? AvailableSpecimenVolume.Value.ToString(Consts.NumericFormat, culture) : null, InitialSpecimenVolume.HasValue ? InitialSpecimenVolume.Value.ToString(Consts.NumericFormat, culture) : null, VolumeUnits?.ToDelimitedString(), SeparatorType?.ToDelimitedString(), CapType?.ToDelimitedString(), Additive != null ? string.Join(Configuration.FieldRepeatSeparator, Additive.Select(x => x.ToDelimitedString())) : null, SpecimenComponent?.ToDelimitedString(), DilutionFactor?.ToDelimitedString(), Treatment?.ToDelimitedString(), Temperature?.ToDelimitedString(), HemolysisIndex.HasValue ? HemolysisIndex.Value.ToString(Consts.NumericFormat, culture) : null, HemolysisIndexUnits?.ToDelimitedString(), LipemiaIndex.HasValue ? LipemiaIndex.Value.ToString(Consts.NumericFormat, culture) : null, LipemiaIndexUnits?.ToDelimitedString(), IcterusIndex.HasValue ? IcterusIndex.Value.ToString(Consts.NumericFormat, culture) : null, IcterusIndexUnits?.ToDelimitedString(), FibrinIndex.HasValue ? FibrinIndex.Value.ToString(Consts.NumericFormat, culture) : null, FibrinIndexUnits?.ToDelimitedString(), SystemInducedContaminants != null ? string.Join(Configuration.FieldRepeatSeparator, SystemInducedContaminants.Select(x => x.ToDelimitedString())) : null, DrugInterference != null ? string.Join(Configuration.FieldRepeatSeparator, DrugInterference.Select(x => x.ToDelimitedString())) : null, ArtificialBlood?.ToDelimitedString(), SpecialHandlingCode != null ? string.Join(Configuration.FieldRepeatSeparator, SpecialHandlingCode.Select(x => x.ToDelimitedString())) : null, OtherEnvironmentalFactors != null ? string.Join(Configuration.FieldRepeatSeparator, OtherEnvironmentalFactors.Select(x => x.ToDelimitedString())) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
DEFINE_STANDARD_OP(Additive, SATURATE)
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IGH_Goo goo = null; Image image = new Image(); if (!DA.GetData(0, ref goo)) { return; } if (!goo.TryGetImage(ref image)) { return; } int mode = 0; DA.GetData(1, ref mode); double numValA = 0; DA.GetData(2, ref numValA); double numValB = 0; DA.GetData(3, ref numValB); Filter filter = new Filter(); switch ((FilterModes)mode) { case FilterModes.Additive: SetParameter(2); SetParameter(3); filter = new Additive(); image.Filters.Add(new Additive()); break; case FilterModes.Daube: SetParameter(2, "S", "Size", "[0-1] Unitized adjustment value"); SetParameter(3); filter = new Daube(numValA); image.Filters.Add(new Daube(numValA)); break; case FilterModes.SaltPepper: SetParameter(2, "N", "Noise", "[0-1] Unitized adjustment value"); SetParameter(3); filter = new SaltPepper(numValA); image.Filters.Add(new SaltPepper(numValA)); break; case FilterModes.Jitter: SetParameter(2, "R", "Radius", "[0-1] Unitized adjustment value"); SetParameter(3); filter = new Jitter(numValA); image.Filters.Add(new Jitter(numValA)); break; case FilterModes.Kuwahara: SetParameter(2, "S", "Size", "[0-1] Unitized adjustment value"); SetParameter(3); filter = new Kuwahara(numValA); image.Filters.Add(new Kuwahara(numValA)); break; case FilterModes.Posterize: SetParameter(2, "I", "Interval", "[0-1] Unitized adjustment value"); SetParameter(3); filter = new Posterize(numValA); image.Filters.Add(new Posterize(numValA)); break; case FilterModes.GaussianBlur: SetParameter(2, "X", "Sigma", "[0-1] Unitized adjustment value"); SetParameter(3, "S", "Size", "[0-1] Unitized adjustment value"); filter = new GaussianBlur(numValA, numValB); image.Filters.Add(new GaussianBlur(numValA, numValB)); break; case FilterModes.Pixellate: SetParameter(2, "W", "Width", "[0-1] Unitized adjustment value"); SetParameter(3, "H", "Height", "[0-1] Unitized adjustment value"); filter = new Pixellate(numValA, numValB); image.Filters.Add(new Pixellate(numValA, numValB)); break; case FilterModes.Blur: SetParameter(2, "D", "Divisor", "[0-1] Unitized adjustment value"); SetParameter(3, "T", "Threshold", "[0-1] Unitized adjustment value"); filter = new Blur(numValA, numValB); image.Filters.Add(new Blur(numValA, numValB)); break; } message = ((FilterModes)mode).ToString(); UpdateMessage(); DA.SetData(0, image); DA.SetData(1, filter); }
public Bread(Flour flour, Salt salt, Additive additives) { Flour = flour; Salt = salt; Additives = additives; }