public void LoadData(AttributeMetadata attr, bool isPrimaryIdAttribute, bool isPrimaryNameAttribute)
        {
            this.IsPrimaryIdAttribute   = isPrimaryIdAttribute;
            this.IsPrimaryNameAttribute = isPrimaryNameAttribute;

            if (attr.MetadataId.HasValue)
            {
                this.MetadataId = attr.MetadataId;
            }

            if (!string.IsNullOrEmpty(attr.LogicalName))
            {
                this.LogicalName = attr.LogicalName;
            }

            if (attr.DisplayName != null)
            {
                this.DisplayName = attr.DisplayName;
            }

            if (attr.Description != null)
            {
                this.Description = attr.Description;
            }

            if (attr.AttributeType.HasValue)
            {
                this.AttributeType = attr.AttributeType;
            }

            this.IsEntityNameAttribute = attr is EntityNameAttributeMetadata;

            if (attr is BooleanAttributeMetadata boolMetadata)
            {
                this.OptionSet = new OptionSetIntellisenseData(boolMetadata);
            }

            if (attr is EnumAttributeMetadata enumAttributeMetadata &&
                enumAttributeMetadata.OptionSet != null
                )
            {
                this.OptionSet = new OptionSetIntellisenseData(enumAttributeMetadata);
            }

            if (attr is LookupAttributeMetadata lookupAttributeMetadata)
            {
                if (lookupAttributeMetadata.Targets != null && lookupAttributeMetadata.Targets.Length > 0)
                {
                    this.Targets = new List <string>(lookupAttributeMetadata.Targets);
                }
            }
        }
        public void MergeDataFromDisk(AttributeIntellisenseData attr)
        {
            if (attr == null)
            {
                return;
            }

            if (!this.MetadataId.HasValue &&
                attr.MetadataId.HasValue)
            {
                this.MetadataId = attr.MetadataId;
            }

            if (string.IsNullOrEmpty(this.LogicalName) &&
                !string.IsNullOrEmpty(attr.LogicalName))
            {
                this.LogicalName = attr.LogicalName;
            }

            if (this.DisplayName == null &&
                attr.DisplayName != null)
            {
                this.DisplayName = attr.DisplayName;
            }

            if (this.Description == null &&
                attr.Description != null)
            {
                this.Description = attr.Description;
            }

            if (!this.AttributeType.HasValue &&
                attr.AttributeType.HasValue)
            {
                this.AttributeType = attr.AttributeType;
            }

            if (!this.IsPrimaryIdAttribute.HasValue &&
                attr.IsPrimaryIdAttribute.HasValue)
            {
                this.IsPrimaryIdAttribute = attr.IsPrimaryIdAttribute;
            }

            if (!this.IsPrimaryNameAttribute.HasValue &&
                attr.IsPrimaryNameAttribute.HasValue)
            {
                this.IsPrimaryNameAttribute = attr.IsPrimaryNameAttribute;
            }

            if (attr.IsEntityNameAttribute)
            {
                this.IsEntityNameAttribute = attr.IsEntityNameAttribute;
            }

            if (this.OptionSet == null &&
                attr.OptionSet != null)
            {
                this.OptionSet = attr.OptionSet;
            }

            if ((this.Targets == null || this.Targets.Count == 0) &&
                attr.Targets != null && attr.Targets.Count > 0)
            {
                this.Targets = attr.Targets;
            }
        }