public PriorityValue( AvaloniaObject owner, StyledPropertyBase <T> property, ValueStore store, IPriorityValueEntry <T> existing) : this(owner, property, store) { existing.Reparent(this); _entries.Add(existing); if (existing is IBindingEntry binding && existing.Priority == BindingPriority.LocalValue) { // Bit of a special case here: if we have a local value binding that is being // promoted to a priority value we need to make sure the binding is subscribed // even if we've got a batch operation in progress because otherwise we don't know // whether the binding or a subsequent SetValue with local priority will win. A // notification won't be sent during batch update anyway because it will be // caught and stored for later by the ValueStore. binding.Start(ignoreBatchUpdate: true); } var v = existing.GetValue(); if (v.HasValue) { _value = v; Priority = existing.Priority; } }
/// Initializes Aquabot. Basically, it hooks controls /// and creates the value storage database to track controls changes. static ValueStore Init(Form f, Lane lane) { ValueStore values = new ValueStore(); HookCtrls(f, values, lane); return(values); }
protected override void Perform(BooterHelper.BootFile file, XmlDbRow row) { TunableStore store = null; if (row.Exists("SubFieldName")) { store = new NestedStore(); } else if (row.Exists("Index")) { store = new ArrayValueStore(); } else { store = new ValueStore(); } if (!store.Parse(row)) { return; } SettingsKey key = ParseKey(row); if (key is GeneralKey) { store.Apply(key); } Add(key, store); }
/// <summary> /// Create or update the main runtime profile with the appropriate value store. /// </summary> static void CreateOrUpdateMainRuntimeProfile() { if (!Application.isPlaying) { Debug.LogError("Cannot create main runtime profile when not playing."); return; } ValueStore currentStore = null; if (Instance.EditorSourceProfile != null) { currentStore = Instance.EditorSourceProfile.Store; } else if (Instance.PlayModeStore != null) { currentStore = Instance.PlayModeStore; } else { currentStore = Instance.store; } if (currentStore != null) { currentStore = currentStore.Clone(); } RuntimeProfile.CreateMain(currentStore); RuntimeProfile.Main.CleanStore(); }
public Context(IContext context, IEnumerableVariableScope enumerableVariableScope) : this(context, default(IVariableScope)) { var variable = enumerableVariableScope.CurrentItemVariable; Variables.Add(variable); _values[variable] = new ValueStore(); }
public void CheckExistsData() { var valueStore = new ValueStore(); valueStore.Load(@"F:\DEV\featureLocalizer\config\valueStores"); Assert.AreEqual("##RU=Контрагенты;EN=Accounts##", valueStore.GetValueMacros("SectionCaption", "Контрагенты")); }
public void Captured() { var x = new object(); ValueStore store = new ValueStore(); Action action = () => store.SetValue(x); Func <Object> f = () => store.GetValue(); //Implicitly capture closure: x }
public void Consume(IEnumerable <DataRowEntity> rows, ValueStore valueStore) { if (_options == null) { throw new ArgumentNullException("Init was not called before calling consume"); } using (TextWriter writer = File.AppendText(OutputFolder + "\\output.csv")) { foreach (var row in rows) { StringBuilder sb = new StringBuilder(); foreach (var field in row.Fields) { if (field.ProducesValue) { valueStore.Put(field.KeyValue, identityCounter++); } var value = valueStore.GetByKey(field.KeyValue); sb.Append(value); Console.WriteLine(value); } writer.Write(sb.ToString()); rowCounter++; _reportInsertion(); writer.WriteLine(); } writer.Flush(); } }
public void ClearTest() { var store = new ValueStore(); IniAdapter.Load(store, ini); var node = store.AddRoot("Superfluous", "Value"); node.AddChild("Child", "Value"); var profile = new RuntimeProfile(); profile.Store = store; profile.CleanStore(); Assert.IsNull(profile.GetOption("Superfluous/Child")); Assert.IsNull(profile.GetOption("Superfluous")); var option = profile.GetOption("ParentDummy"); Assert.IsNotNull(option); Assert.IsTrue(option.Save() == "no"); option = profile.GetOption("ParentDummy/Child2:Child2Variant2/Child3/Child4/Child5:Default1"); Assert.IsNotNull(option); Assert.IsNotNull(option.Save() == "Child5Default1Value"); }
public void CheckNotExistsData() { var valueStore = new ValueStore(); valueStore.Load(@"F:\DEV\featureLocalizer\config\valueStores"); Assert.AreEqual(string.Empty, valueStore.GetValueMacros("SectionCaption1", "Контрагенты")); }
public void ShouldUseSameValueWhenUsingIdentityFromOtherColumn() { ValueStore valuestore = new ValueStore(); var dp = new DataProducer(valuestore); var tables = new List <ExecutionTable>(); tables.Add(new ExecutionTable(customerTable, 1)); tables.Add(new ExecutionTable(orderTable, 2)); List <DataRowEntity> rows = new List <DataRowEntity>(); long n = 1L; rows.AddRange(dp.ProduceRows(tables)); Assert.That(rows.Count, Is.EqualTo(2)); var customerRow = rows[0]; var orderRow = rows[1]; Assert.That(customerRow.Fields.Count, Is.EqualTo(4)); Assert.That(orderRow.Fields.Count, Is.EqualTo(4)); Assert.That(orderRow.Fields[1].FieldName, Is.EqualTo("CustomerId")); Assert.That(customerRow.Fields[0].FieldName, Is.EqualTo("CustomerId")); // Check key is the same as it is for the CustomerId column in CustomerRow Assert.That(orderRow.Fields[1].KeyValue, Is.EqualTo(customerRow.Fields[0].KeyValue)); }
public void ShouldGetNullFromValueStoreIfKeyDoesNotExist() { ValueStore valueStore = new ValueStore(); var value = valueStore.GetByKey(Guid.NewGuid()); Assert.That(value, Is.Null); }
public void ShouldProduceDataForAllTables() { ValueStore valuestore = new ValueStore(); var dp = new DataProducer(valuestore); var tables = new List <ExecutionTable>(); tables.Add(new ExecutionTable(customerTable, 1)); tables.Add(new ExecutionTable(orderTable, 2)); List <DataRowEntity> rows = new List <DataRowEntity>(); rows.AddRange(dp.ProduceRows(tables)); Assert.That(rows.Count, Is.EqualTo(2)); Assert.That(rows[0].Fields.Count, Is.EqualTo(4)); AssertFieldsInRowHaveSomeValues(valuestore, rows[0], 2); // simulate consuming and producing the identity value of CustomerId // this will cause the Order table to have a value for its CustomerId column valuestore.Put(rows[0].Fields[0].KeyValue, 1); Assert.That(rows[1].Fields.Count, Is.EqualTo(4)); AssertFieldsInRowHaveSomeValues(valuestore, rows[1], 0); }
public void ShouldProduceValuesForIdentityColumns() { ValueStore vs = new ValueStore(); DataProducer producer = new DataProducer(vs); DataRowEntity row = producer.ProduceRow(customerTable, 1); // check that the value of the identity column have not been generated Assert.That(vs.GetByKey(row.Fields[0].KeyValue), Is.Null); IDataConsumer consumer = GetImplementedType(); if (consumer.Init("", options)) { int counter = 0; consumer.ReportInsertionCallback = new Action(() => { counter++; }); consumer.Consume(new List <DataRowEntity> { row }, vs); // now assert that the identity value have been generated by the consumer Assert.That(row.Fields[0].FieldName, Is.EqualTo("CustomerId"), "Column should be customerID"); Assert.That(vs.GetByKey(row.Fields[0].KeyValue), Is.Not.Null, consumer.GetType().ToString()); } }
public void ShouldInsertLotsOfRows() { prepareTables(); using (SQLDataProducer.DataConsumers.DataToMSSSQLInsertionConsumer.InsertConsumer consumer = new DataConsumers.DataToMSSSQLInsertionConsumer.InsertConsumer()) { var valueStore = new ValueStore(); DataProducer producer = new DataProducer(valueStore); consumer.Init(connectionString, new Dictionary <string, string>()); int rowCount = 0; consumer.ReportInsertionCallback = new Action(() => { rowCount++; }); for (int i = 0; i < 150; i++) { consumer.Consume(producer.ProduceRows(new List <ExecutionTable> { new ExecutionTable(customerTable, 1), new ExecutionTable(orderTable, 2) }), valueStore); } Assert.That(rowCount, Is.EqualTo(300)); } verifyRowCount("Customer", 150); verifyRowCount("Orders", 150); }
private void Assign() { try { var canBeNull = !collectionItemType.GetTypeInfo().IsValueType || (Nullable.GetUnderlyingType(collectionItemType) != null); var listType = typeof(List <>); var constructedListType = listType.MakeGenericType(collectionItemType); var list = (IList)Activator.CreateInstance(constructedListType); foreach (var item in collection) { if (!canBeNull && item.Value == null) { continue; } list.Add(item.Value == NullEntry ? null : Convert.ChangeType(item.Value, collectionItemType ?? typeof(object))); } ValueStore.SetValue(list); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Assignment error: " + ex.Message); //System.Windows.MessageBox.Show("Assignment error: " + ex.Message); } }
protected override ValueStore GetStoreFromSource(IActiveValue <T> source) { var store = new ValueStore(source); store.ValueChanged += ValueChanged; return(store); }
private void Assign() { Error = string.Empty; try { var canBeNull = !collectionItemType.GetTypeInfo().IsValueType || (Nullable.GetUnderlyingType(collectionItemType) != null); var listType = typeof(List <>); var constructedListType = listType.MakeGenericType(collectionItemType); var list = (IList)Activator.CreateInstance(constructedListType); foreach (var item in collection) { if (item.ValueChanged == null) { item.ValueChanged = Assign; } if (!canBeNull && item.Value == null) { continue; } list.Add(Convert.ChangeType(item.Value, collectionItemType ?? typeof(object))); } ValueStore.SetValue(list); } catch (Exception ex) { Error = ex.Message; } Changed(() => Error); }
public EditBuildProfile(IEditorProfile profile, ValueStore store) : base(store) { foreach (var option in this) { option.SetEditorProfile(profile); } }
private static void AssertFieldsInRowHaveSomeValues(ValueStore valuestore, DataRowEntity row, int nullColumns) { var nullableFieldCounter = 0; foreach (var field in row.Fields) { var retreivedValue = valuestore.GetByKey(field.KeyValue); Console.WriteLine("{0}: {1}", field.KeyValue, retreivedValue); Assert.That(field.KeyValue, Is.Not.Null, field.FieldName); if (!field.ProducesValue) { Assert.That(retreivedValue, Is.Not.Null, field.FieldName); } else { Assert.That(retreivedValue, Is.Null, field.FieldName); } if (field.DataType.IsNullable) { nullableFieldCounter++; Assert.That(retreivedValue, Is.EqualTo(DBNull.Value)); } } Assert.That(nullableFieldCounter, Is.EqualTo(nullColumns)); }
/// Hook handlers to track changes. static void HookCtrls(Form f, Control ctrl, ValueStore values, Lane lane) { var t = ctrl.GetType(); if (t != typeof(Form)) { ctrl.LostFocus += (s, e) => { if (!lane.IsRecording) { return; } var c = (Control)s; if (HasChanged(c, values)) { CaptureInput(f, c, values, lane); } else { CaptureOther(f, values, lane); } }; } foreach (Control c in ctrl.Controls) { HookCtrls(f, c, values, lane); } }
// Use this for initialization void Start() { store = FindObjectOfType <ValueStore>(); cart = FindObjectOfType <cartinventory>(); thisbutton = GetComponent <Button>(); man = FindObjectOfType <HeadstoneMenu>(); thisbutton.onClick.AddListener(StoreHead); }
public Context(IWorkflow workflow) { Workflow = workflow; foreach (var argument in workflow.Arguments) { _values[argument] = new ValueStore(); } }
public string GenerateValuesStatement(DataRowEntity row, ValueStore valueStore) { return("VALUES (" + string.Join(", ", row.Fields .Where(x => x.ProducesValue == false) .Select(x => formatValue(x, valueStore))) + ")"); }
public void RegisterGlobalFunction(string name, LibraryFunction functionRef, int numberOfRequiredParameters) { ExternalFunctionRef extFuncRef = new ExternalFunctionRef(name, functionRef, numberOfRequiredParameters); // TODO: check for object redefinition ValueStore functionObject = state.RegisterGlobalObject(name); functionObject.Value = new ExternalFunctionRefValue(extFuncRef); }
void Start() { valueStore = GameObject.Find("ValueStore").GetComponent <ValueStore>(); sr = GetComponent <SpriteRenderer>(); if (valueStore.easterEggActive) { EasterEgg(); } }
int myCounter; //how many tiles have we instantiated? void Start() { myCounter = 0; cameraZoom = Camera.main.GetComponent <CameraZoom>(); //tileList = new List<Transform>(); valueStore = GameObject.Find("ValueStore").GetComponent <ValueStore>(); valueStore.SetStarted(); StartCoroutine("SpawnFloor"); }
public IValueStore <T> Create <T>(T actualValue, T storedValue, IEqualityComparer <T> equalityComparer, Action <T, T>?updateCallback = null) { var store = new ValueStore <T>(actualValue, storedValue, this, equalityComparer); #pragma warning disable CS8602 // Possible dereference of a null reference. This is checked, but not recognized by the compiler _updateCallbacks.Add(store, updateCallback != null ? ((object a, object b) => updateCallback((T)a, (T)b)) : (Action <object, object>?)null); #pragma warning restore CS8602 // Possible dereference of a null reference. return(store); }
override public void OnLSystemSet() { velValueKey = $"{lsys.Key}-vel"; velocityValueFilter.Init(ValueStore.Get(velValueKey, 0.5f)); speedValueKey = $"{lsys.Key}-speed"; speedValueFilter.Init(ValueStore.Get(velValueKey, 0.5f)); base.OnLSystemSet(); }
public PriorityValue( AvaloniaObject owner, StyledPropertyBase <T> property, ValueStore sink, LocalValueEntry <T> existing) : this(owner, property, sink) { _value = _localValue = existing.GetValue(BindingPriority.LocalValue); Priority = BindingPriority.LocalValue; }
/// Captures changes that were not produced by a user input. static void CaptureOther(Form f, ValueStore values, Lane lane) { foreach (Control c in f.Controls) { if (HasChanged(c, values)) { CaptureFrameOther(f, values, lane); } } }
private ValueStore GetStoreFromSource(int index, TSource source) { var value = _selector.Invoke(source); var store = new ValueStore(value) { Index = index }; store.ValueChanged += ValueChanged; return(store); }
public Context(IWorkflow workflow, IVariableScope variableScope) : this(workflow) { if (variableScope == null) return; foreach (var variable in variableScope.Variables) { Variables.Add(variable); _values[variable] = new ValueStore(); } }
void CheckEquality( ValueStore sut, object value, string secondKey, Guid id, int number ) { Assert.Empty( sut ); var key = id.ToString(); var composite = new Registration( key, value, secondKey ); sut.Add( composite ); sut.Add( new Registration( "asdfasdf", number ) ); var first = sut.Get( key ); Assert.NotNull( first ); Assert.Same( first, value ); var second = sut.Get( secondKey ); Assert.NotNull( second ); Assert.Same( second, value ); Assert.Same( first, second ); var third = sut.Get( "asdfasdf" ); Assert.Equal( number, third ); }