/*=========================*/ #endregion #region Constructors /*=========================*/ /// <summary> /// /// </summary> /// <param name="parentProperty"></param> /// <param name="inclusionType"></param> /// <param name="acceptedValues"></param> internal Dependency(IEntityProperty parentProperty, DependencyInclusionType inclusionType, object[] acceptedValues) { InclusionType = inclusionType; ParentProperty = parentProperty; AcceptedValues = new List <object>(acceptedValues); ValueChangedHandler = new EventHandler <ValueChangedEventArgs>(ParentValueChanged); }
public void Update(object entity, IEntityProperty[] activeProperties) { if (_entity == null) { _entity = entity; for (int i = 0; i < activeProperties.Length; i++) { _properties.Add(activeProperties[i], null); } } else { for (int i = 0; i < activeProperties.Length; i++) { object nothing; IEntityProperty property = activeProperties[i]; // Update the property value property.SetValue(_entity, property.GetValue(entity)); if (!_properties.TryGetValue(property, out nothing)) { _properties.Add(property, null); } } } TimeUpdated = DateTime.Now; }
/*=========================*/ #endregion #region Public Properties /*=========================*/ /// <summary> /// /// </summary> /// <param name="property"></param> /// <returns></returns> public Dependency this[IEntityProperty property] { get { return(_dependencies[property]); } }
public HandlerStackItem ProcessProperty(IEntityProperty property) { var tabs = this.GeneratorConfiguration.HierarchyStack.Count; var tabText = this.CurrentTabText; HandlerStackItem handlerStackItem; if (property.Facets.Length > 0) { var facetList = property.Facets.Select(f => string.Format("{0}[{1}]", tabText, f.AttributeCode)).ToMultiLineList(); var uiHierarchyPath = property.Facets.GetUIHierarchyPathList(generatorOptions.PrintMode); this.CurrentUIHierarchyPath = uiHierarchyPath; WriteLine(facetList, PrintMode.PrintFacetsOnly); WriteLine(uiHierarchyPath, PrintMode.PrintUIHierarchyPathOnly); } handlerStackItem = this.GeneratorConfiguration.HandleFacets(property); WriteLine("{0}{1} ({2})", PrintMode.All, tabText, property.Name, property.DataType.Name); this.GeneratorConfiguration.AddProperty(property); return(handlerStackItem); }
public MongoDbBucketSet(IMongoDbContext context, IDbSetOptions options) { Check.NotNull(context, nameof(context)); Context = context; if (options is BucketSetOptions bucketOptions) { if (bucketOptions.BucketSize < 1) { throw new ArgumentException($"Invalid bucket size of {bucketOptions.BucketSize}"); } BucketSize = bucketOptions.BucketSize; var property = EntityMapping.GetOrCreateDefinition(typeof(TSubEntity)).GetProperty(bucketOptions.EntityTimeProperty); if (property == null) { throw new ArgumentException($"Property {bucketOptions.EntityTimeProperty} doesn't exist on bucket item."); } if (property.PropertyType != typeof(DateTime)) { throw new ArgumentException($"Property {bucketOptions.EntityTimeProperty} on bucket item isn't of type DateTime"); } EntityTimeProperty = property; } else { throw new ArgumentException("Invalid DbSet options supplied", nameof(options)); } }
public AddToBucketCommand(TGroup group, TSubEntity subEntity, IEntityProperty entityTimeProperty, int bucketSize) { Group = group; SubEntity = subEntity; BucketSize = bucketSize; EntityTimeProperty = entityTimeProperty; }
internal QueryBase Sort(IEntityProperty property, SortOrder order) { this.SortingList.Add(new SortingDefinition() { Property = property, SortOrder = order }); return(this); }
/// <summary> /// Activates a function when a scalar property needs mapping. /// </summary> public Mapping <T> Map <V>(IEntityProperty <V> property, Action <MappingContext <V> > function) { this.SubMappings.Add(new Mapping <V>(this.EntitySpace) { Property = property, MappingFunction = function }); return(this); }
public override void OnInsert(object target, IEntityProperty property) { if (property.PropertyType != typeof(DateTime)) { throw new ArgumentException("Property is not of type DateTime"); } property.SetValue(target, DateTime.UtcNow); }
public bool OnBeforeCommit(IEntityProperty p0) { // Return true to cancel the commit for the given property. if (p0.Name ().Equals ("Age")) { return true; } return false; }
public bool OnBeforeCommit(IEntityProperty p0) { // Return true to cancel the commit for the given property. if (p0.Name().Equals("Age")) { return(true); } return(false); }
public Java.Lang.Object Apply(Java.Lang.Object p0) { IEntityProperty property = (IEntityProperty)p0; // if(property.Name().Equals("EmployeeType")) { // return new CustomEditor(dataForm, property); // } return(null); }
public Mapping <T> Map <V>(IEntityProperty <V> property, Action <PropertyMapping <V> > init) { var submapping = new PropertyMapping <V>(this) { Property = property }; this.SubMappings.Add(submapping); init(submapping); return(this); }
public IdentityDefinition Constrain <T>(IEntityProperty <T> property, Func <T, bool> checkIfValid) { if (this.Constraints == null) { this.Constraints = new Dictionary <IEntityProperty, Func <object, bool> >(); } this.Constraints.Add(property, obj => checkIfValid((T)obj)); return(this); }
protected override void UpdateEditor(EntityPropertyEditor editor, IEntityProperty property) { base.UpdateEditor(editor, property); Type editorType = editor.GetType(); if (typeof(DataFormDecimalEditor).IsAssignableFrom(editorType)) { var dfEditor = editor.JavaCast <DataFormIntegerEditor>(); dfEditor.ValueFormatter = new CustomValueFormatter(); } }
/// <summary> /// /// </summary> /// <param name="property"></param> public void Remove(IEntityProperty property) { if (!_dependencies.ContainsKey(property)) { throw new InvalidOperationException("There is no dependency for the specified property."); } Dependency dep = _dependencies[property]; _dependencies.Remove(property); // Release handler property.ValueChanged -= dep.ParentValueChanged; }
public bool Equals(IEntityProperty other) { if (other == null) { return(false); } return(EntityType == other.EntityType && IsKey == other.IsKey && ElementName == other.ElementName && FullPath == other.FullPath && PropertyType == other.PropertyType && PropertyInfo == other.PropertyInfo); }
public CustomEditor(RadDataForm dataForm, IEntityProperty property) : base(dataForm, dataForm.EditorsMainLayout, dataForm.EditorsHeaderLayout, Resource.Id.data_form_text_viewer_header, Resource.Layout.dataform_custom_editor, Resource.Id.custom_editor, dataForm.EditorsValidationLayout, property) { editorButton = (Button)EditorView; editorButton.SetOnClickListener(this); ((TextView)HeaderView).Text = property.Header; }
/// <summary> /// Maps a result set field to a scalar property. /// </summary> public Mapping <T> Map <V>(IEntityProperty <V> property, string field) { return(this.Map <V>(property, context => { if (context.Direction == MappingDirection.Inbound) { context.SetValue(context.GetField <V>(field)); } else { context.SetField(field, context.Target); } } )); }
public PopupEditor(RadDataForm dataForm, IEntityProperty property, FragmentManager fragmentManager) : base( dataForm, dataForm.EditorsMainLayout, dataForm.EditorsHeaderLayout, Resource.Id.data_form_text_viewer_header, Resource.Layout.dataform_popup_editor, Resource.Id.popup_editor, dataForm.EditorsValidationLayout, property) { this.editorButton = (Button)this.EditorView; this.editorButton.SetOnClickListener(this); ((TextView)this.HeaderView).Text = property.Header; this.fragmentManager = fragmentManager; this.InitPopupFragment(); }
public void ApplyMapping(IEntityDefinition definition, BsonClassMap classMap) { IEntityProperty idProperty = default; foreach (var property in definition.Properties) { if (property.PropertyInfo.GetCustomAttribute <KeyAttribute>() != null) { idProperty = property; break; } if (property.ElementName.Equals("id", StringComparison.InvariantCultureIgnoreCase)) { //We don't break here just in case another property has the KeyAttribute //We preference the attribute over the name match idProperty = property; } } if (idProperty is EntityProperty entityProperty) { classMap.MapIdMember(idProperty.PropertyInfo); entityProperty.IsKey = true; //Set an Id Generator based on the member type var idMemberMap = classMap.IdMemberMap; var memberType = BsonClassMap.GetMemberInfoType(idMemberMap.MemberInfo); if (memberType == typeof(string)) { idMemberMap.SetIdGenerator(StringObjectIdGenerator.Instance); definition.KeyGenerator = new EntityKeyGenerator(StringObjectIdGenerator.Instance); } else if (memberType == typeof(Guid)) { idMemberMap.SetIdGenerator(CombGuidGenerator.Instance); definition.KeyGenerator = new EntityKeyGenerator(CombGuidGenerator.Instance); } else if (memberType == typeof(ObjectId)) { idMemberMap.SetIdGenerator(ObjectIdGenerator.Instance); definition.KeyGenerator = new EntityKeyGenerator(ObjectIdGenerator.Instance); } } }
public Mapping <T> Map <V>(IEntityProperty <V> property, string field, Func <object, V> convertIn = null, Func <V, object> convertOut = null) { return(this.Map <V>(property, mapping => mapping .Do(context => { if (!context.HasField(field)) { return; } if (context.Direction == MappingDirection.Inbound) { context.Target = context.GetField <V>(field, convertIn); } else if (context.Direction == MappingDirection.Outbound) { context.SetField(field, convertOut == null ? context.Target : convertOut(context.Target)); } }) )); }
/*=========================*/ #endregion #region Public Methods /*=========================*/ /// <summary> /// /// </summary> /// <param name="property"></param> /// <param name="inclusionType"></param> /// <param name="acceptedValues"></param> /// <returns></returns> public Dependency Add(IEntityProperty property, DependencyInclusionType inclusionType, object[] acceptedValues) { if (_dependencies.ContainsKey(property)) { throw new ArgumentException(String.Format("A dependency already exists on property {0}.", property.InlineName), "property"); } // Circular dependency check if (property.GetParentDependency(_dependentProperty) != null) { throw new DependencyException(String.Format("Cannot add a dependency on {0} because it is in itself dependent on the current property {1}.", property.InlineName, _dependentProperty.InlineName)); } Dependency newDep = new Dependency(property, inclusionType, acceptedValues); _dependencies.Add(property, newDep); property.ValueChanged += newDep.ParentValueChanged; return(newDep); }
/// <summary> /// /// </summary> /// <param name="parentProperty"></param> /// <returns></returns> public Dependency GetParentDependency(IEntityProperty parentProperty) { // Check if there is a direct dependency Dependency direct = this.Dependencies[parentProperty]; if (direct != null) { return(direct); } foreach (Dependency dep in this.Dependencies) { // Recursively check the parent dependencies Dependency indirect = dep.ParentProperty.GetParentDependency(parentProperty); if (indirect != null) { return(indirect); } } // Nothing found return(null); }
public SubqueryTemplate ConditionalColumn(string columnAlias, string columnSyntax, IEntityProperty mappedProperty) { this.ConditionalColumns[columnAlias] = new SubqueryConditionalColumn() { ColumnAlias = columnAlias, ColumnSyntax = columnSyntax, Condition = subquery => subquery.SelectList.Count == 0 || subquery.SelectList.Contains(mappedProperty), MappedProperty = mappedProperty }; return(this); }
public SubqueryTemplate ConditionalColumn(string column, IEntityProperty mappedProperty) { return(ConditionalColumn(column, column, mappedProperty)); }
public void OnAfterCommit(IEntityProperty p0) { }
protected override EntityPropertyEditor GetCustomEditorForProperty(RadDataForm form, IEntityProperty nativeProperty, Telerik.XamarinForms.Input.DataForm.IEntityProperty property) { if (property.PropertyName == "Option") { return(new PopupEditor(form, nativeProperty, ((Activity)this.Context).FragmentManager)); } return(base.GetCustomEditorForProperty(form, nativeProperty, property)); }
public new InlineMapping <T> Map <V>(IEntityProperty <V> property, string field) { return((InlineMapping <T>)base.Map <V>(property, field)); }
public new InlineMapping <T> Map <V>(IEntityProperty <V> property, Action <PropertyMapping <V> > init) { return((InlineMapping <T>)base.Map <V>(property, init)); }
protected override void InitEditor(TKDataFormEditor editor, IEntityProperty property) { base.InitEditor(editor, property); var name = property.PropertyName; editor.Style.ImageViewSize = new CoreGraphics.CGSize(15, 15); editor.Style.AccessoryArrowSize = new CoreGraphics.CGSize(10, 15); editor.Style.AccessoryArrowStroke = new TKStroke(UIColor.FromRGB(199, 51, 57), 2); editor.Style.Insets = UIEdgeInsets.Zero; editor.Style.SeparatorLeadingSpace = 30; if (name != nameof(Reservation.GuestNumber) && name != nameof(Reservation.TableSection) && name != nameof(Reservation.TableNumber)) { editor.Style.TextLabelDisplayMode = TKDataFormEditorTextLabelDisplayMode.Hidden; var textLabelDef = editor.GridLayout.DefinitionForView(editor.TextLabel); editor.GridLayout.SetWidth(0, textLabelDef.Column.Int32Value); editor.Style.EditorOffset = new UIOffset(15, 0); } else { editor.Style.TextLabelOffset = new UIOffset(15, 0); } switch (name) { case nameof(Reservation.ReservationHolder): editor.Property.Image = new UIImage("DataForm_Guest_Name.png"); break; case nameof(Reservation.GuestNumber): editor.Property.Image = new UIImage("DataForm_Guest_Number.png"); editor.TintColor = UIColor.FromRGB(199, 51, 57); var stepperLabel = (editor as TKDataFormStepperEditor).ValueLabel; var labelDef = editor.GridLayout.DefinitionForView(stepperLabel); labelDef.ContentOffset = new UIOffset(-15, 0); stepperLabel.TextColor = UIColor.Black; break; case nameof(Reservation.HolderPhoneNumber): editor.Property.Image = new UIImage("DataForm_Phone_Number.png"); break; case nameof(Reservation.ReservationDate): editor.Property.Image = new UIImage("DataForm_Date.png"); (editor as TKDataFormInlineEditor).EditorValueLabel.TextColor = UIColor.Black; break; case nameof(Reservation.ReservationTime): property.Metadata.Position = 0; editor.Property.Image = new UIImage("DataForm_Time.png"); (editor as TKDataFormInlineEditor).EditorValueLabel.TextColor = UIColor.Black; break; case nameof(Reservation.TableSection): editor.Property.Image = new UIImage("DataForm_Section.png"); var sectionPickerEditor = editor as TKDataFormPickerViewEditor; var sectionValueLabel = sectionPickerEditor.EditorValueLabel; sectionValueLabel.TextColor = UIColor.Black; sectionValueLabel.TextAlignment = UITextAlignment.Right; sectionValueLabel.TextInsets = new UIEdgeInsets(0, 0, 0, 15); break; case nameof(Reservation.TableNumber): editor.Property.Image = new UIImage("DataForm_Table_Number.png"); var pickerEditor = editor as TKDataFormPickerViewEditor; var valueLabel = pickerEditor.EditorValueLabel; valueLabel.TextColor = UIColor.Black; valueLabel.TextAlignment = UITextAlignment.Right; valueLabel.TextInsets = new UIEdgeInsets(0, 0, 0, 15); break; case nameof(Reservation.OrderOrigin): var segmentedEditor = editor as TKDataFormSegmentedEditor; segmentedEditor.SegmentedControl.TintColor = UIColor.FromRGB(199, 51, 57); editor.Style.EditorOffset = new UIOffset(0, 0); editor.Style.SeparatorColor = new TKFill(); break; } }
public new Subquery Sort(IEntityProperty property, SortOrder order) { ThrowIfRoot(); return((Subquery)base.Sort(property, order)); }