Esempio n. 1
0
        private LanguageExpression GenerateScopedResourceId(ResourceSymbol resourceSymbol, ResourceScope?targetScope)
        {
            var typeReference = EmitHelpers.GetTypeReference(resourceSymbol);
            var nameSegments  = GetResourceNameSegments(resourceSymbol, typeReference);

            if (!context.ResourceScopeData.TryGetValue(resourceSymbol, out var scopeData))
            {
                return(ScopeHelper.FormatLocallyScopedResourceId(targetScope, typeReference.FullyQualifiedType, nameSegments));
            }

            return(ScopeHelper.FormatCrossScopeResourceId(this, scopeData, typeReference.FullyQualifiedType, nameSegments));
        }
Esempio n. 2
0
        private LanguageExpression GenerateScopedResourceId(ResourceSymbol resourceSymbol, ResourceScopeType?targetScope)
        {
            var typeReference = EmitHelpers.GetTypeReference(resourceSymbol);
            var nameSegments  = GetResourceNameSegments(resourceSymbol, typeReference);

            if (context.ResoureScopeData[resourceSymbol] is {} parentResourceSymbol)
            {
                // this should be safe because we've already checked for cycles by now
                var parentResourceId = GetUnqualifiedResourceId(parentResourceSymbol);

                return(ExpressionConverter.GenerateScopedResourceId(parentResourceId, typeReference.FullyQualifiedType, nameSegments));
            }

            return(ScopeHelper.FormatLocallyScopedResourceId(targetScope, typeReference.FullyQualifiedType, nameSegments));
        }
Esempio n. 3
0
        public LanguageExpression GetLocallyScopedResourceIdExpression(ResourceDeclarationSyntax resourceSyntax, ResourceTypeReference typeReference)
        {
            IEnumerable <LanguageExpression> nameSegments;

            if (typeReference.Types.Length == 1)
            {
                nameSegments = GetResourceNameExpression(resourceSyntax).AsEnumerable();
            }
            else
            {
                nameSegments = typeReference.Types.Select(
                    (type, i) => new FunctionExpression(
                        "split",
                        new LanguageExpression[] { GetResourceNameExpression(resourceSyntax), new JTokenExpression("/") },
                        new LanguageExpression[] { new JTokenExpression(i) }));
            }

            return(ScopeHelper.FormatLocallyScopedResourceId(
                       context.SemanticModel,
                       typeReference.FullyQualifiedType,
                       nameSegments));
        }