private static void StoreDateTimeOffset(string fieldName, LazyDictionary <string, ItemField> d, DateTimeOffset dt) { //store the date d.AddOrUpdate(fieldName, new ItemField(dt.DateTime) { DataType = FieldDataType.DateTime }); //store the offset d.AddOrUpdate(fieldName + FixedIndexedFields.DateTimeOffsetSuffix, new ItemField(dt.Offset.TotalHours)); }
public override LazyDictionary <string, ItemField> GetValue(TypedEntity source) { var d = new LazyDictionary <string, ItemField>(); foreach (var a in source.Attributes) { if (a.Values.Count == 1) { StoreFieldValue(a.AttributeDefinition.AttributeType.SerializationType, FixedAttributeIndexFields.AttributePrefix + a.AttributeDefinition.Alias, a.DynamicValue, d); } else if (a.Values.Count > 1) { //we need to put multiple values in the index with dot notation foreach (var val in a.Values) { var key = FixedAttributeIndexFields.AttributePrefix + a.AttributeDefinition.Alias + "." + val.Key; StoreFieldValue(a.AttributeDefinition.AttributeType.SerializationType, key, val.Value, d); } } //put attribute alias/name/id in there FixedAttributeIndexFields.AddAttributeAlias(d, a); //FixedAttributeIndexFields.AddAttributeName(d, a); FixedAttributeIndexFields.AddAttributeId(d, a); } //Get the parent Id. //TODO: We should support all relation types in some magical way foreach (var r in source.RelationProxies.GetParentRelations(FixedRelationTypes.DefaultRelationType)) { d.AddOrUpdate(FixedIndexedFields.ParentId, new ItemField(r.Item.SourceId.Value.ToString())); } d.AddOrUpdate(FixedIndexedFields.SchemaId, new Lazy <ItemField>(() => new ItemField(source.EntitySchema.Id.Value.ToString())), (k, i) => new Lazy <ItemField>(() => new ItemField(source.EntitySchema.Id.Value.ToString()))); d.Add(FixedIndexedFields.SchemaAlias, new ItemField(source.EntitySchema.Alias)); d.AddOrUpdate(FixedIndexedFields.SchemaName, new ItemField(source.EntitySchema.Name)); d.AddOrUpdate(FixedIndexedFields.SchemaType, new ItemField(source.EntitySchema.SchemaType)); ExamineHelper.SetTimestampsOnEntityAndIndexFields(d, source); return(d); }
private void DeviceOnKeyEvent(object sender, ButtonEventArgs e) { if (e.IsDown) { var value = _pressedButtons.AddOrUpdate(e.Location, l => { var result = _globalContext.Services.TimerService.RegisterTimer(_globalContext.Options.LongPressTimeout, () => { DoButtonPressed(e.Location, ButtonEvent.LongPress); _pressedButtons.TryRemove(l, out _); }, true); result.Start(); return(result); }, null); } else { if (_pressedButtons.TryRemove(e.Location, out var token)) { token.Value.Stop(); } } DoButtonPressed(e.Location, e.IsDown?ButtonEvent.Down:ButtonEvent.Up); }
bool PerformDraw() { while (_scheduledTransitions.TryDequeue(out var drawElement)) { var secs = drawElement.TransitionInfo.Duration.TotalSeconds; if (secs == 0) { secs = DefaultDuration; } int steps = (int)(secs * FPS); var localElement = drawElement; var value = _currentTransitions.AddOrUpdate(drawElement.Location, location => { var transition = new InstantTransition(); return(new VisualEffectInfo(localElement.Location, transition, null, localElement.BitmapRepresentation, steps)); }, (location, info) => { if (info.Transition.HasNext && localElement.TransitionInfo.Type == TransitionType.Instant) { info.ReplaceLastBitmap(localElement.BitmapRepresentation); return(info); } else { var transition = GetTransition(localElement); var result = new VisualEffectInfo(localElement.Location, transition, info.Transition?.Current.Clone(), localElement.BitmapRepresentation, steps); info.Dispose(); return(result); } }); } var effectInfos = _currentTransitions.Values.Where(t => t.Transition.HasNext); _currentDrawElementsCache.Clear(); foreach (var effectInfo in effectInfos) { effectInfo.Transition.Next(); _currentDrawElementsCache.Add(new LayoutDrawElement(effectInfo.Location, effectInfo.Transition.Current)); } if (_currentDrawElementsCache.Any()) { _device.SetBitmaps(_currentDrawElementsCache); } return(_currentDrawElementsCache.Any()); }