public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { base.GetPropertyHeight(property, label); _audioOption = property.GetValue<AudioOption>(); _dynamicValue = _audioOption.Value; _hasCurve = _audioOption.HasCurve(); _typeProperty = property.FindPropertyRelative("_type"); _delayProperty = property.FindPropertyRelative("_delay"); UpdateProperties(); InitializeValue(_typeProperty.GetValue<AudioOption.Types>()); float height = 16f; if (property.isExpanded) { height += 38f + EditorGUI.GetPropertyHeight(_valueProperty, label, true); if (_timeProperty != null) height += EditorGUI.GetPropertyHeight(_timeProperty) + 2f; if (_easeProperty != null) height += EditorGUI.GetPropertyHeight(_easeProperty) + 2f; } return height; }
protected override void Execute(CodeActivityContext context) { DynamicValue taskdata = context.GetValue(this.Data); DynamicValue MessageId = new DynamicValue(); taskdata.TryGetValue("MessageId", out MessageId); IMessageStore messageStore = strICT.InFlow.Db.StoreHandler.getMessageStore(context.GetValue(cfgSQLConnectionString)); M_Message message = messageStore.getMessageBymsgId(Convert.ToInt32(MessageId.ToString())); //store message-type in GlobalTransition context.SetValue(GlobalTransition, message.Sender_SubjectName + "|" + message.Message_Type); DynamicValue data = DynamicValue.Parse(message.Data); DynamicValue variables = context.GetValue(GlobalVariables); //write message data to GlobalVariables foreach (string i in data.Keys) { DynamicValue value = new DynamicValue(); data.TryGetValue(i, out value); if (variables.ContainsKey(i)) { variables.Remove(i); } variables.Add(i, value); } context.SetValue(GlobalVariables, variables); //mark message in message-store as received messageStore.markMessageAsReceived(message.Id); }
public void AddNote(int track, int start, int length, byte key, DynamicValue dynamicValue, byte channel) { var velocity = MidiUtils.DynamicToVelocity(dynamicValue); AddEvent(track, start, new MidiMessage(new[] { MakeCommand(0x90, channel), FixValue(key), FixValue((byte)velocity) })); AddEvent(track, start + length, new MidiMessage(new[] { MakeCommand(0x80, channel), FixValue(key), FixValue((byte)velocity) })); }
internal static BaseSettlementType Create(XElement element) { string id = element.Attribute("id").Value; string name = element.Element("name").Value; string description = element.Element("description").Value; DynamicValue<LandProvince> probability = new DynamicValue<LandProvince>(element.Element("probability")); return new BaseSettlementType(id, name, description, probability); }
public void Can_Convert_Int_To_Boolean() { dynamic t = new DynamicValue(1); bool tTest = t; tTest.Should().BeTrue(); dynamic t2 = new DynamicValue(0); bool t2Test = t2; t2Test.Should().BeFalse(); }
public void Can_Convert_String_To_Boolean() { dynamic t = new DynamicValue("true"); bool testt = t; testt.Should().BeTrue(); dynamic f = new DynamicValue("false"); bool testf = f; testf.Should().BeFalse(); }
internal ResourceType(XElement element) { Id = element.MandatoryAttribute("id", "A resource type without id is defined.").Value; Name = element.MandatoryElement("name", "The resource type ("+Id+") has no name.").Value; Probability = new DynamicValue<IScriptLandProvinceForResourcesGeneration>(element.Element("probability")); ResourceCategory category = ResourceCategory.Default; bool conversionSucceeded = element.Element("category") != null; if(conversionSucceeded) conversionSucceeded = ResourceCategory.TryParse(element.Element("category").Value, true, out category); Category = conversionSucceeded ? category : ResourceCategory.Default; }
public void StringInEqualityOperatorTest() { // LHS DynamicValue value = new DynamicValue("test1"); Assert.IsTrue(value != "test", "Equality test Value == <string> test failed."); // RHS Assert.IsTrue("test" != value, "Equality test <string> == Value test failed."); // Value var value2 = new DynamicValue("test"); Assert.IsTrue(value != value2, "Equality test Value == Value test failed."); }
public void IntegerInEqualityOperatorTest() { // LHS DynamicValue value = new DynamicValue(10); Assert.IsTrue(value != 12, "Equality test Value == <int> test failed."); // RHS Assert.IsTrue(12 != value, "Equality test <int> == Value test failed."); // Value var value2 = new DynamicValue(12); Assert.IsTrue(value != value2, "Equality test Value == Value test failed."); }
public void LongInEqualityOperatorTest() { // LHS DynamicValue value = new DynamicValue(10L); Assert.IsTrue(value != 12L, "Equality test Value == <long> test failed."); // RHS Assert.IsTrue(12L != value, "Equality test <long> == Value test failed."); // Value var value2 = new DynamicValue(12L); Assert.IsTrue(value != value2, "Equality test Value == Value test failed."); }
internal ConstructionStep(BuildingType buildingType, XElement element) { _resourceRequirements = element.Descendants("resource") .Select(e => new { Resource = ResourceTypes.Types.Single(t => t.Id.Equals(e.MandatoryAttribute("type", "A construction step has a resource with no type ("+buildingType.Id+").").Value)), Value = new DynamicValue<Settlement>(e) }) .ToDictionary(e => e.Resource, e => e.Value); _manpowerRequirement = new DynamicValue<Settlement>(element.MandatoryElement("manpower", "A construction step has no manpower requirement (" + buildingType.Id + ").")); }
public void LongEqualityOperatorTest() { // As integer // LHS DynamicValue value = new DynamicValue(10L); Assert.IsTrue(value == 10L, "Equality test Value == <long> test failed."); // RHS Assert.IsTrue(10L == value, "Equality test <long> == Value test failed."); // Value var value2 = new DynamicValue(10L); Assert.IsTrue(value == value2, "Equality test Value == Value test failed."); }
public void AddNote(int track, int start, int length, byte key, DynamicValue dynamicValue, byte channel) { MidiEvents.Add(new NoteEvent { Channel = channel, DynamicValue = dynamicValue, Key = key, Length = length, Tick = start, Track = track }); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { base.GetPropertyHeight(property, label); dynamicValue = property.GetValue<DynamicValue>(); height = GetHeight(); if (height == 0f) return 18f; else return height; }
public void IntegerEqualityOperatorTest() { // As integer // LHS int original = 10; int compareTo = 10; DynamicValue value = new DynamicValue(original); Assert.IsTrue(value == compareTo, "Equality test Value == <int> test failed."); // RHS Assert.IsTrue(compareTo == value, "Equality test <int> == Value test failed."); // Value var value2 = new DynamicValue(original); Assert.IsTrue(value == value2, "Equality test Value == Value test failed."); }
public static int DynamicToVelocity(DynamicValue dyn) { return (MinVelocity + ((int)(dyn) * VelocityIncrement)); // switch(dynamicValue) // { // case PPP: return (MinVelocity + (0 * VelocityIncrement)); // case PP: return (MinVelocity + (1 * VelocityIncrement)); // case P: return (MinVelocity + (2 * VelocityIncrement)); // case MP: return (MinVelocity + (3 * VelocityIncrement)); // case MF: return (MinVelocity + (4 * VelocityIncrement)); // case F: return (MinVelocity + (5 * VelocityIncrement)); // case FF: return (MinVelocity + (6 * VelocityIncrement)); // case FFF: return (MinVelocity + (7 * VelocityIncrement)); // } }
public static int DynamicToVelocity(DynamicValue dyn) { return(MinVelocity + ((int)(dyn) * VelocityIncrement)); // switch(dynamicValue) // { // case PPP: return (MinVelocity + (0 * VelocityIncrement)); // case PP: return (MinVelocity + (1 * VelocityIncrement)); // case P: return (MinVelocity + (2 * VelocityIncrement)); // case MP: return (MinVelocity + (3 * VelocityIncrement)); // case MF: return (MinVelocity + (4 * VelocityIncrement)); // case F: return (MinVelocity + (5 * VelocityIncrement)); // case FF: return (MinVelocity + (6 * VelocityIncrement)); // case FFF: return (MinVelocity + (7 * VelocityIncrement)); // } }
public void ShouldSerializeCustomProxies() { var instance = new DynamicValue <int>(null, () => 0); _endpoint.Setup(x => x.RegisterInstance(instance)).Returns("i1"); Serialize(instance).ShouldBe("i1"); Serialize <DynamicValue <int> >(null).ShouldBe(String.Empty); // transparent serialization scenario var instance2 = new DynamicValue <int>(TinyProtocol.Serializer <IDynamicValueProxy <int> > .Deserialize(_endpoint.Object, "otherProxy"), () => 0); Serialize(instance2).ShouldBe("otherProxy"); Deserialize <DynamicValue <int> >("i1").ShouldNotBeNull(); Deserialize <DynamicValue <int> >(String.Empty).ShouldBe(null); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { base.GetPropertyHeight(property, label); dynamicValue = property.GetValue <DynamicValue>(); height = GetHeight(); if (height == 0f) { return(18f); } else { return(height); } }
private void DynamicValueField(string label, DynamicValue dv) { GUILayout.BeginHorizontal(); dv.useGameValue = EditorGUILayout.Toggle(label, dv.useGameValue, GUILayout.ExpandWidth(false)); DeserialiseGameValueType(dv); if (dv.useGameValue) { dv.valueType = (GameValueType)EditorGUILayout.EnumPopup(dv.valueType); dv.serializedtype = dv.valueType.ToString(); } else { dv.constantValue = EditorGUILayout.FloatField(dv.constantValue); } GUILayout.EndHorizontal(); }
protected override void InnerReplaceValues(Dictionary <Value, Value> originalReplace) { if (resourceFieldValue != null && originalReplace.ContainsKey(resourceFieldValue)) { resourceFieldValue = (ResourceFieldValue)originalReplace[resourceFieldValue]; } if (resourceTypeValue != null && originalReplace.ContainsKey(resourceTypeValue)) { resourceTypeValue = (DynamicValue)originalReplace[resourceTypeValue]; } if (toolTypeValue != null && originalReplace.ContainsKey(toolTypeValue)) { toolTypeValue = (DynamicValue)originalReplace[toolTypeValue]; } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { base.GetPropertyHeight(property, label); _dynamicValue = property.GetValue<DynamicValue>(); _typeProperty = property.FindPropertyRelative("_type"); _isArrayProperty = property.FindPropertyRelative("_isArray"); _valueProperty = GetValueProperty(_typeProperty.GetValue<DynamicValue.ValueTypes>(), _isArrayProperty.GetValue<bool>()); if (property.isExpanded) if (_valueProperty == null) return 32f; else return EditorGUI.GetPropertyHeight(_valueProperty, label, true) + 32f; else return 16f; }
public override async Task <Tfplugin5.PrepareProviderConfig.Types.Response> PrepareProviderConfig( Tfplugin5.PrepareProviderConfig.Types.Request request, ServerCallContext context) { _log.LogDebug(">>>{method}>>>", nameof(PrepareProviderConfig)); _log.LogTrace($"->input[{nameof(request)}] = {{@request}}", request); _log.LogTrace($"->input[{nameof(context)}] = {{@context}}", context); try { var response = new Tfplugin5.PrepareProviderConfig.Types.Response(); // Default prepared config to incoming config response.PreparedConfig = request.Config; var plugin = SchemaHelper.GetPluginDetails(PluginAssembly); _ProviderInstance = DynamicValue.Unmarshal(plugin.Provider, request.Config); if (typeof(IHasPrepareProviderConfig).IsAssignableFrom(plugin.Provider)) { var invokeInput = new PrepareProviderConfigInput(); var invokeResult = (_ProviderInstance as IHasPrepareProviderConfig).PrepareConfig(invokeInput); if (invokeResult == null) { throw new Exception("invocation result returned null"); } var diagnostics = invokeResult.Diagnostics; if (diagnostics.Count() > 0) { response.Diagnostics.Add(diagnostics.All()); } response.PreparedConfig = DynamicValue.Marshal(plugin.Provider, _ProviderInstance); } _log.LogTrace("<-result = {@response}", response); return(await Task.FromResult(response)); } catch (Exception ex) { _log.LogError(ex, "<!exception = "); throw; } }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DynamicValue source = this.Source.Get(context); Encoding encoding = this.Encoding.Get(context) ?? System.Text.Encoding.UTF8; var settings = new System.Xml.XmlWriterSettings() { Encoding = encoding, OmitXmlDeclaration = false, ConformanceLevel = System.Xml.ConformanceLevel.Document, Indent = true }; Func <string> action = () => InternalExecute(this.RootName, source, settings); context.UserState = action; return(action.BeginInvoke(callback, state)); }
public Beat() { WhammyBarPoints = new FastList <BendPoint>(); Notes = new FastList <Note>(); BrushType = BrushType.None; Vibrato = VibratoType.None; GraceType = GraceType.None; PickStroke = PickStrokeType.None; Duration = Duration.Quarter; TremoloSpeed = null; Automations = new FastList <Automation>(); Dots = 0; Start = 0; TupletDenominator = -1; TupletNumerator = -1; Dynamic = DynamicValue.F; Crescendo = CrescendoType.None; }
public ActionResult EditPost(List <DynamicValue> dynamics) { foreach (var dv in dynamics) { int? id = dv.Id; DynamicValue dynamic = db.dynamicValues.Find(id); if (ModelState.IsValid) { dynamic.dynamicValue = dv.dynamicValue; db.Entry(dynamic).State = EntityState.Modified; db.SaveChanges(); } ViewBag.templateID = new SelectList(db.Orders, "orderId", "orderId", dynamic.OrderId); } return(RedirectToAction("Index")); }
public void Save() { try { if (!AllowSave) { return; } List <DynamicValue> lstValues = new List <DynamicValue>(); if (dr != null) { DynamicValue objVal = null; if (Utility.Int32Dbnull(dr["idValue"], -1) > 0) { objVal = DynamicValue.FetchByID(Utility.Int32Dbnull(dr["idValue"], -1)); objVal.IsNew = false; objVal.MarkOld(); } else { objVal = new DynamicValue(); objVal.IsNew = true; } objVal.Id = Utility.Int32Dbnull(dr["idValue"], -1); objVal.Ma = Utility.sDbnull(dr[DynamicField.Columns.Ma], "-1"); objVal.Giatri = Utility.DoTrim(txtValue.Text); objVal.Rtf = txtValue.Rtf; objVal.ImageId = -1; objVal.IdChidinhchitiet = Utility.Int32Dbnull(dr[DynamicValue.Columns.IdChidinhchitiet], -1); lstValues.Add(objVal); clsHinhanh.UpdateDynamicValues(lstValues); dr["idValue"] = objVal.Id; isSaved = true; } } catch (Exception ex) { } }
public Value VerifyType <T>( [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "", [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0 ) { if ((Object == null || !(Object is T)) && Type != ValueType.Nil) { throw new UnexpectedTypeException( DynamicValue?.GetType(), typeof(T), new SourceRef( new Source(sourceFilePath, ""), sourceLineNumber, 0 ) ); } return(this); }
private void submitTaskAnswer(DynamicValue val, P_Process process, T_Task openTask) { //create and publish notification WorkflowManagementClient client = new WorkflowManagementClient(new Uri(baseAddress + process.WFM_RootScope + process.WFM_ProcessScope), credentials); client.PublishNotification(new WorkflowNotification() { Properties = { { "NotificationType", "taskAnswer" }, { "wfID", openTask.WFId }, { "OrderId", openTask.InternalOrderId } }, Content = new Dictionary <string, object>() { { "data", val } } }); }
protected override void Execute(CodeActivityContext context) { System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword)); DynamicValue variables = context.GetValue(globalVariables); DynamicValue dvReadableParameters = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(readableParameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); dvReadableParameters.Add(i, value); } } DynamicValue dvEditableParameters = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(editableParameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); dvEditableParameters.Add(i, value); } else { DynamicValue val = new DynamicValue(); val.Add("Type", "string"); val.Add("Value", ""); dvEditableParameters.Add(i, val); } } T_Task newTask = new T_Task("S", context.GetValue(globalWFId), context.GetValue(Name), false, false, context.GetValue(isEndState), dvReadableParameters.ToString(), dvEditableParameters.ToString(), context.GetValue(toSubject), context.GetValue(OrderId));//, 0, ""); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(context.GetValue(cfgManagementScopeAddress)), credentials); client.PublishNotification(newTask.toWorkflowNotification()); }
private void EvaluateDynamicvaluePath() { try { var dv = DynamicValue.Parse(txtWebPayload.Text); var act = new EvaluateDynamicValuePath { Input = new LambdaValue <DynamicValue>(c => dv), Path = txtPath.Text }; var result = WorkflowInvoker.Invoke(act); txtResults.Text = result.Count == 0 ? "< No Results >" : result.ToString(); } catch (Exception ex) { txtResults.Text = string.Format("ERROR\r\n{0}", ex); } }
protected override void Execute(NativeActivityContext context) { DynamicValue dynCondition = context.GetValue <DynamicValue>(this.Condition); bool condition = DynamicValueConvert.ConvertTo <bool>(dynCondition); if (condition) { if (null != this.Then) { context.ScheduleActivity(this.Then); } } else { if (null != this.Else) { context.ScheduleActivity(this.Else); } } }
public static object UnmarshalViaMsgPackCli(Type t, DynamicValue dv) { var ctx = new SerializationContext { SerializationMethod = SerializationMethod.Map, }; ctx.ResolveSerializer += (s, ev) => { _log.LogInformation("Resolving Serialization for: " + ev.TargetType.FullName); var serType = typeof(TFMsgPackSerializer <>).MakeGenericType(ev.TargetType); var serInst = Activator.CreateInstance(serType, ev.Context); ((ISerSetter)serInst).SetSerializer(ev); }; var ser = MessagePackSerializer.Get(t, ctx); using (var ms = new MemoryStream(dv.Msgpack.ToArray())) { return(ser.Unpack(ms)); } }
protected override void Execute(CodeActivityContext context) { System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(context.GetValue(cfgWFMUsername), context.GetValue(cfgWFMPassword)); DynamicValue variables = context.GetValue(globalVariables); DynamicValue dvReadableParameters = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(readableParameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); dvReadableParameters.Add(i, value); } } DynamicValue dvEditableParameters = new DynamicValue(); foreach (string i in SbpmActivityHelper.convertCSVtoListofString(context.GetValue(editableParameters))) { if (variables.ContainsKey(i)) { DynamicValue value = new DynamicValue(); variables.TryGetValue(i, out value); dvEditableParameters.Add(i, value); } else { DynamicValue val = new DynamicValue(); val.Add("Type", "string"); val.Add("Value", ""); dvEditableParameters.Add(i, val); } } T_Task newTask = new T_Task("S", context.GetValue(globalWFId), context.GetValue(Name),false, false, context.GetValue(isEndState), dvReadableParameters.ToString(), dvEditableParameters.ToString(), context.GetValue(toSubject), context.GetValue(OrderId));//, 0, ""); WorkflowManagementClient client = new WorkflowManagementClient(new Uri(context.GetValue(cfgManagementScopeAddress)), credentials); client.PublishNotification(newTask.toWorkflowNotification()); }
public override object CreateValue(ISymbol symbol, byte[] rawData, int offset, IValue parent) { object obj2 = null; IDataType dataType = symbol.DataType; IResolvableType type2 = symbol.DataType as IResolvableType; if (type2 != null) { dataType = type2.ResolveType(DataTypeResolveStrategy.AliasReference); } if (base.mode.HasFlag(ValueCreationMode.FullDynamics) || !dataType.IsPrimitive) { if (!symbol.IsReference) { obj2 = !symbol.IsPointer ? new DynamicValue((IDynamicSymbol)symbol, rawData, offset, (DynamicValue)parent) : new DynamicPointerValue((IDynamicSymbol)symbol, rawData, offset, (DynamicValue)parent); } else { byte[] buffer; DateTime time; IAccessorDynamicValue accessor = base.accessor as IAccessorDynamicValue; if ((accessor != null) && (accessor.TryReadValue(symbol, out buffer, out time) == 0)) { obj2 = new DynamicReferenceValue((IDynamicSymbol)symbol, buffer, 0, (DynamicValue)parent); } } } else if ((dataType.Category == DataTypeCategory.Enum) && base.mode.HasFlag(ValueCreationMode.Enums)) { obj2 = EnumValueFactory.Create((IEnumType)dataType, rawData, offset); } else if (base.mode.HasFlag(ValueCreationMode.Default)) { base.valueConverter.Unmarshal(symbol, rawData, offset, out obj2); } else { obj2 = new DynamicValue((IDynamicSymbol)symbol, rawData, offset, (DynamicValue)parent); } return(obj2); }
private static DynamicValue GetValidValue(ModelItem item, DynamicValue id) { if (item.Parent != null) { //IEnumerable<DynamicValue> validValues = item.Parent.GetValidValues(); //if (validValues.Any()) //{ // try // { // return (from v in validValues // where v.Equals(id) // select v).First(); // } // catch (InvalidOperationException) // { // return default(DynamicValue); // } //} } return(default(DynamicValue)); }
//private void cmdSave_Click(object sender, EventArgs e) //{ // try // { // List<DynamicField> lstFields = new List<DynamicField>(); // List<DynamicValue> lstValues = new List<DynamicValue>(); // foreach (GridEXRow _row in grdList.GetDataRows()) // { // DynamicField obj = null; // DynamicValue objVal = null; // if (Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1) > 0) // { // obj = DynamicField.FetchByID(Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1)); // obj.IsNew = false; // obj.MarkOld(); // } // else // { // obj = new DynamicField(); // obj.IsNew = true; // } // if (Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1) > 0) // { // objVal = DynamicValue.FetchByID(Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1)); // objVal.IsNew = false; // objVal.MarkOld(); // } // else // { // objVal = new DynamicValue(); // objVal.IsNew = true; // } // obj.Id = Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1); // obj.Ma = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1"); // obj.Bodypart = objDichvuchitiet.Bodypart; // obj.Viewposition = objDichvuchitiet.ViewPosition; // objVal.Id = Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1); // objVal.Ma = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1"); // obj.Mota = Utility.sDbnull(_row.Cells[DynamicField.Columns.Mota].Value, "-1"); // objVal.Giatri = Utility.sDbnull(_row.Cells[DynamicValue.Columns.Giatri].Value, "-1"); // objVal.ImageId = ImageID; // objVal.IdChidinhchitiet = Id_chidinhchitiet; // lstFields.Add(obj); // lstValues.Add(objVal); // } // ActionResult _actionResult = UpdateDynamicValues(lstFields, lstValues); // if (_actionResult == ActionResult.Success) // { // this.Close(); // } // } // catch (Exception ex) // { // } //} private void cmdSave_Click(object sender, EventArgs e) { try { List <DynamicValue> lstValues = new List <DynamicValue>(); foreach (GridEXRow _row in grdList.GetDataRows()) { DynamicValue objVal = null; if (Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1) > 0) { objVal = DynamicValue.FetchByID(Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1)); objVal.IsNew = false; objVal.MarkOld(); } else { objVal = new DynamicValue(); objVal.IsNew = true; } objVal.Id = Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1); objVal.Ma = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1"); objVal.Giatri = Utility.sDbnull(_row.Cells[DynamicValue.Columns.Giatri].Value, "-1"); objVal.ImageId = ImageID; objVal.IdChidinhchitiet = Id_chidinhchitiet; lstValues.Add(objVal); } ActionResult _actionResult = UpdateDynamicValues(lstValues); if (_actionResult == ActionResult.Success) { this.Close(); } } catch (Exception ex) { } }
private IEnumerator Gather(Resource resource, DynamicValue delayedTime) { if (resource.TryCollecting(ActiveTool != null ? ActiveTool.Tool : null)) { Animator.SetTrigger("hit"); yield return(new WaitForSeconds(0.1f)); float animationTime = MecanimUtil.GetActiveAnimationDuration(Animator, 0); yield return(new WaitForSeconds(animationTime * 0.8f)); Resource.GatheringDrop gatheringDrop = resource.Gather(out ResourceItem item); switch (gatheringDrop) { case Resource.GatheringDrop.SpawnInWorld: ItemInWorld.CreateItem(item, transform.position + transform.up * 1.8f); break; case Resource.GatheringDrop.DirectlyIntoInventory: if (Inventory.CapacityLeft < item.TotalWeight && Inventory.Add(item) == false) { goto case Resource.GatheringDrop.SpawnInWorld; } break; default: Debug.LogError("case " + gatheringDrop + " not found!"); break; } delayedTime.SetValue(new DelayedTime(true, animationTime * 0.2f + 1)); } else { Animator.SetTrigger("fail"); yield return(new WaitForSeconds(0.1f)); float animationTime = MecanimUtil.GetActiveAnimationDuration(Animator, 0) + 1; delayedTime.SetValue(new DelayedTime(true, animationTime)); } }
/// <inheritdoc /> public void AddNote(int track, int start, int length, byte key, DynamicValue dynamicValue, byte channel) { var velocity = MidiUtils.DynamicToVelocity(dynamicValue); var noteOn = new MidiEvent(start, MakeCommand((byte)MidiEventType.NoteOn, channel), FixValue(key), FixValue((byte)velocity), true, channel); _midiFile.AddEvent(noteOn); var noteOff = new MidiEvent(start + length, MakeCommand((byte)MidiEventType.NoteOff, channel), FixValue(key), FixValue((byte)velocity), true, channel); _midiFile.AddEvent(noteOff); }
public PrompterPrepareResult Prepare(string sTemplateName, DynamicValue[] ahDinamicValues) { string sTemplateFile = ""; switch (sTemplateName) { case "prompter": sTemplateFile = "c:/cues/scr/prompter.xml"; break; default: throw new Exception("неизвестный шаблон"); } if (!System.IO.File.Exists(sTemplateFile)) throw new System.IO.FileNotFoundException("отсутствует файл шаблона [" + sTemplateFile + "]"); _cPrompterTemplate = new TemplatePrompter(sTemplateFile); _cPrompterTemplate.RuntimeGet = (sRuntime) => { return ahDinamicValues.First(row => row.sName == sRuntime).sValue; }; _cPrompterTemplate.MacroExecute = (sMacro) => { return ahDinamicValues.First(row => row.sName == sMacro).sValue; }; _cPrompterTemplate.ParseDone += new userspace.Template.ParseDoneDelegate(cPrompterTemplate_ParseDone); _cPrompterTemplate.Prepare(); int nHash=_cPrompterTemplate.GetHashCode(); PrompterPrepareResult cRetVal = new PrompterPrepareResult() { nTemplatesHashCode = nHash, aSplittedText = _cPrompterTemplate.aSplittedText.ToArray() }; return cRetVal; }
protected override void Execute(CodeActivityContext context) { DynamicValue data = context.GetValue(this.Data); DynamicValue transition = new DynamicValue(); data.TryGetValue("recipient", out transition); context.SetValue(Recipient, transition.ToString()); data.Remove("recipient"); DynamicValue variables = context.GetValue(GlobalVariables); foreach (string i in data.Keys) { DynamicValue value = new DynamicValue(); data.TryGetValue(i, out value); if (variables.ContainsKey(i)) { variables.Remove(i); } variables.Add(i, value); } context.SetValue(GlobalVariables, variables); }
private static string InternalExecute(string rootName, DynamicValue value, System.Xml.XmlWriterSettings settings) { var xdoc = new XDocument(new XDeclaration("1.0", settings.Encoding.WebName, "yes"), new XElement(rootName, new XAttribute(XNamespace.Xmlns.GetName("xsd"), XNamespace.Get("http://www.w3.org/2001/XMLSchema").NamespaceName), new XAttribute(XNamespace.Xmlns.GetName("xsi"), XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance").NamespaceName))); BuildFromValue(xdoc.Root, value); using (var ms = new System.IO.MemoryStream()) { using (var xw = System.Xml.XmlTextWriter.Create(ms, settings)) { xdoc.Save(xw); xw.Flush(); } using (var sr = new System.IO.StreamReader(ms)) { ms.Seek(0, System.IO.SeekOrigin.Begin); return(sr.ReadToEnd()); } } }
public GameEvent(GameEvent gEvent) { name = gEvent.name; ID = gEvent.ID; useSubEventMessages = gEvent.useSubEventMessages; scenario = gEvent.scenario; oddsOfOccuring = new DynamicValue(gEvent.oddsOfOccuring); StartingCondition = new EventConditionGroup(gEvent.StartingCondition); ContinualCondition = new EventConditionGroup(gEvent.ContinualCondition); FamilyCondition = new FamilyConditionGroup(gEvent.FamilyCondition); MaxOccurencePerPlaythrough = new DynamicValue(gEvent.MaxOccurencePerPlaythrough); Occurence = gEvent.Occurence; Duration = gEvent.Duration; startingMessage = new string[gEvent.startingMessage.Length]; for (int i = 0; i < startingMessage.Length; i++) { startingMessage[i] = gEvent.startingMessage[i]; } endingMessage = new string[gEvent.endingMessage.Length]; for (int i = 0; i < endingMessage.Length; i++) { endingMessage[i] = gEvent.endingMessage[i]; } modifers = new GameValueModifer[gEvent.modifers.Length]; for (int i = 0; i < modifers.Length; i++) { modifers[i] = new GameValueModifer(gEvent.modifers[i]); } subEvents = new SubEvent[gEvent.subEvents.Length]; for (int i = 0; i < subEvents.Length; i++) { subEvents[i] = new SubEvent(gEvent.subEvents[i]); } }
public static object UnmarshalViaMPSharp(Type t, DynamicValue dv) { using (var ms = new MemoryStream(dv.Msgpack.ToArray())) { _log.LogDebug($"parsing MsgPack as [{t.FullName}]"); var mpo = MPReader.Parse(ms); if (mpo == null) { throw new InvalidDataException("premature EOF"); } _log.LogTrace("Unmarshalled to MPOjbject:"); Visit(mpo.Value, (l, s) => _log.LogTrace("MPVisitor: {0}", s)); if (MPReader.Parse(ms) != null) { _log.LogWarning("DynamicValue message pack stream has more to read -- UNEXPECTED!!"); } return(WithNullsConverterContext.Decode(t, mpo.Value)); } }
/// <summary> /// Set taskanswer for a send-state task /// </summary> /// <param name="taskId">Id of the task</param> /// <param name="recipientName">choosen recipient/s</param> /// <param name="editableParameters">edited parameters</param> public void submitSendTaskAnswer(int taskId, string recipientName, string editableParameters, string username) { IProcessStore processStore = StoreHandler.getProcessStore(connectionString); ITaskStore taskStore = StoreHandler.getTaskStore(connectionString); T_Task openTask = taskStore.getTaskById(taskId); //check if task isn't already answered if (openTask.Done == false && openTask.Type.Equals("S")) { P_ProcessSubject processSubject = processStore.getProcessSubjectForWFId(openTask.WFId); P_Process process = processStore.getProcess(processSubject.Process_Id); DynamicValue val = DynamicValue.Parse(editableParameters); val.Add("recipient", new DynamicValue(recipientName)); submitTaskAnswer(val, process, openTask); //set task as answered //taskStore.setTaskStatus(taskId, true); taskStore.setTaskStatus(taskId, username, editableParameters, recipientName); } }
public T Deserialize <T>(XElement element) where T : class, new() { var target = new T(); var properties = typeof(T).GetProperties(); foreach (var attribute in element.Attributes()) { var prop = properties.SingleOrDefault(_ => _.Name.EqualsIgnoreCase(attribute.Name.ToString())); if (prop != null) { object value = ValueFor(attribute); if (value == null) { continue; } if (prop.PropertyType == typeof(IDynamicValue)) { value = new DynamicValue(value.ToString()); } else if (value.GetType() != prop.PropertyType) { var type = prop.PropertyType; if (type.Closes(typeof(Nullable <>))) { type = type.GetGenericArguments()[0]; } value = Convert.ChangeType(value, type); } prop.SetValue(target, value); } } return(target); }
public override void Update() { if (dynamicValue == null) { if (PreConditionCheck() == false) { return; } dynamicValue = GetDynamicValue(); } else // equipEvent is not null { if (timer == -1) // if the dynamicValue was not sel already { if (dynamicValue.TryGetValue(out equipEvent)) { timer = equipEvent.timeToEquip; } } else { // timer is not -1 timer -= Time.deltaTime; if (timer < 0) { if (equipEvent.wasSuccessful) { CurrentStatus = Status.Success; } else { CurrentStatus = Status.Failure; } } } } }
void ModelItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { // If left-hand operand changed, check if it become a feature property having valid values, e.g. Domain Attribute if (e.PropertyName == IMConstants.LeftOperandPropertyName) { IEnumerable <DynamicValue> validValues = ModelItem.Properties[IMConstants.RightOperandPropertyName].Value.GetValidValues(); ModelProperty rightOperand = ModelItem.Properties[IMConstants.RightOperandPropertyName]; // if expression like "1 equals 1" becomes "status equals 1", the right-hand operand should be refresh. // if expression like "Status equals new" becomes "1 equals new", the right-hand operand should be refresh, too. if (validValues.Any()) { // TODO: refactor to remove redundant code. DynamicValue dv = validValues.First(); rightOperand.SetValue(DynamicLiteral.CreateArgument(dv.Value)); _hasValidValues = true; } else if (_hasValidValues) { rightOperand.SetValue(DynamicLiteral.CreateArgument(IMConstants.DefaultNumberValue)); _hasValidValues = false; } } }
private static MusicFontSymbol GetSymbol(DynamicValue dynamics) { switch (dynamics) { case DynamicValue.PPP: return MusicFontSymbol.DynamicPPP; case DynamicValue.PP: return MusicFontSymbol.DynamicPP; case DynamicValue.P: return MusicFontSymbol.DynamicP; case DynamicValue.MP: return MusicFontSymbol.DynamicMP; case DynamicValue.MF: return MusicFontSymbol.DynamicMF; case DynamicValue.F: return MusicFontSymbol.DynamicF; case DynamicValue.FF: return MusicFontSymbol.DynamicFFF; case DynamicValue.FFF: return MusicFontSymbol.DynamicFFF; default: return MusicFontSymbol.None; } }
public DynamicsGlyph(float x, float y, DynamicValue dynamics) : base(x, y) { _dynamics = dynamics; }
public void DateTimeInEqualityOperatorTest() { var date1 = new DateTime(2012, 11, 10, 10, 10, 10); var date2 = new DateTime(2012, 12, 10, 10, 10, 10); // LHS DynamicValue value = new DynamicValue(date1); Assert.IsTrue(value != date2, "Equality test Value == <Float> test failed."); // RHS Assert.IsTrue(date2 != value, "Equality test <Float> == Value test failed."); // Value var value2 = new DynamicValue(date2); Assert.IsTrue(value != value2, "Equality test Value == Value test failed."); }
public void FloatInEqualityOperatorTest() { // LHS DynamicValue value = new DynamicValue(10f); Assert.IsTrue(value != 12f, "Equality test Value == <Float> test failed."); // RHS Assert.IsTrue(12f != value, "Equality test <Float> == Value test failed."); // Value var value2 = new DynamicValue(12f); Assert.IsTrue(value != value2, "Equality test Value == Value test failed."); }
public void FloatEqualityOperatorTest() { // As integer // LHS DynamicValue value = new DynamicValue(10f); Assert.IsTrue(value == 10f, "Equality test Value == <Float> test failed."); // RHS Assert.IsTrue(10f == value, "Equality test <Float> == Value test failed."); // Value var value2 = new DynamicValue(10f); Assert.IsTrue(value == value2, "Equality test Value == Value test failed."); }
//private void cmdSave_Click(object sender, EventArgs e) //{ // try // { // List<DynamicField> lstFields = new List<DynamicField>(); // List<DynamicValue> lstValues = new List<DynamicValue>(); // foreach (GridEXRow _row in grdList.GetDataRows()) // { // DynamicField obj = null; // DynamicValue objVal = null; // if (Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1) > 0) // { // obj = DynamicField.FetchByID(Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1)); // obj.IsNew = false; // obj.MarkOld(); // } // else // { // obj = new DynamicField(); // obj.IsNew = true; // } // if (Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1) > 0) // { // objVal = DynamicValue.FetchByID(Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1)); // objVal.IsNew = false; // objVal.MarkOld(); // } // else // { // objVal = new DynamicValue(); // objVal.IsNew = true; // } // obj.Id = Utility.Int32Dbnull(_row.Cells[DynamicField.Columns.Id].Value, -1); // obj.Ma = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1"); // obj.Bodypart = objDichvuchitiet.Bodypart; // obj.Viewposition = objDichvuchitiet.ViewPosition; // objVal.Id = Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1); // objVal.Ma = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1"); // obj.Mota = Utility.sDbnull(_row.Cells[DynamicField.Columns.Mota].Value, "-1"); // objVal.Giatri = Utility.sDbnull(_row.Cells[DynamicValue.Columns.Giatri].Value, "-1"); // objVal.ImageId = ImageID; // objVal.IdChidinhchitiet = Id_chidinhchitiet; // lstFields.Add(obj); // lstValues.Add(objVal); // } // ActionResult _actionResult = UpdateDynamicValues(lstFields, lstValues); // if (_actionResult == ActionResult.Success) // { // this.Close(); // } // } // catch (Exception ex) // { // } //} private void cmdSave_Click(object sender, EventArgs e) { try { List<DynamicValue> lstValues = new List<DynamicValue>(); foreach (GridEXRow _row in grdList.GetDataRows()) { DynamicValue objVal = null; if (Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1) > 0) { objVal = DynamicValue.FetchByID(Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1)); objVal.IsNew = false; objVal.MarkOld(); } else { objVal = new DynamicValue(); objVal.IsNew = true; } objVal.Id = Utility.Int32Dbnull(_row.Cells["idValue"].Value, -1); objVal.Ma = Utility.sDbnull(_row.Cells[DynamicField.Columns.Ma].Value, "-1"); objVal.Giatri = Utility.sDbnull(_row.Cells[DynamicValue.Columns.Giatri].Value, "-1"); objVal.ImageId = ImageID; objVal.IdChidinhchitiet = Id_chidinhchitiet; lstValues.Add(objVal); } ActionResult _actionResult = UpdateDynamicValues(lstValues); if (_actionResult == ActionResult.Success) { this.Close(); } } catch (Exception ex) { } }
public void BoolEqualityOperatorTest() { // As integer // LHS DynamicValue value = new DynamicValue(true); Assert.IsTrue(value == true, "Equality test Value == <bool> test failed."); // RHS Assert.IsTrue(true == value, "Equality test <bool> == Value test failed."); // Value var value2 = new DynamicValue(true); Assert.IsTrue(value == value2, "Equality test Value == Value test failed."); }
public void ImplicitDoubleConversionTest() { var data = 10d; var value = new DynamicValue(data); double result = value; Assert.IsTrue(result == data, "Value to " + data.GetType().Name + " conversion failed."); DynamicValue value2 = data; Assert.IsTrue(data.ToString() == value2.StringValue, data.GetType().Name + " to value conversion failed."); }
public void ImplicitDateConversionTest() { var value = new DynamicValue("2010-10-10"); DateTime date = value; Assert.IsTrue(date == new DateTime(2010,10,10)); }
public void ImplicitTimeConversionTest() { var value = new DynamicValue("10:45:35.1234567"); DateTime date = value; }