Exemple #1
0
        private void FillEntityNamesInList(IList <CompletionSet> completionSets, ITrackingSpan applicableTo, ConnectionIntellisenseData intellisenseData, bool isObjectTypeCode)
        {
            List <CrmCompletion> list = new List <CrmCompletion>();

            var entityList = intellisenseData.Entities.Values.OrderBy(e => e.IsIntersectEntity).ThenBy(e => e.EntityLogicalName).ToList();

            foreach (var entityData in entityList)
            {
                string entityDescription = CrmIntellisenseCommon.GetDisplayTextEntity(entityData);

                List <string> compareValues = CrmIntellisenseCommon.GetCompareValuesForEntity(entityData);

                var insertionText = entityData.EntityLogicalName;

                if (isObjectTypeCode)
                {
                    insertionText = entityData.ObjectTypeCode.ToString();
                }

                list.Add(CreateCompletion(entityDescription, insertionText, CrmIntellisenseCommon.CreateEntityDescription(entityData), _defaultGlyph, compareValues));
            }

            if (list.Count > 0)
            {
                completionSets.Add(new CrmCompletionSet(SourceNameMoniker, "All Entities", applicableTo, list, Enumerable.Empty <CrmCompletion>()));
            }
        }
        private void FillEntityNamesInList(IList <CompletionSet> completionSets, ITrackingSpan applicableTo, ConnectionIntellisenseDataRepository repository, bool isObjectTypeCode, bool withNone = false)
        {
            var connectionIntellisense = repository.GetEntitiesIntellisenseData();

            if (connectionIntellisense == null || connectionIntellisense.Entities == null)
            {
                return;
            }

            List <CrmCompletion> list = new List <CrmCompletion>();

            if (withNone)
            {
                list.Add(CreateCompletion("none - 0", "0", "none", _defaultGlyph, new[] { "none", "0" }));
            }

            var keys = connectionIntellisense.Entities.Keys.ToList();

            foreach (var entityName in keys.OrderBy(s => s))
            {
                var entityData = connectionIntellisense.Entities[entityName];

                string entityDescription = CrmIntellisenseCommon.GetDisplayTextEntity(entityData);

                List <string> compareValues = CrmIntellisenseCommon.GetCompareValuesForEntity(entityData);

                var insertionText = entityData.EntityLogicalName;

                if (isObjectTypeCode)
                {
                    insertionText = entityData.ObjectTypeCode.ToString();
                }

                list.Add(CreateCompletion(entityDescription, insertionText, CrmIntellisenseCommon.CreateEntityDescription(entityData), _defaultGlyph, compareValues));
            }

            if (list.Count > 0)
            {
                completionSets.Add(new CrmCompletionSet(SourceNameMonikerAllEntites, "All Entities", applicableTo, list, Enumerable.Empty <CrmCompletion>()));
            }
        }
Exemple #3
0
        private void FillAttributeReferencedEntities(IList <CompletionSet> completionSets, ITrackingSpan applicableTo, IEnumerable <EntityIntellisenseData> entities)
        {
            List <CrmCompletion> list = new List <CrmCompletion>();

            foreach (var entityData in entities)
            {
                if (entityData.Attributes != null)
                {
                    string entityDescription = CrmIntellisenseCommon.GetDisplayTextEntity(entityData);

                    if (!string.IsNullOrEmpty(entityData.EntityPrimaryIdAttribute) &&
                        entityData.Attributes != null &&
                        entityData.Attributes.ContainsKey(entityData.EntityPrimaryIdAttribute) &&
                        entityData.Attributes[entityData.EntityPrimaryIdAttribute].AttributeType == AttributeTypeCode.Uniqueidentifier
                        )
                    {
                        List <string> compareValues = CrmIntellisenseCommon.GetCompareValuesForEntity(entityData);
                        compareValues.Add(entityData.EntityPrimaryIdAttribute);

                        var insertText = string.Format("multi {0} {1}", entityData.EntityPrimaryIdAttribute, entityData.EntityLogicalName);

                        list.Add(CreateCompletion(CrmIntellisenseCommon.GetDisplayTextEntity(entityData), insertText, CrmIntellisenseCommon.CreateEntityDescription(entityData), _defaultGlyph, compareValues));
                    }

                    foreach (var attribute in entityData.Attributes
                             .Values
                             .Where(e => !string.Equals(e.LogicalName, entityData.EntityPrimaryIdAttribute, StringComparison.InvariantCultureIgnoreCase) && e.AttributeType == AttributeTypeCode.Uniqueidentifier)
                             .OrderBy(e => e.LogicalName)
                             )
                    {
                        List <string> compareValues = CrmIntellisenseCommon.GetCompareValuesForEntity(entityData);

                        CrmIntellisenseCommon.FillCompareValuesForAttribute(compareValues, attribute);

                        var insertText = string.Format("multi {0} {1}", entityData.EntityPrimaryIdAttribute, entityData.EntityLogicalName);

                        list.Add(CreateCompletion(CrmIntellisenseCommon.GetDisplayTextEntityAndAttribute(entityData, attribute), insertText, CrmIntellisenseCommon.CreateEntityAndAttributeDescription(entityData, attribute), _defaultGlyph, compareValues));
                    }
                }
            }

            if (list.Count > 0)
            {
                completionSets.Add(new CrmCompletionSet(SourceNameMoniker, "Entities", applicableTo, list, Enumerable.Empty <CrmCompletion>()));
            }
        }
        private void FillLinkedEntityNames(IList <CompletionSet> completionSets, ITrackingSpan applicableTo, ConnectionIntellisenseDataRepository repository, XElement currentXmlNode)
        {
            var entityName = GetParentEntityName(currentXmlNode);

            if (string.IsNullOrEmpty(entityName))
            {
                return;
            }

            var connectionIntellisense = repository.GetEntitiesIntellisenseData();

            if (connectionIntellisense == null || connectionIntellisense.Entities == null)
            {
                return;
            }

            var entityData = repository.GetEntityAttributeIntellisense(entityName);

            if (entityData == null)
            {
                return;
            }

            HashSet <string> linkedEntities = entityData.GetLinkedEntities(connectionIntellisense);

            List <CrmCompletion> list = new List <CrmCompletion>();

            foreach (var linkedEntityName in linkedEntities.OrderBy(s => s))
            {
                if (connectionIntellisense.Entities.ContainsKey(linkedEntityName))
                {
                    var linkedEntityData = connectionIntellisense.Entities[linkedEntityName];

                    string entityDescription = CrmIntellisenseCommon.GetDisplayTextEntity(linkedEntityData);

                    List <string> compareValues = CrmIntellisenseCommon.GetCompareValuesForEntity(linkedEntityData);

                    list.Add(CreateCompletion(entityDescription, linkedEntityData.EntityLogicalName, CrmIntellisenseCommon.CreateEntityDescription(linkedEntityData), _defaultGlyph, compareValues));
                }
            }

            if (list.Count > 0)
            {
                completionSets.Add(new CrmCompletionSet(SourceNameMonikerLinkedEntites, "Linked Entities", applicableTo, list, Enumerable.Empty <CrmCompletion>()));
            }
        }