Beispiel #1
0
        /// <summary>
        /// Returns model by GUID
        /// </summary>
        /// <param name="modelGuid">Identifier of the requested model.</param>
        /// <returns>Found <see cref="ModelBase"/> object.</returns>
        public ModelBase GetModelInternal(Guid modelGuid)
        {
            ModelBase foundModel = (Connectors.FirstOrDefault(c => c.GUID == modelGuid)
                                    ?? Nodes.FirstOrDefault(node => node.GUID == modelGuid) as ModelBase)
                                   ?? (Notes.FirstOrDefault(note => note.GUID == modelGuid)
                                       ?? Annotations.FirstOrDefault(annotation => annotation.GUID == modelGuid) as ModelBase
                                       ?? Presets.FirstOrDefault(preset => preset.GUID == modelGuid) as ModelBase);

            return(foundModel);
        }
Beispiel #2
0
        public Declaration(
            QualifiedMemberName qualifiedName,
            Declaration parentDeclaration,
            string parentScope,
            string asTypeName,
            string typeHint,
            bool isSelfAssigned,
            bool isWithEvents,
            Accessibility accessibility,
            DeclarationType declarationType,
            ParserRuleContext context,
            Selection selection,
            bool isArray,
            VBAParser.AsTypeClauseContext asTypeContext,
            bool isBuiltIn = false,
            IEnumerable <IAnnotation> annotations = null,
            Attributes attributes = null)
        {
            _qualifiedName          = qualifiedName;
            _parentDeclaration      = parentDeclaration;
            _parentScopeDeclaration = _parentDeclaration;
            _parentScope            = parentScope ?? string.Empty;
            _identifierName         = qualifiedName.MemberName;
            _asTypeName             = asTypeName;
            _isSelfAssigned         = isSelfAssigned;
            _isWithEvents           = isWithEvents;
            _accessibility          = accessibility;
            _declarationType        = declarationType;
            _selection   = selection;
            _context     = context;
            _isBuiltIn   = isBuiltIn;
            _annotations = annotations;
            _attributes  = attributes ?? new Attributes();

            _projectId = _qualifiedName.QualifiedModuleName.ProjectId;

            var    @namespace = Annotations.FirstOrDefault(annotation => annotation.AnnotationType == AnnotationType.Folder);
            string result;

            if (@namespace == null)
            {
                result = _qualifiedName.QualifiedModuleName.Project == null
                    ? _projectId
                    : _qualifiedName.QualifiedModuleName.Project.Name;
            }
            else
            {
                var value = ((FolderAnnotation)@namespace).FolderName;
                result = value;
            }
            _customFolder  = result;
            _isArray       = isArray;
            _asTypeContext = asTypeContext;
            _typeHint      = typeHint;
        }
        private string FolderFromAnnotations()
        {
            var    folderAnnotation = Annotations.FirstOrDefault(pta => pta.Annotation is FolderAnnotation);
            string result;

            if (folderAnnotation == null)
            {
                return(string.IsNullOrEmpty(QualifiedName.QualifiedModuleName.ProjectName)
                    ? ProjectId
                    : QualifiedName.QualifiedModuleName.ProjectName);
            }

            var folderValue = folderAnnotation.AnnotationArguments.FirstOrDefault();

            return(folderValue?.FromVbaStringLiteral() ?? "");
        }
Beispiel #4
0
        private string FolderFromAnnotations()
        {
            var    @namespace = Annotations.FirstOrDefault(annotation => annotation.AnnotationType == AnnotationType.Folder);
            string result;

            if (@namespace == null)
            {
                result = string.IsNullOrEmpty(QualifiedName.QualifiedModuleName.ProjectName)
                        ? ProjectId
                        : QualifiedName.QualifiedModuleName.ProjectName;
            }
            else
            {
                var value = ((FolderAnnotation)@namespace).FolderName;
                result = value;
            }
            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Adds or updates an annotation with the specified name and value.
        /// </summary>
        /// <remarks>
        /// If an annotation with the given name already exists then the value of that annotation
        /// is updated to the given value. If the given value is null then the annotation will be
        /// removed.
        /// </remarks>
        /// <param name="name">The name of the annotation property.</param>
        /// <param name="value">The value of the annotation property.</param>
        public void AddAnnotation(string name, object value)
        {
            Check.NotEmpty(name, "name");

            var existingAnnotation = Annotations.FirstOrDefault(a => a.Name == name);

            if (existingAnnotation != null)
            {
                if (value == null)
                {
                    RemoveAnnotation(name);
                }
                else
                {
                    existingAnnotation.Value = value;
                }
            }
            else if (value != null)
            {
                GetMetadataProperties().Add(MetadataProperty.CreateAnnotation(name, value));
            }
        }
Beispiel #6
0
        /// <summary>
        /// Returns model by GUID
        /// </summary>
        /// <param name="modelGuid">Identifier of the requested model.</param>
        /// <returns>Found <see cref="ModelBase"/> object.</returns>
        public ModelBase GetModelInternal(Guid modelGuid)
        {
            ModelBase foundModel = (Connectors.FirstOrDefault(c => c.GUID == modelGuid)
                                    ?? Nodes.FirstOrDefault(node => node.GUID == modelGuid) as ModelBase)
                                   ?? (Notes.FirstOrDefault(note => note.GUID == modelGuid)
                                       ?? Annotations.FirstOrDefault(annotation => annotation.GUID == modelGuid) as ModelBase
                                       ?? Presets.FirstOrDefault(preset => preset.GUID == modelGuid) as ModelBase);

            if (foundModel is null)
            {
                foreach (var connector in Connectors)
                {
                    foreach (var pin in connector.ConnectorPinModels)
                    {
                        if (pin.GUID == modelGuid)
                        {
                            return(pin as ModelBase);
                        }
                    }
                }
            }

            return(foundModel);
        }
Beispiel #7
0
 private bool TryGetAnnotation(string annotationType, out ZipkinAnnotation annotation)
 {
     annotation = Annotations.FirstOrDefault(a => a.Value.Equals(annotationType));
     return(annotation != default(ZipkinAnnotation));
 }