public void ToStreamTest() { StringConverter target = new StringConverter(); Assert.AreEqual<string>("313233343500", target.ToStream("12345")); Assert.AreEqual<string>("5835444A3700", target.ToStream("X5DJ7")); Assert.AreEqual<string>("504736535130", target.ToStream("PG6SQ0")); }
public void ShouldConvertToCSharpValue() { //Arrange var converter = new StringConverter(); object value0; object value1; object value2; object value3; //Act bool success0 = converter.TryConvertToCSharpValue("0", out value0); bool success1 = converter.TryConvertToCSharpValue("1", out value1); bool success2 = converter.TryConvertToCSharpValue(null, out value2); bool success3 = converter.TryConvertToCSharpValue(string.Empty, out value3); //Assert Assert.IsTrue(success0); Assert.IsTrue(success1); Assert.IsTrue(success2); Assert.IsTrue(success3); Assert.AreEqual("0", value0); Assert.AreEqual("1",value1); Assert.IsNull(value2); Assert.AreEqual(string.Empty,value3); }
public void Convert_ReturnString_WhenUnicodeString() { var py = Python.Instance(); var pyStr = py.Eval("u\"unicode string\""); var converter = new StringConverter(); Assert.AreEqual("unicode string", converter.Convert(pyStr)); }
public void Convert_ThrowsException_WhenNotUnicodeOrString() { var py = Python.Instance(); var pyInt = py.Eval("55"); var converter = new StringConverter(); Assert.Throws<ConversionException>(() => converter.Convert(pyInt)); }
public void PlcStreamToTextTest() { StringConverter privateTarget = new StringConverter(); StringConverter_Accessor target = new StringConverter_Accessor(new PrivateObject(privateTarget, new PrivateType(typeof(StringConverter)))); Assert.AreEqual<string>("323338393400", target.PlcStreamToText("323338393400")); Assert.AreEqual<string>("41424B4C", target.PlcStreamToText("41424B4C")); Assert.AreEqual<string>("53525958", target.PlcStreamToText("53525958")); }
public void TextToHexaDigitTest() { StringConverter privateTarget = new StringConverter(); StringConverter_Accessor target = new StringConverter_Accessor(new PrivateObject(privateTarget, new PrivateType(typeof(StringConverter)))); Assert.AreEqual<string>("48656C6C6F5F776F726C64", target.TextToHexaDigit("Hello_world")); Assert.AreEqual<string>("3132333435", target.TextToHexaDigit("12345")); Assert.AreEqual<string>("41583646473845525439", target.TextToHexaDigit("AX6FG8ERT9")); }
public void TextToPlcStreamTest() { StringConverter privateTarget = new StringConverter(); StringConverter_Accessor target = new StringConverter_Accessor(new PrivateObject(privateTarget, new PrivateType(typeof(StringConverter)))); Assert.AreEqual<string>("333239383400", target.TextToPlcStream("333239383400")); Assert.AreEqual<string>("393143333400", target.TextToPlcStream("3931433334")); Assert.AreEqual<string>("3348384741583536", target.TextToPlcStream("3348384741583536")); }
public void ToObjectTest() { StringConverter target = new StringConverter(); Assert.AreEqual<string>("12345", target.ToObject("313233343500")); Assert.AreEqual<string>("XH5WP", target.ToObject("584835575000")); Assert.AreEqual<string>("ZW43M", target.ToObject("5A5734334D00")); Assert.AreEqual<string>("P6JFQM", target.ToObject("50364A46514D")); }
public void HexaDigitToTextTest() { StringConverter privateTarget = new StringConverter(); StringConverter_Accessor target = new StringConverter_Accessor(new PrivateObject(privateTarget, new PrivateType(typeof(StringConverter)))); Assert.AreEqual<string>("HELLO", target.HexaDigitToText("48454C4C4F")); Assert.AreEqual<string>("35769", target.HexaDigitToText("3335373639")); Assert.AreEqual<string>("2E68T3", target.HexaDigitToText("324536385433")); }
public void CanSerializeAndDeserialize() { string value = "Lorem ipsum"; StringConverter converter = new StringConverter(); byte[] bytes = converter.Serialize(value); string valueFromBytes = converter.Deserialize(bytes); Assert.Equal(valueFromBytes, value); }
public void ShouldFailToConvertToCellValue() { //Arrange //Act var converter = new StringConverter(); string value0; string value1; bool success0 = converter.TryConvertToCellValue(0, out value0); bool success1 = converter.TryConvertToCellValue(9E+09, out value1); //Assert Assert.IsFalse(success0); Assert.IsFalse(success1); }
public void ShouldConvertToCellValue() { //Arrange //Act var converter = new StringConverter(); string value0; string value1; bool success0 = converter.TryConvertToCellValue("Yes", out value0); bool success1 = converter.TryConvertToCellValue("No", out value1); //Assert Assert.IsTrue(success0); Assert.IsTrue(success1); Assert.AreEqual("Yes", value0); Assert.AreEqual("No", value1); }
public StringConverterTests() { _target = new StringConverter(); }
protected override void OnInitEffect(params object[] objs) { assetSubType = (ASSET_SUB_TYPE)Enum.Parse(typeof(ASSET_SUB_TYPE), objs[0].ToString()); assetCnt = StringConverter.ToInt(objs[1].ToString(), 0); }
public string Get(object target) { var emitter = target as EllipsoidEmitter; return(StringConverter.ToString(emitter.Depth)); }
private static string MounterStatusStream3() { StringConverter stringConverter = new StringConverter(); IntConverter intConverter = new IntConverter(); string statusStream = "00FF" // station ID + pc ID + stringConverter.ToStream("LDPW8X2D") // cassette ID + "0001" // lot data request flag + "0001" // cassette ID error flag + "0000" // lot data communication timeout flag + stringConverter.ToStream("MZQPALJFIR2JCS") // new lot ID + "0001" // new lot start line + "0000" // new lot start flag + "0001" // carrier plate arrival flag + "0001" // BCR read OK flag + "0001" // carrier plate mounting ready flag + intConverter.ToStream(0) // wafer break information + "0001" // wafer break information OK flag + "0000" // mounting error carrier plate flag + "0000" // lot end flag + "0001" // reservation lot cancel flag + "22222222222222222222222222222222" // ... some data ... + "0004" // mounter machine state + "\u0003" // ETX ; return statusStream; }
private static string PolishingStatusStream2() { StringConverter stringConverter = new StringConverter(); string fullInfoStream = "00FF" // station ID + pc ID + stringConverter.ToStream("RTG8PS1P") // Magazine ID + stringConverter.ToStream("VFYEQ41C") // Carrier Plate ID (head 1) + stringConverter.ToStream("APSD2EKJ") // Carrier Plate ID (head 2) + stringConverter.ToStream("JHDER7PM") // Carrier Plate ID (head 3) + stringConverter.ToStream("WKD95UAS") // Carrier Plate ID (head 4) + "0000" // High Pressure Polishing flag + "0055" // High Pressure Polishing duration + "0032" // Head 1 Force + "003C" // Head 2 Force + "0046" // Head 3 Force + "0050" // Head 4 Force + "00BD" // Pad Temperature + "006F" // Cooling Water In Temperature + "00DE" // Cooling Water Out Temperature + "0155" // Slurry In Temperature + "01A9" // Slurry Out Temperature + "0278" // Rinse Temperature + "0102" // Cooling Water Amount + "0006" // Slurry Amount + "000A" // Rinse Amount + "1569" // Head 1 Pressure + "0038" // Head 2 Pressure + "036A" // Head 3 Pressure + "03E8" // Head 4 Pressure + "0005" // Head 1 Back Pressure + "A18A" // Head 2 Back Pressure + "2547" // Head 3 Back Pressure + "00A2" // Head 4 Back Pressure + "0694" // Plate RPM + "0960" // Head 1 RPM + "0A8C" // Head 2 RPM + "0BB8" // Head 3 RPM + "0CE4" // head 4 RPM + "0292" // Plate Load Current + "0014" // Head 1 Load Current + "0000" // Head 2 Load Current + "009C" // head 3 Load Current + "40A3" // head 4 Load Current + "036B" // Pad Used Time + "0281" // Pad Used Count + "\u0003" // ETX ; return fullInfoStream; }
public void Set(object target, string val) { var affector = target as ColorFaderAffector2; affector.StateChangeVal = StringConverter.ParseFloat(val); }
public void GetStream1Test() { string lotId = "NCHFYRT"; List<ICassette> cassettes = PlcHelper.GetCassetteList(2); LotCassetteInfoToStreamConverter_Accessor target = new LotCassetteInfoToStreamConverter_Accessor(); StringConverter stringConverter = new StringConverter(); IntConverter intConverter = new IntConverter(); string expected = stringConverter.ToStream(lotId).PadRight(28, '0'); expected += stringConverter.ToStream(cassettes[0].CassetteId.PadRight(8)); expected = expected.PadRight(44, '0'); expected += stringConverter.ToStream(cassettes[1].CassetteId.PadRight(8)); expected = expected.PadRight(60, '0'); expected = expected.PadRight(220, '0') + intConverter.ToStream(cassettes.Count); Assert.AreEqual<string>(expected, target.GetStream(PlcHelper.GetLotData(lotId, cassettes, PlcHelper.GetWaferList(50, 2)))); }
/// <summary> /// Puts a new translation for the specified language. /// </summary> /// <param name="language">a language two-symbol code.</param> /// <param name="value">a new translation for the specified language.</param> public void Put(string language, dynamic value) { this[language] = StringConverter.ToNullableString(value); }
public Triangle GetCoordinates(string name) { //generate initial point for calculations based on triangle name int[] InitialPoint = new int[2] { StringConverter.GetRow(name), StringConverter.GetY(name) }; //create new triangle object Triangle triangle = new Triangle { Name = name, PointA = new int[2] { Calculator.ToPixels(StringConverter.GetX(name)), Calculator.ToPixels(StringConverter.GetY(name)) }, PointB = Calculator.ToPixels(Calculator.CalculateB(InitialPoint)), PointC = Calculator.ToPixels(Calculator.CalculateC(InitialPoint)) }; return(triangle); }
public string Get(object target) { var emitter = target as RingEmitter; return(StringConverter.ToString(emitter.InnerY)); }
private double Sval(IDictionary <OmaParameter, string> parameters, double centralThickness) { double radiusDx = 1000 * (StringConverter.ExtractDoubleValue(parameters, OmaParameter.LIND) - 1) / StringConverter.ExtractDoubleValue(parameters, OmaParameter.FRNT); double result = StringConverter.ExtractDoubleValue(parameters, OmaParameter.RNGH) - (radiusDx - Math.Sqrt(Math.Pow(radiusDx, 2) - Math.Pow(StringConverter.ExtractDoubleValue(parameters, OmaParameter.BLKD) / 2, 2))); result += centralThickness; return(result); }
public void Set(object target, string val) { var emitter = target as RingEmitter; emitter.InnerY = StringConverter.ParseFloat(val); }
public void MagazineDataToStreamTest() { List<ICarrierPlate> plates = PlcHelper.GetPlateList(1, "NCG", "KFHRTE", "V", "YETSEAFQ"); Mock<IMagazine> magazine = new Mock<IMagazine>(); magazine.Setup(x => x.Id).Returns("KFYI7W"); magazine.Setup(x => x.Plates).Returns(plates); ProcessRecipeToStreamConverter_Accessor target = new ProcessRecipeToStreamConverter_Accessor(); StringConverter stringConverter = new StringConverter(); string expected = stringConverter.ToStream(magazine.Object.Id).PadRight(16, '0'); expected += stringConverter.ToStream(magazine.Object.Plates[0].Id); expected = expected.PadRight(32, '0'); expected += stringConverter.ToStream(magazine.Object.Plates[1].Id); expected = expected.PadRight(48, '0'); expected += stringConverter.ToStream(magazine.Object.Plates[2].Id); expected = expected.PadRight(64, '0'); expected += stringConverter.ToStream(magazine.Object.Plates[3].Id); expected = expected.PadRight(80, '0'); // recipes expected += "0001000100010001"; Assert.AreEqual<string>(expected, target.MagazineDataToStream(magazine.Object)); }
public override string ToString() { return(StringConverter.GetString(Operator) + Expression); }
public virtual async Task <DataPage <object> > GetPageByFilterAndProjectionAsync(string correlationId, FilterDefinition <T> filterDefinition, PagingParams paging = null, SortDefinition <T> sortDefinition = null, ProjectionParams projection = null) { var documentSerializer = BsonSerializer.SerializerRegistry.GetSerializer <T>(); var renderedFilter = filterDefinition.Render(documentSerializer, BsonSerializer.SerializerRegistry); var query = _collection.Find(renderedFilter); if (sortDefinition != null) { query = query.Sort(sortDefinition); } var projectionBuilder = Builders <T> .Projection; var projectionDefinition = CreateProjectionDefinition(projection, projectionBuilder); paging = paging ?? new PagingParams(); var skip = paging.GetSkip(0); var take = paging.GetTake(_maxPageSize); var count = paging.Total ? (long?)await query.CountAsync() : null; var result = new DataPage <object>() { Data = new List <object>(), Total = count }; using (var cursor = await query.Project(projectionDefinition).Skip((int)skip).Limit((int)take).ToCursorAsync()) { while (await cursor.MoveNextAsync()) { foreach (var doc in cursor.Current) { if (doc.ElementCount != 0) { result.Data.Add(BsonSerializer.Deserialize <object>(doc)); } } } } _logger.Trace(correlationId, $"Retrieved {result.Total} from {_collection} with projection fields = '{StringConverter.ToString(projection)}'"); return(result); }
public void GetStream2Test() { string lotId = "NCHFYRT"; List<ICassette> cassettes = PlcHelper.GetCassetteList(12); LotCassetteInfoToStreamConverter_Accessor target = new LotCassetteInfoToStreamConverter_Accessor(); StringConverter stringConverter = new StringConverter(); IntConverter intConverter = new IntConverter(); string expected = stringConverter.ToStream(lotId).PadRight(28, '0'); expected += stringConverter.ToStream(cassettes[0].CassetteId.PadRight(8)); expected = expected.PadRight(44, '0'); expected += stringConverter.ToStream(cassettes[1].CassetteId.PadRight(8)); expected = expected.PadRight(60, '0'); expected += stringConverter.ToStream(cassettes[2].CassetteId.PadRight(8)); expected = expected.PadRight(76, '0'); expected += stringConverter.ToStream(cassettes[3].CassetteId.PadRight(8)); expected = expected.PadRight(92, '0'); expected += stringConverter.ToStream(cassettes[4].CassetteId.PadRight(8)); expected = expected.PadRight(108, '0'); expected += stringConverter.ToStream(cassettes[5].CassetteId.PadRight(8)); expected = expected.PadRight(124, '0'); expected += stringConverter.ToStream(cassettes[6].CassetteId.PadRight(8)); expected = expected.PadRight(140, '0'); expected += stringConverter.ToStream(cassettes[7].CassetteId.PadRight(8)); expected = expected.PadRight(156, '0'); expected += stringConverter.ToStream(cassettes[8].CassetteId.PadRight(8)); expected = expected.PadRight(172, '0'); expected += stringConverter.ToStream(cassettes[9].CassetteId.PadRight(8)); expected = expected.PadRight(188, '0'); expected += stringConverter.ToStream(cassettes[10].CassetteId.PadRight(8)); expected = expected.PadRight(204, '0'); expected += stringConverter.ToStream(cassettes[11].CassetteId.PadRight(8)); expected = expected.PadRight(220, '0'); expected = expected.PadRight(220, '0') + intConverter.ToStream(cassettes.Count); Assert.AreEqual<string>(expected, target.GetStream(PlcHelper.GetLotData(lotId, cassettes, PlcHelper.GetWaferList(300, 12)))); }
/// <summary> /// Converts array element into a string or returns null if conversion is not possible. /// </summary> /// <param name="index">an index of element to get.</param> /// <returns>string value of the element or null if conversion is not supported.</returns> /// See <see cref="StringConverter.ToNullableString(object)"/> public string GetAsNullableString(int index) { return(StringConverter.ToNullableString(this[index])); }
public string Get(object target) { var affector = target as ColorFaderAffector2; return(StringConverter.ToString(affector.StateChangeVal)); }
public void Set(object target, string val) { var affector = target as ColorFaderAffector2; affector.AlphaAdjust2 = StringConverter.ParseFloat(val); }
/// <summary> /// Converts array element into a string or returns default value if conversion is not possible. /// </summary> /// <param name="index">an index of element to get.</param> /// <param name="defaultValue">the default value</param> /// <returns>string value of the element or default value if conversion is not supported.</returns> /// See <see cref="StringConverter.ToStringWithDefault(object, string)"/> public string GetAsStringWithDefault(int index, string defaultValue) { return(StringConverter.ToStringWithDefault(this[index], defaultValue)); }
public void GetStream4Test() { string lotId = "AA"; List<ICassette> cassettes = new List<ICassette>() { new Cassette() { CassetteId = "222" } }; LotCassetteInfoToStreamConverter_Accessor target = new LotCassetteInfoToStreamConverter_Accessor(); StringConverter stringConverter = new StringConverter(); IntConverter intConverter = new IntConverter(); string expected = stringConverter.ToStream(lotId).PadRight(28, '0'); expected += "3232322020202020"; expected = expected.PadRight(220, '0') + intConverter.ToStream(cassettes.Count); Assert.AreEqual<string>(expected, target.GetStream(PlcHelper.GetLotData(lotId, cassettes, PlcHelper.GetWaferList(125, 5)))); }
public void Update() { if (!_modActive) { return; } // Read battle pointer from memory var battlePointer = GameMemory.Read <IntPtr>(_offsetEnemyPointer); // Check if we need to reset battle if (battlePointer == IntPtr.Zero && changedCreature != null) { changedThisBattle = false; changedCreature = null; } if (battlePointer != IntPtr.Zero && !changedThisBattle) { ModLogger.WriteLine("Battle detected, modifying enemies"); changedCreature = new bool[8]; // Loop until all creatures are modified or limit is hit var loopLimit = 2000; // maximum times to attempt modification before giving up while (changedCreature.Contains(false) && loopLimit > 0) { loopLimit--; for (int i = 0; i < 8; i++) { if (changedCreature[i]) { continue; // Enemy already modified } var entityData = Battle.GetEnemyEntity(i); var entityName = StringConverter.ToString(entityData.text_name); int entityOffset = (int)battlePointer + _sizeBattleEntity * i; if (entityData.guid == 0) // No enemy in this slot { continue; } ModLogger.WriteLine("Modifying creature: {0}", entityName); var newHP = entityData.hp_max * m_HpMpMultiplier; newHP = newHP > int.MaxValue ? int.MaxValue : newHP; var newMP = entityData.mp_max * m_HpMpMultiplier; newMP = newMP > int.MaxValue ? int.MaxValue : newMP; var newStrength = entityData.strength * m_StatMultiplier; newStrength = newStrength > byte.MaxValue ? byte.MaxValue : newStrength; var newDefense = entityData.defense * m_StatMultiplier; newDefense = newDefense > byte.MaxValue ? byte.MaxValue : newDefense; var newMagic = entityData.magic * m_StatMultiplier; newMagic = newMagic > byte.MaxValue ? byte.MaxValue : newMagic; var newMagicDef = entityData.magic_defense * m_StatMultiplier; newMagicDef = newMagicDef > byte.MaxValue ? byte.MaxValue : newMagicDef; var newAgility = entityData.agility * m_StatMultiplier; newAgility = newAgility > byte.MaxValue ? byte.MaxValue : newAgility; var newLuck = entityData.luck * m_StatMultiplier; newLuck = newLuck > byte.MaxValue ? byte.MaxValue : newLuck; var newAccuracy = entityData.accuracy * m_StatMultiplier; newAccuracy = newAccuracy > byte.MaxValue ? byte.MaxValue : newAccuracy; var newEvasion = entityData.evasion * m_StatMultiplier; newEvasion = newEvasion > byte.MaxValue ? byte.MaxValue : newEvasion; // update entity values GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_current"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_max"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("hp_max2"), newHP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_current"), newMP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_max"), newMP, false); GameMemory.Write <int>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("mp_max2"), newMP, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("strength"), (byte)newStrength, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("defense"), (byte)newDefense, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("magic"), (byte)newMagic, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("magic_defense"), (byte)newMagicDef, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("agility"), (byte)newAgility, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("luck"), (byte)newLuck, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("accuracy"), (byte)newAccuracy, false); GameMemory.Write <byte>(entityOffset + StructHelper.GetFieldOffset <BattleEntityData>("evasion"), (byte)newEvasion, false); changedCreature[i] = true; } } changedThisBattle = true; } }
private static string MounterStatusStream2() { StringConverter stringConverter = new StringConverter(); IntConverter intConverter = new IntConverter(); string statusStream = "00FF" // station ID + pc ID + stringConverter.ToStream("IJKLMNOP") // cassette ID + "0000" // lot data request flag + "0001" // cassette ID error flag + "0001" // lot data communication timeout flag + stringConverter.ToStream("KCGE8PAQ1HC4HF") // new lot ID + "0002" // new lot start line + "0001" // new lot start flag + "0000" // carrier plate arrival flag + "0000" // BCR read OK flag + "0001" // carrier plate mounting ready flag + intConverter.ToStream(15) // wafer break information + "0001" // wafer break information OK flag + "0001" // mounting error carrier plate flag + "0001" // lot end flag + "0001" // reservation lot cancel flag + "11111111111111111111111111111111" // ... some data ... + "0003" // mounter machine state + "\u0003" // ETX ; return statusStream; }
public static string With(T t, StringConverter converter = null) { converter ??= new StringConverter(); return($"+{converter.ConvertToInvariantString(t)}"); }
private static string PolishingStatusStream1() { StringConverter stringConverter = new StringConverter(); string fullInfoStream = "00FF" // station ID + pc ID + stringConverter.ToStream("DHFTPR8Q") // Magazine ID + stringConverter.ToStream("NDFH8PLF") // Carrier Plate ID (head 1) + stringConverter.ToStream("DKFYQ8EL") // Carrier Plate ID (head 2) + stringConverter.ToStream("WYEJF8F3") // Carrier Plate ID (head 3) + stringConverter.ToStream("PRYDGHF4") // Carrier Plate ID (head 4) + "0001" // High Pressure Polishing flag + "0038" // High Pressure Polishing duration + "000A" // Head 1 Force + "0014" // Head 2 Force + "001E" // Head 3 Force + "0028" // Head 4 Force + "0084" // Pad Temperature + "0062" // Cooling Water In Temperature + "0093" // Cooling Water Out Temperature + "009F" // Slurry In Temperature + "0165" // Slurry Out Temperature + "01C8" // Rinse Temperature + "0144" // Cooling Water Amount + "010B" // Slurry Amount + "028C" // Rinse Amount + "30A5" // Head 1 Pressure + "1D6C" // Head 2 Pressure + "1388" // Head 3 Pressure + "00FE" // Head 4 Pressure + "0223" // Head 1 Back Pressure + "000D" // Head 2 Back Pressure + "16F2" // Head 3 Back Pressure + "0145" // Head 4 Back Pressure + "058F" // Plate RPM + "04B0" // Head 1 RPM + "05DC" // Head 2 RPM + "0708" // Head 3 RPM + "0834" // head 4 RPM + "002D" // Plate Load Current + "0008" // Head 1 Load Current + "0044" // Head 2 Load Current + "008A" // head 3 Load Current + "03B4" // head 4 Load Current + "03DE" // Pad Used Time + "0233" // Pad Used Count + "\u0003" // ETX ; return fullInfoStream; }
public computeLensRequestDTO BuildRequest(IDictionary <OmaParameter, string> parameters, side side) { computeLensRequestDTO request; string design = null; int far = 80; int near = 24; int channel = 10; double distance = Double.MaxValue; double degressiveSphereValue = 0; double degressiveAdditionValue = 0; Boolean degressiveSphere = false; Boolean degressiveAddition = false; if ((parameters.ContainsKey(OmaParameter.LDNAM) ? parameters[OmaParameter.LDNAM] : parameters.ContainsKey(OmaParameter.LNAM) ? parameters[OmaParameter.LNAM] : null) is string ldnam) { if (officeRegex.IsMatch(ldnam) && officeRegex.Match(ldnam) is Match OfficeMatch) { design = OfficeMatch.Groups[1].Value; distance = double.Parse(OfficeMatch.Groups[3].Value, CultureInfo.InvariantCulture); degressiveAddition = true; degressiveAdditionValue = Math.Round(StringConverter.ExtractDoubleValue(parameters, OmaParameter.ADD) - 1D / distance, 2); degressiveSphere = true; degressiveSphereValue = StringConverter.ExtractDoubleValue(parameters, OmaParameter.SPH) + StringConverter.ExtractDoubleValue(parameters, OmaParameter.ADD) - degressiveAdditionValue; } if (farRegex.IsMatch(ldnam) && farRegex.Match(ldnam) is Match FarMatch) { design = FarMatch.Groups[1].Value; far = Convert.ToInt32(FarMatch.Groups[2].Value); near = Convert.ToInt32(FarMatch.Groups[3].Value); channel = Convert.ToInt32(FarMatch.Groups[4].Value); } else if (nearRegex.IsMatch(ldnam) && nearRegex.Match(ldnam) is Match NearMath) { design = NearMath.Groups[1].Value; near = Convert.ToInt32(NearMath.Groups[2].Value); channel = Convert.ToInt32(NearMath.Groups[3].Value); } else if (channelRegex.IsMatch(ldnam) && channelRegex.Match(ldnam) is Match ChannelMatch) { design = ChannelMatch.Groups[1].Value; channel = Convert.ToInt32(ChannelMatch.Groups[2].Value); } else { design = ldnam; } } switch (design.ToUpper()) { case "MAGIC": request = new computeMagicLensRequestDTO(); break; case "FANTASY": request = new computeFantasyLensRequestDTO(); break; case "OFFICE": case "EBLOFFICE": request = new computeOfficeLensRequestDTO(); break; case "ANTIFATIGUE": case "EBLANTIFATIGUE": request = new computeAntifatigueLensRequestDTO(); break; case "BASIC": case "EBLPROGRESSIVE": request = new computeBasicLensRequestDTO(); break; case "4K07": case "4KUS": request = new compute4K07LensRequestDTO(); break; case "4K09": case "4KSX": request = new compute4K09LensRequestDTO(); break; case "4K11": case "4KS": request = new compute4K11LensRequestDTO(); break; case "4K13": case "4KR": request = new compute4K13LensRequestDTO(); break; case "DIGIT": request = new computeDigitLensRequestDTO(); break; case "VARIO": request = new computeVarioLensRequestDTO(); break; case "IFLEX": request = new computeIflexLensRequestDTO(); break; case "IPROG": request = new computeIprogLensRequestDTO(); break; case "IPROF": request = new computeIprofLensRequestDTO(); break; case "PUNCTUAL": request = new computePunctualLensRequestDTO(); break; case "MONOF": case "EBLSINGLEVISION": request = new computeMonofLensRequestDTO(); break; case "EBLPROGR": request = new computeEblRegularLensRequestDTO(); break; case "EBLPROGS": request = new computeEblShortLensRequestDTO(); break; case "EBLPROGSX": request = new computeEblExtraShortLensRequestDTO(); break; case "EBLPROGUS": request = new computeEblUltraShortLensRequestDTO(); break; default: throw new OmaException("LDNAME format is not correct", null, side, OmaStatusCode.IncorrectLdname); } if (request is computeFarLensRequestDTO computeFarLensRequestDTO) { computeFarLensRequestDTO.far = far; computeFarLensRequestDTO.farSpecified = true; } if (request is computeNearLensRequestDTO computeNearLensRequestDTO) { computeNearLensRequestDTO.near = near; computeNearLensRequestDTO.nearSpecified = true; } if (request is computeNativeLensRequestDTO computeNativeLensRequestDTO) { computeNativeLensRequestDTO.channel = channel; computeNativeLensRequestDTO.channelSpecified = true; } request.verticalPrismThinning = StringConverter.ExtractBoolValue(parameters, OmaParameter.PTOK); request.verticalPrismThinningSpecified = true; request.horizontalPrismThinning = StringConverter.ExtractBoolValue(parameters, OmaParameter._PTOK); request.horizontalPrismThinningSpecified = true; request.horizontalPrismThinningHeight = StringConverter.ExtractDoubleValue(parameters, OmaParameter._PTOKHVAL, 6); request.horizontalPrismThinningHeightSpecified = true; request.prismThinningCompensation = false; request.prismThinningCompensationSpecified = true; request.maximumPrismThinningCompensation = 0; request.maximumPrismThinningCompensationSpecified = true; request.atoric = false; request.atoricSpecified = true; request.pantoscopicAngle = StringConverter.ExtractDoubleValue(parameters, OmaParameter.PANTO); request.pantoscopicAngleSpecified = true; request.wrappingAngle = StringConverter.ExtractDoubleValue(parameters, OmaParameter.ZTILT); request.wrappingAngleSpecified = true; request.backVertexDistance = StringConverter.ExtractDoubleValue(parameters, OmaParameter.BVD); request.backVertexDistanceSpecified = true; request.eyeDiameter = 24; request.eyeDiameterSpecified = true; request.readDistance = StringConverter.ExtractDoubleValue(parameters, OmaParameter.NWD); request.readDistanceSpecified = true; request.value = new computeLensRequestSideDTO { side = side, sideSpecified = true, sphere = (degressiveSphere ? degressiveSphereValue : StringConverter.ExtractDoubleValue(parameters, OmaParameter.SPH)) + StringConverter.ExtractDoubleValue(parameters, OmaParameter.ADJSPH), sphereSpecified = true, cylinder = StringConverter.ExtractDoubleValue(parameters, OmaParameter.CYL) + StringConverter.ExtractDoubleValue(parameters, OmaParameter.ADJCYL), cylinderSpecified = true, cylinderAxis = Convert.ToInt32(Math.Round(StringConverter.ExtractDoubleValue(parameters, OmaParameter.AX) + StringConverter.ExtractDoubleValue(parameters, OmaParameter.ADJAX))), cylinderAxisSpecified = true, addiction = (degressiveAddition ? degressiveAdditionValue : StringConverter.ExtractDoubleValue(parameters, OmaParameter.ADD)) + StringConverter.ExtractDoubleValue(parameters, OmaParameter.ADJADD), addictionSpecified = true, horizontalDiameter = Convert.ToInt32(Math.Round(StringConverter.ExtractDoubleValue(parameters, OmaParameter.CRIB))), horizontalDiameterSpecified = true, verticalDiameter = Convert.ToInt32(Math.Round(StringConverter.ExtractDoubleValue(parameters, OmaParameter.ELLH, StringConverter.ExtractDoubleValue(parameters, OmaParameter.CRIB)))), verticalDiameterSpecified = true, refractiveIndex = StringConverter.ExtractDoubleValue(parameters, OmaParameter.LIND), refractiveIndexSpecified = true, toolRealBase = (StringConverter.ExtractDoubleValue(parameters, OmaParameter.LIND) - 1) * 1000 / ((StringConverter.ExtractDoubleValue(parameters, OmaParameter.TIND) - 1) * 1000 / StringConverter.ExtractDoubleValue(parameters, OmaParameter.FRNT)), toolRealBaseSpecified = true, toolIndex = StringConverter.ExtractDoubleValue(parameters, OmaParameter.TIND), toolIndexSpecified = true, prescriptedPrism = StringConverter.ExtractDoubleValue(parameters, OmaParameter.PRVM), prescriptedPrismSpecified = true, prescriptedPrismBase = StringConverter.ExtractIntValue(parameters, OmaParameter.PRVA), prescriptedPrismBaseSpecified = true, secondaryPrism = StringConverter.ExtractDoubleValue(parameters, OmaParameter._PRVM), secondaryPrismSpecified = true, secondaryPrismBase = StringConverter.ExtractIntValue(parameters, OmaParameter._PRVA), secondaryPrismBaseSpecified = true, minimalCentralThickness = StringConverter.ExtractDoubleValue(parameters, OmaParameter.MINCTR), minimalCentralThicknessSpecified = true, minimalSideThickness = StringConverter.ExtractDoubleValue(parameters, OmaParameter.MINEDG, 2.0), minimalSideThicknessSpecified = true, horizontalDecentralization = StringConverter.ExtractDoubleValue(parameters, OmaParameter.BCERIN, StringConverter.ExtractDoubleValue(parameters, OmaParameter.SMOCIN)), horizontalDecentralizationSpecified = true, verticalDecentralization = StringConverter.ExtractDoubleValue(parameters, OmaParameter.BCERUP, StringConverter.ExtractDoubleValue(parameters, OmaParameter.SMOCUP)), verticalDecentralizationSpecified = true, monocularCentrationDistance = StringConverter.ExtractDoubleValue(parameters, OmaParameter.IPD, 32), monocularCentrationDistanceSpecified = true, inset = StringConverter.ExtractDoubleValue(parameters, OmaParameter.ERNRIN, 2.2), insetSpecified = true }; if (new[] { OmaParameter._EBL }.ToList().All(Key => parameters.ContainsKey(Key)) && StringConverter.ExtractBoolValue(parameters, OmaParameter._EBL)) { request = new computeAestheticLensRequestDTO() { componentLensRequest = request, internalLensDiameter = StringConverter.ExtractIntValue(parameters, OmaParameter._EBLINTDIA, 40), internalLensDiameterSpecified = true, junctionDiameter = StringConverter.ExtractIntValue(parameters, OmaParameter._EBLJUNDIA, 60), junctionDiameterSpecified = true, sideAngle = StringConverter.ExtractIntValue(parameters, OmaParameter._EBLANG, 10), sideAngleSpecified = true }; } return(request); }
private static string PolishingStatusStream3() { StringConverter stringConverter = new StringConverter(); string fullInfoStream = "00FF" // station ID + pc ID + stringConverter.ToStream("SDJR8ZS6") // Magazine ID + stringConverter.ToStream("AP5KFHEM") // Carrier Plate ID (head 1) + stringConverter.ToStream("VES7KGFT") // Carrier Plate ID (head 2) + stringConverter.ToStream("CIFGP3KJ") // Carrier Plate ID (head 3) + stringConverter.ToStream("WKD95UAS") // Carrier Plate ID (head 4) + "0001" // High Pressure Polishing flag + "004F" // High Pressure Polishing duration + "005A" // Head 1 Force + "0064" // Head 2 Force + "006E" // Head 3 Force + "0078" // Head 4 Force + "00D5" // Pad Temperature + "0166" // Cooling Water In Temperature + "02E5" // Cooling Water Out Temperature + "0168" // Slurry In Temperature + "0001" // Slurry Out Temperature + "0323" // Rinse Temperature + "0057" // Cooling Water Amount + "0087" // Slurry Amount + "03C3" // Rinse Amount + "30FF" // Head 1 Pressure + "589C" // Head 2 Pressure + "0001" // Head 3 Pressure + "0591" // Head 4 Pressure + "0063" // Head 1 Back Pressure + "03A6" // Head 2 Back Pressure + "1A5D" // Head 3 Back Pressure + "0000" // Head 4 Back Pressure + "05FE" // Plate RPM + "0E10" // Head 1 RPM + "0F3C" // Head 2 RPM + "0EA6" // Head 3 RPM + "0DDE" // head 4 RPM + "0007" // Plate Load Current + "000A" // Head 1 Load Current + "01AC" // Head 2 Load Current + "038E" // head 3 Load Current + "0001" // head 4 Load Current + "03D0" // Pad Used Time + "0247" // Pad Used Count + "\u0003" // ETX ; return fullInfoStream; }
private string SecondExceptionString() { return(string.Format(CultureInfo.InvariantCulture, "There is a delegate specified on the factory, '{0}', but it leads to a null referenced delegate wrapper.", StringConverter.FromType(GetType(), true))); }
public void TestStringConverter() { var bytes = new byte[] { 0xd8, 0xc4, 0xc2, 0xf2, 0x61, 0xd1, 0xe5, 0xd4 }; Assert.AreEqual("QDB2/JVM", StringConverter.EbcdicToAscii(bytes, 0, bytes.Length)); }
private static void LoadMtlib(string filePath, ref ObjItem result) { #if WEB_APP var request = (FtpWebRequest)FtpWebRequest.Create(filePath); request.Credentials = new NetworkCredential(FTPHelper.Login, FTPHelper.Password); request.Method = WebRequestMethods.Ftp.DownloadFile; var ftpResponse = (FtpWebResponse)request.GetResponse(); byte[] buffer = new byte[16 * 1024]; using (var ftpStream = ftpResponse.GetResponseStream()) { using (MemoryStream ms = new MemoryStream()) { int read; while ((read = ftpStream.Read(buffer, 0, buffer.Length)) > 0) { ms.Write(buffer, 0, read); } ms.Position = 0; ms.Flush(); using (var sr = new StreamReader(ms, Encoding.Default)) #else var fi = new FileInfo(filePath); if (!fi.Exists) return; using (var sr = new StreamReader(fi.FullName)) #endif { var material = default(ObjMaterial); while (!sr.EndOfStream) { var currentLine = sr.ReadLine(); if (String.IsNullOrWhiteSpace(currentLine) || currentLine[0] == '#') continue; var fields = currentLine.Trim().Split(null, 2); var keyword = fields[0].Trim().ToLower(); var data = fields[1].Trim(); switch (keyword) { case "newmtl": var dt = data.ToLower(); if (result.Materials.ContainsKey(dt)) material = result.Materials[dt]; else { material = new ObjMaterial(data); result.Materials.Add(dt, material); } break; case "ka": if (material != null) material.AmbientColor = ParseVector3(data); break; case "kd": if (material != null) { var color = ParseVector3(data); material.DiffuseColor = new Vector4(color.X, color.Y, color.Z, 1f); } break; case "ks": if (material != null) material.SpecularColor = ParseVector3(data); break; case "ns": if (material != null) material.SpecularCoefficient = StringConverter.ToFloat(data); break; case "ni": if (material != null) material.OpticalDensity = StringConverter.ToFloat(data); break; case "d": case "tr": if (material != null) material.Transparency = StringConverter.ToFloat(data); break; case "illum": if (material != null) material.IlluminationModel = StringConverter.ToInt(data); break; case "map_ka": if (material != null) material.AmbientTextureMap = GetMapFullPath(data, filePath); break; case "map_kd": if (material != null) material.DiffuseTextureMap = GetMapFullPath(data, filePath); break; case "map_ks": if (material != null) material.SpecularTextureMap = GetMapFullPath(data, filePath); break; case "map_ns": if (material != null) material.SpecularHighlightTextureMap = GetMapFullPath(data, filePath); break; case "map_d": if (material != null) material.TransparentTextureMap = GetMapFullPath(data, filePath); break; case "map_bump": case "bump": if (material != null) material.BumpMap = GetMapFullPath(data, filePath); break; case "disp": if (material != null) material.DisplacementMap = GetMapFullPath(data, filePath); break; case "decal": if (material != null) material.StencilDecalMap = GetMapFullPath(data, filePath); break; } } } #if WEB_APP } } #endif }
public void Set(object target, string val) { var emitter = target as EllipsoidEmitter; emitter.Depth = StringConverter.ParseFloat(val); }
public void Set(object target, string val) { ((BillboardParticleRenderer)target).PointRenderingEnabled = StringConverter.ParseBool(val); }
public override BaseMessageSelection <TValue> Build() { if (Selectables == null) { throw new ArgumentException(nameof(Selectables)); } if (Selectables.Count == 0) { throw new InvalidOperationException("You need at least one selectable"); } var selectableDictionary = new Dictionary <string[], TValue>(); var descriptionBuilder = new StringBuilder(); for (int i = 0; i < Selectables.Count; i++) { var selectable = Selectables[i]; string text = StringConverter.Invoke(selectable); selectableDictionary.Add(new string[] { $"{i + 1}", $"#{i + 1}", text, $"#{i + 1} - {text}" }, selectable); if (EnableDefaultSelectionDescription) { descriptionBuilder.AppendLine($"#{i + 1} - {text}"); } } if (AllowCancel) { selectableDictionary.Add(new string[] { $"{Selectables.Count + 1}", $"#{Selectables.Count + 1}", CancelMessage, $"#{Selectables.Count + 1} - {CancelMessage}" }, default); if (EnableDefaultSelectionDescription) { descriptionBuilder.Append($"#{Selectables.Count + 1} - {CancelMessage}"); } } if (EnableDefaultSelectionDescription) { SelectionPage.AddField(Title, descriptionBuilder.ToString()); } return(new MessageSelection <TValue>( selectableDictionary.AsReadOnly(), Users?.AsReadOnly() ?? throw new ArgumentException(nameof(Users)), SelectionPage?.Build() ?? throw new ArgumentNullException(nameof(SelectionPage)), CancelledPage?.Build(), TimeoutedPage?.Build(), AllowCancel, CancelMessage, Deletion )); }
public void Set(object target, string val) { ((BillboardParticleRenderer)target).UseAccurateFacing = StringConverter.ParseBool(val); }
public void Set(object target, string val) { LinearForceAffector affector = target as LinearForceAffector; affector.Force = StringConverter.ParseVector3(val); }
public string Get(object target) { var affector = target as DeflectorPlaneAffector; return(StringConverter.ToString(affector.PlanePoint)); }
public void Set(object target, string val) { ((BillboardParticleRenderer)target).CommonUpVector = StringConverter.ParseVector3(val); }
public virtual async Task <object> GetOneByIdAsync(string correlationId, K id, ProjectionParams projection) { var builder = Builders <T> .Filter; var filter = builder.Eq(x => x.Id, id); var projectionBuilder = Builders <T> .Projection; var projectionDefinition = CreateProjectionDefinition(projection, projectionBuilder); var result = await _collection.Find(filter).Project(projectionDefinition).FirstOrDefaultAsync(); if (result == null) { _logger.Trace(correlationId, "Nothing found from {0} with id = {1} and projection fields '{2}'", _collectionName, id, StringConverter.ToString(projection)); return(null); } if (result.ElementCount == 0) { _logger.Trace(correlationId, "Retrieved from {0} with id = {1}, but projection is not valid '{2}'", _collectionName, id, StringConverter.ToString(projection)); return(null); } _logger.Trace(correlationId, "Retrieved from {0} with id = {1} and projection fields '{2}'", _collectionName, id, StringConverter.ToString(projection)); return(BsonSerializer.Deserialize <object>(result)); }
public string Get(object target) { var affector = target as ColorFaderAffector2; return(StringConverter.ToString(affector.AlphaAdjust2)); }
public void Convert_ReturnString_WhenAnsiString() { var py = Python.Instance(); var pyStr = py.Eval("\"ansi string\""); var converter = new StringConverter(); Assert.AreEqual("ansi string", converter.Convert(pyStr)); }