Beispiel #1
0
        private void SetAssociatedSource(TargetSource value)
        {
            if (associatedSource != value)
            {
                associatedSource = value;

                if (associatedSource == TargetSource.DataSourceValue)
                {
                    AssociatedTarget = new Dynamics365DataSourceValue(this);
                }
                else if (associatedSource == TargetSource.LookupValue)
                {
                    AssociatedTarget = new Dynamics365LookupValue(this);
                }
                else if (associatedSource == TargetSource.UserProvidedValue)
                {
                    AssociatedTarget = new Dynamics365UserProvidedValue(this);
                }
                else
                {
                    AssociatedTarget = default(FieldValue);
                }

                RefreshBrowsableFields();
                OnPropertyChanged(nameof(AssociatedSource));
            }
        }
        /// <summary>
        /// Sets the TargetSource value and makes the appropriate properties browsable.
        /// </summary>
        /// <param name="value"></param>
        protected virtual void SetTargetSource(TargetSource value)
        {
            if (targetSource != value)
            {
                targetSource = value;

                if (targetSource == TargetSource.DataSourceValue)
                {
                    Target = new Dynamics365DataSourceValue(this);
                    CoreUtility.SetBrowsable(this, nameof(Target), true);
                }
                else if (targetSource == TargetSource.LookupValue)
                {
                    Target = new Dynamics365LookupValue(this);
                    CoreUtility.SetBrowsable(this, nameof(Target), true);
                }
                else if (targetSource == TargetSource.UserProvidedValue)
                {
                    Target = new Dynamics365UserProvidedValue(this);
                    CoreUtility.SetBrowsable(this, nameof(Target), true);
                }
                else
                {
                    Target = default(FieldValue);
                    CoreUtility.SetBrowsable(this, nameof(Target), false);
                }

                RefreshBrowsableFields();
                OnPropertyChanged(nameof(TargetSource));
                RefreshName();
                // todo - events if properties within target source change
            }
        }