Beispiel #1
0
        public async Task <M <DataNodeName> > TryGetNodeAsync(ModelPaths modelPaths, Source source)
        {
            Log.Debug($"Get node for {source} in model {modelPaths}...");

            try
            {
                if (!TryGetParser(modelPaths, out IParser parser))
                {
                    return(Error.From($"File not supported: {modelPaths}"));
                }

                NodeDataSource nodeSource = new NodeDataSource(source.Text, source.LineNumber, source.Path);

                string nodeName = await parser.GetNodeAsync(modelPaths.ModelPath, nodeSource);

                if (nodeName == null)
                {
                    return(M.NoValue);
                }

                return((DataNodeName)nodeName);
            }
            catch (Exception e)
            {
                return(Error.From(e));
            }
        }
Beispiel #2
0
        public async Task <M <string> > TryGetNodeAsync(NodeDataSource source)
        {
            await Task.Yield();

            M result = CreateAssemblyParsers(true);

            if (result.IsFaulted)
            {
                return(result.Error);
            }

            foreach (AssemblyParser parser in assemblyParsers)
            {
                if (parser.TryGetNode(source.Path, out string nodeName))
                {
                    return(nodeName);
                }
            }

            string sourceFilePath = Path.GetDirectoryName(source.Path);

            foreach (AssemblyParser parser in assemblyParsers)
            {
                if (parser.TryGetNode(sourceFilePath, out string nodeName))
                {
                    return(GetParentName(nodeName));
                }
            }

            return(Error.From($"Failed to find node for {sourceFilePath}"));
        }
        /// <summary>
        /// Gets the type of the image on node.
        /// </summary>
        /// <returns>The image on node type.</returns>
        /// <param name="datasource">Datasource.</param>
        /// <param name="row">Row.</param>
        /// <param name="ob">Ob.</param>
        private NSImage GetImageOnNodeType(NodeDataSource datasource, nint row, VMPSCHighAvailabilityMainWindowController ob)
        {
            var collection = datasource.Entries;
            var isInfra    = false;

            if (collection != null)
            {
                var item = collection [(int)row];
                isInfra = (item.NodeType == VMPSCHighAvailability.Common.NodeType.Infrastructure);
            }
            return(isInfra
                                ? _ob.CachedImages [(int)ImageIndex.Infrastructure]
                                        : _ob.CachedImages [(int)ImageIndex.Management]);
        }
        private bool TryGetFilePath(IMemberDefinition member, out NodeDataSource source)
        {
            if (member is MethodDefinition method)
            {
                SequencePoint sequencePoint = method.DebugInformation.SequencePoints.ElementAtOrDefault(0);
                if (sequencePoint != null)
                {
                    source = ToFileLocation(sequencePoint);
                    return(true);
                }
            }

            return(TryGetFilePath(member.DeclaringType, out source));
        }
        private bool TryGetFilePath(TypeDefinition type, out NodeDataSource source)
        {
            foreach (MethodDefinition method in type.Methods)
            {
                SequencePoint sequencePoint = method.DebugInformation.SequencePoints.ElementAtOrDefault(0);
                if (sequencePoint != null)
                {
                    source = ToFileLocation(sequencePoint);
                    return(true);
                }
            }

            source = null;
            return(false);
        }
Beispiel #6
0
        public async Task <M <Source> > GetSourceAsync(ModelPaths modelPaths, DataNodeName nodeName)
        {
            Log.Debug($"Get source for {nodeName} in model {modelPaths}...");
            try
            {
                if (!TryGetParser(modelPaths, out IParser parser))
                {
                    return(Error.From($"File not supported: {modelPaths}"));
                }

                NodeDataSource source = await parser.GetSourceAsync(modelPaths.ModelPath, (string)nodeName);

                if (source == null)
                {
                    return(M.NoValue);
                }

                return(new Source(source.Path, source.Text, source.LineNumber));
            }
            catch (Exception e)
            {
                return(Error.From(e));
            }
        }