public void NewAzureSBNamespaceGetsDefaultLocation()
        {
            // Setup
            Mock <ServiceBusClientExtensions> client      = new Mock <ServiceBusClientExtensions>();
            MockCommandRuntime         mockCommandRuntime = new MockCommandRuntime();
            string                     name     = "test";
            string                     location = "West US";
            NamespaceType              type     = NamespaceType.NotificationHub;
            NewAzureSBNamespaceCommand cmdlet   = new NewAzureSBNamespaceCommand()
            {
                Name           = name,
                CommandRuntime = mockCommandRuntime,
                NamespaceType  = type,
                Client         = client.Object,
                Location       = location
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace {
                Name = name, Region = location, NamespaceType = type
            };

            client.Setup(f => f.CreateNamespace(name, location, type, true)).Returns(expected);

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            ExtendedServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ExtendedServiceBusNamespace;

            Assert.Equal <ExtendedServiceBusNamespace>(expected, actual);
        }
Exemplo n.º 2
0
        private static IEnumerable <FunctionSymbol> GetAccessibleDecoratorFunctions(NamespaceType namespaceType, Symbol?enclosingDeclarationSymbol)
        {
            // Local function.
            IEnumerable <FunctionSymbol> GetAccessible(IEnumerable <FunctionSymbol> symbols, TypeSymbol targetType, FunctionFlags flags) =>
            symbols.Where(functionSymbol => functionSymbol.Overloads.Any(overload =>
                                                                         overload.Flags.HasFlag(flags) &&
                                                                         namespaceType.DecoratorResolver.TryGetDecorator(overload)?.CanAttachTo(targetType) == true));

            var knownDecoratorFunctions = namespaceType.DecoratorResolver.GetKnownDecoratorFunctions().Values;

            return(enclosingDeclarationSymbol switch
            {
                ParameterSymbol parameterSymbol => GetAccessible(knownDecoratorFunctions, parameterSymbol.Type, FunctionFlags.ParameterDecorator),
                VariableSymbol variableSymbol => GetAccessible(knownDecoratorFunctions, variableSymbol.Type, FunctionFlags.VariableDecorator),
                ResourceSymbol resourceSymbol => GetAccessible(knownDecoratorFunctions, resourceSymbol.Type, FunctionFlags.ResoureDecorator),
                ModuleSymbol moduleSymbol => GetAccessible(knownDecoratorFunctions, moduleSymbol.Type, FunctionFlags.ModuleDecorator),
                OutputSymbol outputSymbol => GetAccessible(knownDecoratorFunctions, outputSymbol.Type, FunctionFlags.OutputDecorator),

                /*
                 * The decorator is dangling if enclosingDeclarationSymbol is null. Return all decorator factory functions since
                 * we don't know which kind of declaration it will attach to.
                 */
                null => knownDecoratorFunctions,
                _ => Enumerable.Empty <FunctionSymbol>()
            });
Exemplo n.º 3
0
        public NamespaceSymbol(string name, IEnumerable <FunctionOverload> functionOverloads, IEnumerable <BannedFunction> bannedFunctions)
            : base(name)
        {
            var methodResolver = new FunctionResolver(functionOverloads, bannedFunctions);

            Type = new NamespaceType(name, Enumerable.Empty <TypeProperty>(), methodResolver);
        }
Exemplo n.º 4
0
 public ResourceType(NamespaceType declaringNamespace, ResourceTypeReference typeReference, ResourceScope validParentScopes, ITypeReference body)
     : base(typeReference.FormatName())
 {
     DeclaringNamespace = declaringNamespace;
     TypeReference      = typeReference;
     ValidParentScopes  = validParentScopes;
     Body = body;
 }
        public RegisterNamespaceTransactionBuilder SetRootNamespace(string name)
        {
            NamespaceType = NamespaceType.ROOT_NAMESPACE;
            SetNamespaceName(name);
            SetNamespaceId(new NamespaceId(name));

            return(Self());
        }
Exemplo n.º 6
0
 public ResourceType(NamespaceType declaringNamespace, ResourceTypeReference typeReference, ResourceScope validParentScopes, ITypeReference body, ImmutableHashSet <string> uniqueIdentifierProperties)
     : base(typeReference.FormatName())
 {
     DeclaringNamespace = declaringNamespace;
     TypeReference      = typeReference;
     ValidParentScopes  = validParentScopes;
     Body = body;
     UniqueIdentifierProperties = uniqueIdentifierProperties;
 }
 /// <summary>
 /// Initializes a new instance of the
 /// ServiceBusNamespaceCreateParameters class with required arguments.
 /// </summary>
 public ServiceBusNamespaceCreateParameters(string region, NamespaceType namespaceType)
     : this()
 {
     if (region == null)
     {
         throw new ArgumentNullException("region");
     }
     this.Region = region;
     this.NamespaceType = namespaceType;
 }
Exemplo n.º 8
0
            public ResourceType?TryGetDefinedType(NamespaceType declaringNamespace, ResourceTypeReference reference, ResourceTypeGenerationFlags flags)
            {
                if (resourceTypes.TryGetValue(reference) is not {
                } resourceType)
                {
                    return(null);
                }

                return(new(declaringNamespace, resourceType.TypeReference, resourceType.ValidParentScopes, resourceType.Body, UniqueIdentifierProperties));
            }
 /// <summary>
 /// Initializes a new instance of the
 /// ServiceBusNamespaceCreateParameters class with required arguments.
 /// </summary>
 public ServiceBusNamespaceCreateParameters(string region, NamespaceType namespaceType)
     : this()
 {
     if (region == null)
     {
         throw new ArgumentNullException("region");
     }
     this.Region        = region;
     this.NamespaceType = namespaceType;
 }
        public RegisterNamespaceTransactionBuilder SetSubNamespace(NamespaceId parentId, string name)
        {
            NamespaceType = NamespaceType.SUB_NAMESPACE;
            SetNamespaceName(name);
            SetParentId(parentId);
            var subNamespace = IdGenerator.GenerateSubNamespaceIdFromParentId(parentId.Id, name);

            SetNamespaceId(new NamespaceId(subNamespace));

            return(Self());
        }
Exemplo n.º 11
0
        internal static string ToSerializedValue(this NamespaceType value)
        {
            switch (value)
            {
            case NamespaceType.Messaging:
                return("Messaging");

            case NamespaceType.NotificationHub:
                return("NotificationHub");
            }
            return(null);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 创建一个具有 IIRAPNamespaceSet 接口的实例,返回
        /// 该实例的 IIRAPNamespaceSet 接口
        /// </summary>
        /// <param name="namespaceType"></param>
        /// <returns></returns>
        public static IIRAPNamespaceSet CreatInstance(
            NamespaceType namespaceType)
        {
            switch (namespaceType)
            {
            case NamespaceType.Sys:
                return(new IRAPSysNamespaceSet());

            case NamespaceType.Biz:
                return(new IRAPBizNamespaceSet());

            default:
                return(null);
            }
        }
Exemplo n.º 13
0
        public static IEnumerable<NamespaceType> GetAllNamespaces(string cleanString, SpecData specificationData)
        {
            var namespaces = new List<NamespaceType>();

            foreach (Match _namespace in NamespaceParser.Matches(cleanString))
            {
                var namespaceDefinition = new NamespaceType
                {
                    Name = _namespace.Groups["name"].Value.Trim(),
                    IsPartial = !string.IsNullOrWhiteSpace(_namespace.Groups["partial"].Value.Trim()),
                    ExtendedAttribute = CleanString(_namespace.Groups["extended"].Value),
                    SpecNames = new[] { specificationData.Name }
                };

                if (!string.IsNullOrWhiteSpace(namespaceDefinition.ExtendedAttribute))
                {
                    var exposed = namespaceDefinition.Exposed.ToList();

                    foreach (Match m in NamespaceExtendedParser.Matches(namespaceDefinition.ExtendedAttribute))
                    {
                        namespaceDefinition.SecureContext = namespaceDefinition.SecureContext || !string.IsNullOrWhiteSpace(m.Groups["securecontext"].Value.Trim());

                        var exposedValue = RegexLibrary.GroupingCleaner.Replace(m.Groups["exposed"].Value, string.Empty);
                        if (!string.IsNullOrWhiteSpace(exposedValue))
                        {
                            exposed.AddRange(exposedValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(api => api.Trim()));
                        }
                    }

                    namespaceDefinition.Exposed = exposed.Distinct();
                }

                namespaceDefinition.Members = _namespace.Groups["members"].Length > 0 ? GetAllNamespaceMembers(_namespace.Groups["members"].Value, specificationData) : new List<NamespaceMember>();

                if (!namespaces.Contains(namespaceDefinition))
                {
                    namespaces.Add(namespaceDefinition);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Duplicate namespace: " + namespaceDefinition.Name);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }

            return namespaces;
        }
Exemplo n.º 14
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="NamespaceInfo" /> class.
 /// </summary>
 /// <param name="active">The namespace is active</param>
 /// <param name="index">The namespace index</param>
 /// <param name="metaId">The namespace metaId</param>
 /// <param name="type">The namespace type, namespace and sub namespace.</param>
 /// <param name="depth">The namespace depth</param>
 /// <param name="levels">The namespace level</param>
 /// <param name="parentId">The namespace parent</param>
 /// <param name="owner">The owner of the namespace</param>
 /// <param name="startHeight">The height at which the ownership begins.</param>
 /// <param name="endHeight">The height at which the ownership ends.</param>
 /// <param name="alias"> The alias linked to a namespace.</param>
 public NamespaceInfo(bool?active, int?index, string metaId, NamespaceType type, int?depth,
                      List <NamespaceId> levels, NamespaceId parentId, PublicAccount owner, ulong startHeight, ulong endHeight,
                      Alias alias)
 {
     Active      = active;
     Index       = index;
     MetaId      = metaId;
     Type        = type;
     Depth       = depth;
     Levels      = levels;
     ParentId    = parentId;
     Owner       = owner;
     StartHeight = startHeight;
     EndHeight   = endHeight;
     Alias       = alias;
 }
        /// <summary>
        ///     Initializes a new instance of the <see cref="RegisterNamespaceTransaction" /> class.
        /// </summary>
        /// <param name="networkType"></param>
        /// <param name="version"></param>
        /// <param name="deadline"></param>
        /// <param name="maxFee"></param>
        /// <param name="namespaceName"></param>
        /// <param name="namespaceId"></param>
        /// <param name="namespaceType"></param>
        /// <param name="duration"></param>
        /// <param name="parentId"></param>
        /// <param name="signature"></param>
        /// <param name="signer"></param>
        /// <param name="transactionInfo"></param>
        public RegisterNamespaceTransaction(NetworkType networkType, int version, Deadline deadline, ulong?maxFee,
                                            string namespaceName, NamespaceId namespaceId, NamespaceType namespaceType, ulong?duration,
                                            NamespaceId parentId            = null, string signature = null, PublicAccount signer = null,
                                            TransactionInfo transactionInfo = null)
            : base(networkType, version, EntityType.REGISTER_NAMESPACE, deadline, maxFee, signature, signer,
                   transactionInfo)
        {
            if (string.IsNullOrEmpty(namespaceName))
            {
                throw new ArgumentNullException(nameof(namespaceName));
            }

            if (!Enum.IsDefined(typeof(NetworkType), networkType))
            {
                throw new InvalidEnumArgumentException(nameof(networkType), networkType.GetValue(),
                                                       typeof(NetworkType));
            }
            if (namespaceType != NamespaceType.ROOT_NAMESPACE && namespaceType != NamespaceType.SUB_NAMESPACE)
            {
                throw new ArgumentOutOfRangeException(nameof(namespaceType));
            }
            if (namespaceType == NamespaceType.ROOT_NAMESPACE)
            {
                if (!duration.HasValue)
                {
                    throw new ArgumentNullException(nameof(duration));
                }
            }
            else
            {
                if (parentId == null)
                {
                    throw new ArgumentNullException(nameof(parentId));
                }
            }


            Duration      = duration;
            NamespaceName = namespaceName;
            NamespaceType = namespaceType;
            NamespaceId   = namespaceId;
            ParentId      = parentId;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Generates the bytes.
        /// </summary>
        /// <returns>System.Byte[].</returns>
        internal override byte[] GenerateBytes()
        {
            var builder = new FlatBufferBuilder(1);

            var namespaceNameLength = (uint)Encoding.UTF8.GetBytes(NamespaceId.Name).Length;

            // create vectors
            var signatureVector  = NamespaceCreationTransactionBuffer.CreateSignatureVector(builder, new byte[64]);
            var signerVector     = NamespaceCreationTransactionBuffer.CreateSignerVector(builder, GetSigner());
            var feeVector        = NamespaceCreationTransactionBuffer.CreateFeeVector(builder, Fee.ToUInt8Array());
            var deadlineVector   = NamespaceCreationTransactionBuffer.CreateDeadlineVector(builder, Deadline.Ticks.ToUInt8Array());
            var durationParentId = ParentId == null?Duration.ToUInt8Array() : ParentId.Id.ToUInt8Array();

            var durationParentIdVector = NamespaceCreationTransactionBuffer.CreateDurationParentIdVector(builder, durationParentId);
            var namespaceIdVector      = NamespaceCreationTransactionBuffer.CreateNamespaceIdVector(builder, IdGenerator.GenerateId(NamespaceType == 0x00 ? 0 : IdGenerator.GenerateId(0, ParentId.Name), NamespaceId.Name).ToUInt8Array());

            var    name    = NamespaceCreationTransactionBuffer.CreateNamespaceNameVector(builder, Encoding.UTF8.GetBytes(NamespaceId.Name));
            ushort version = ushort.Parse(NetworkType.GetNetworkByte().ToString("X") + "0" + Version.ToString("X"), System.Globalization.NumberStyles.HexNumber);

            // Add to buffer
            NamespaceCreationTransactionBuffer.StartNamespaceCreationTransactionBuffer(builder);
            NamespaceCreationTransactionBuffer.AddSize(builder, 138 + namespaceNameLength);
            NamespaceCreationTransactionBuffer.AddSignature(builder, signatureVector);
            NamespaceCreationTransactionBuffer.AddSigner(builder, signerVector);
            NamespaceCreationTransactionBuffer.AddVersion(builder, version);
            NamespaceCreationTransactionBuffer.AddType(builder, TransactionTypes.Types.RegisterNamespace.GetValue());
            NamespaceCreationTransactionBuffer.AddFee(builder, feeVector);
            NamespaceCreationTransactionBuffer.AddDeadline(builder, deadlineVector);
            NamespaceCreationTransactionBuffer.AddNamespaceType(builder, NamespaceType.GetValue());
            NamespaceCreationTransactionBuffer.AddDurationParentId(builder, durationParentIdVector);
            NamespaceCreationTransactionBuffer.AddNamespaceId(builder, namespaceIdVector);
            NamespaceCreationTransactionBuffer.AddNamespaceNameSize(builder, (byte)namespaceNameLength);
            NamespaceCreationTransactionBuffer.AddNamespaceName(builder, name);

            // Calculate size
            var codedNamespace = NamespaceCreationTransactionBuffer.EndNamespaceCreationTransactionBuffer(builder);

            builder.Finish(codedNamespace.Value);

            return(new NamespaceCreateionTransactionSchema().Serialize(builder.SizedByteArray()));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Creates a new folder.
        /// </summary>
        private FolderState CreateFolder(NodeState parent, string path, string name, NamespaceType namespaceType)
        {
            ushort namespaceIndex = NamespaceIndexes[(int)namespaceType];

            var folder = new FolderState(parent)
            {
                SymbolicName     = name,
                ReferenceTypeId  = ReferenceTypes.Organizes,
                TypeDefinitionId = ObjectTypeIds.FolderType,
                NodeId           = new NodeId(path, namespaceIndex),
                BrowseName       = new QualifiedName(path, namespaceIndex),
                DisplayName      = new LocalizedText("en", name),
                WriteMask        = AttributeWriteMask.None,
                UserWriteMask    = AttributeWriteMask.None,
                EventNotifier    = EventNotifiers.None
            };

            parent?.AddChild(folder);

            return(folder);
        }
        public void NewAzureSBNamespaceNoACSSuccessfull()
        {
            // Setup
            MockCommandRuntime mockCommandRuntime    = new MockCommandRuntime();
            Mock <ServiceBusClientExtensions> client = new Mock <ServiceBusClientExtensions>();
            string        name                = "test1";
            string        location            = "West US";
            NamespaceType type                = NamespaceType.NotificationHub;
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand()
            {
                Name               = name,
                Location           = location,
                CreateACSNamespace = false,
                NamespaceType      = type,
                CommandRuntime     = mockCommandRuntime,
                Client             = client.Object
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace {
                Name = name, Region = location, NamespaceType = type
            };

            client.Setup(f => f.CreateNamespace(name, location, type, false)).Returns(expected);
            client.Setup(f => f.GetServiceBusRegions()).Returns(new List <ServiceBusLocation>()
            {
                new ServiceBusLocation()
                {
                    Code = location
                }
            });

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            ExtendedServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ExtendedServiceBusNamespace;

            Assert.Equal <ExtendedServiceBusNamespace>(expected, actual);
        }
        public void CreatesNewSBCaseInsensitiveRegion()
        {
            // Setup
            MockCommandRuntime mockCommandRuntime    = new MockCommandRuntime();
            Mock <ServiceBusClientExtensions> client = new Mock <ServiceBusClientExtensions>();
            string        name                = "test";
            string        location            = "West US";
            NamespaceType type                = NamespaceType.Messaging;
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand()
            {
                Name           = name,
                Location       = location.ToLower(),
                CommandRuntime = mockCommandRuntime,
                Client         = client.Object
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace {
                Name = name, Region = location, NamespaceType = NamespaceType.Messaging
            };

            client.Setup(f => f.CreateNamespace(name, location.ToLower(), type, true)).Returns(expected);
            client.Setup(f => f.GetServiceBusRegions()).Returns(new List <ServiceBusLocation>()
            {
                new ServiceBusLocation()
                {
                    Code = location
                }
            });

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            ExtendedServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ExtendedServiceBusNamespace;

            Assert.Equal <ExtendedServiceBusNamespace>(expected, actual);
        }
Exemplo n.º 20
0
 /// <summary>
 ///   自分の親になり得る,かつ,名前空間構成要素になりうる要素タイプを取得します
 /// </summary>
 /// <param name="type"> 名前空間構成要素タイプ </param>
 /// <returns> 親になる名前空間構成要素タイプの集合 </returns>
 public static NamespaceType[] GetParentTypes(NamespaceType type)
 {
     switch (type) {
     case NamespaceType.Package:
         return new NamespaceType[] { };
     case NamespaceType.Class:
         return new[] { NamespaceType.Class, NamespaceType.Package };
     case NamespaceType.Function:
         return new[] {
                 NamespaceType.Class, NamespaceType.Package,
                 NamespaceType.Function
         };
     case NamespaceType.Variable:
         return new[] {
                 NamespaceType.Class, NamespaceType.Function,
                 NamespaceType.TemporaryScope
         };
     case NamespaceType.TemporaryScope:
         return new[]
         { NamespaceType.Function, NamespaceType.TemporaryScope };
     default:
         throw new InvalidOperationException();
     }
 }
Exemplo n.º 21
0
 public SimpleComplexElementAttribute(NamespaceType namespaceType)
     : base(namespaceType)
 {
 }
        public virtual ExtendedServiceBusNamespace CreateNamespace(string name, string location, NamespaceType type, bool createACSNamespace = false)
        {
            location = string.IsNullOrEmpty(location) ? GetDefaultLocation() : location;

            if (!Regex.IsMatch(name, ServiceBusConstants.NamespaceNamePattern))
            {
                throw new ArgumentException(string.Format(Resources.InvalidNamespaceName, name), "Name");
            }

            ServiceBusClient.Namespaces.CreateNamespace(name, new ServiceBusNamespaceCreateParameters { Region = location, CreateACSNamespace = createACSNamespace, NamespaceType = type});

            // Wait until the namespace is activated
            while (!IsActiveNamespace(name))
            {
                Thread.Sleep(SleepDuration);
            }

            return GetExtendedServiceBusNamespace(name);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Process a generic `Assign` statement.
        /// </summary>
        /// <param name="nsType"></param>
        protected void ProcessAssignment(NamespaceType nsType)
        {
            DmlSyntaxError badAssign = DmlSyntaxError.BadAssignmentStatement();

            Advance(exception: badAssign);

            Instruction assigner; // The instruction that performs the assignment.

            // Check for a global identifier.
            if (DmlTokens.IsMatch(CurrentToken, DmlTokens.AT))
            {
                Advance(exception: badAssign);
                if (DmlTokens.IsMatch(CurrentToken, DmlTokens.UQNAME))
                {
                    assigner = new AssignGlobal(CurrentToken);
                }
                else
                {
                    throw DmlSyntaxError.BadGlobalName(CurrentToken);
                }
            }
            // Check for an instance bound indentifier.
            else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.DOLLAR))
            {
                switch (nsType)
                {
                case NamespaceType.BulletInit:
                case NamespaceType.BulletUpdate:
                    Advance(exception: badAssign);
                    if (DmlTokens.IsName(CurrentToken))
                    {
                        switch (CurrentToken)
                        {
                        // Assign directly to the bullet direction.
                        case DmlTokens.INTRINSIC_DIRECTION:
                            assigner = AssignIntrinsicBulletProperty.Direction;
                            break;

                        // Assign directly to the bullet speed.
                        case DmlTokens.INTRINSIC_SPEED:
                            assigner = AssignIntrinsicBulletProperty.Speed;
                            break;

                        // Assign directly to the bullet colour.
                        case DmlTokens.INTRINSIC_COLOUR:
                            assigner = AssignIntrinsicBulletProperty.Colour;
                            break;

                        case DmlTokens.INTRINSIC_SPRITE:
                            assigner = AssignIntrinsicBulletProperty.Sprite;
                            break;

                        default:
                            assigner = new AssignBulletBound(CurrentToken);
                            break;
                        }
                    }
                    else
                    {
                        throw DmlSyntaxError.BadVariableName(CurrentToken);
                    }
                    break;

                default:
                    throw DmlSyntaxError.BadAssignmentNamespace();
                }
            }
            // Check for an ordinary local name.
            else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.UQNAME))
            {
                assigner = new AssignLocal(CurrentToken);
            }
            else
            {
                throw DmlSyntaxError.BadVariableName(CurrentToken);
            }

            // Read the expression.
            Advance(exception: badAssign);
            string[] expression_tokens = GetUntil(DmlTokens.EOL);
            ProcessExpression(expression_tokens);
            Instructions.Add(assigner);
        }
 public RegisterNamespaceTransactionBuilder SetNamespaceType(NamespaceType namespaceType)
 {
     NamespaceType = namespaceType;
     return(Self());
 }
 /// <summary>
 ///     Get value extension
 /// </summary>
 /// <param name="type">The namespace type</param>
 /// <returns>NamespaceType</returns>
 public static byte GetValueInByte(this NamespaceType type)
 {
     return((byte)type);
 }
Exemplo n.º 26
0
 public TagElementAttribute(NamespaceType namespaceType)
     : this()
 {
     NamespaceType = namespaceType;
 }
Exemplo n.º 27
0
 public BuiltInNamespaceSymbol(string name, NamespaceType type)
     : base(name)
 {
     Type = type;
 }
Exemplo n.º 28
0
        public bool Match(SourceStream source, out NamespaceType result)
        {
            result = null;

            if (!source.IsValid())
            {
                return(false);
            }

            var slice = source.GetSlice();

            SkipCommentsAndWhitespace(slice);

            if (!slice.MatchString(KeywordNamespace))
            {
                return(false);
            }

            SkipCommentsAndWhitespace(slice);

            string namespace_name = string.Empty;

name_match:

            if (!slice.ReadWord(out string name))
            {
                throw new ParseError($"expected namespace 'name'.", slice);
            }

            if (!name.IsNameLegal())
            {
                slice.MoveBy(-name.Length);
                throw new ParseError($"'{name}' is not a legal namespace.", slice);
            }

            namespace_name += name;

            SkipCommentsAndWhitespace(slice);

            if (slice.MatchString(TokenNameExtension))
            {
                namespace_name += TokenNameExtension;
                goto name_match;
            }

            if (!slice.MatchString(TokenNamespaceFirst))
            {
                throw new ParseError($"expected '{TokenNamespaceFirst}'.", slice);
            }

            var types   = new TypeList();
            var parsers = new GrammarParserDelegate[]
            {
                MatchStruct,
                match_enum,
                MatchNamespace,
            };

            while (slice.IsValid())
            {
                SkipCommentsAndWhitespace(slice);

                if (slice.MatchString(TokenNamespaceFinal))
                {
                    break;
                }

                if (!MatchAny(slice, parsers, out BaseType type))
                {
                    throw new ParseError("cannot parse", slice);
                }

                types.Add(type);
            }

            var span = source.Join(slice);

            result = new NamespaceType(namespace_name, types, span);

            return(true);
        }
Exemplo n.º 29
0
 public ResourceType?TryGenerateFallbackType(NamespaceType declaringNamespace, ResourceTypeReference reference, ResourceTypeGenerationFlags flags)
 => null;
Exemplo n.º 30
0
        public static Symbol ResolveNamespaceQualifiedFunction(FunctionFlags allowedFlags, Symbol?foundSymbol, IdentifierSyntax identifierSyntax, NamespaceType namespaceType)
        => ResolveSymbolInternal(
            allowedFlags,
            foundSymbol,
            identifierSyntax,
            getNameSuggestions: () =>
        {
            var knowFunctionNames = namespaceType.MethodResolver.GetKnownFunctions().Keys;

            return(allowedFlags.HasAnyDecoratorFlag()
                        ? knowFunctionNames.Concat(namespaceType.DecoratorResolver.GetKnownDecoratorFunctions().Keys)
                        : knowFunctionNames);
        },
            getMissingNameError: (builder, suggestedName) => suggestedName switch {
            null => builder.FunctionDoesNotExistInNamespace(namespaceType, identifierSyntax.IdentifierName),
        public virtual ExtendedServiceBusNamespace CreateNamespace(string name, string location, NamespaceType type, bool createACSNamespace = false)
        {
            location = string.IsNullOrEmpty(location) ? GetDefaultLocation() : location;

            if (!Regex.IsMatch(name, ServiceBusConstants.NamespaceNamePattern))
            {
                throw new ArgumentException(string.Format(Resources.InvalidNamespaceName, name), "Name");
            }

            ServiceBusClient.Namespaces.CreateNamespace(name, new ServiceBusNamespaceCreateParameters {
                Region = location, CreateACSNamespace = createACSNamespace, NamespaceType = type
            });

            // Wait until the namespace is activated
            while (!IsActiveNamespace(name))
            {
                Thread.Sleep(SleepDuration);
            }

            return(GetExtendedServiceBusNamespace(name));
        }
Exemplo n.º 32
0
 /// <summary>
 ///   名前空間要素タイプから対応する Unified 型(型オブジェクト)へ変換します
 /// </summary>
 /// <param name="type"> 名前空間構成要素タイプ </param>
 /// <returns> type に対応する Unified 型(型オブジェクト)の集合 </returns>
 public static IEnumerable<Type> Namespace2UnifiedType(
     NamespaceType type)
 {
     switch (type) {
     case NamespaceType.Package:
         return new List<Type>
         { UnifiedNamespaceDefinition.Create().GetType() };
     case NamespaceType.Class:
         return new List<Type>
         { UnifiedClassDefinition.Create().GetType() };
     case NamespaceType.Function:
         return new List<Type>
         { UnifiedFunctionDefinition.Create().GetType() };
     case NamespaceType.TemporaryScope:
         return new List<Type> {
                 UnifiedForeach.Create().GetType(),
                 UnifiedFor.Create().GetType(),
                 UnifiedWhile.Create().GetType(),
                 UnifiedDoWhile.Create().GetType(),
         };
     default:
         throw new InvalidOperationException();
     }
 }
Exemplo n.º 33
0
 public NamespaceSymbol(string name, IEnumerable <FunctionOverload> functionOverloads, IEnumerable <BannedFunction> bannedFunctions, IEnumerable <Decorator> decorators)
     : base(name)
 {
     Type = new NamespaceType(name, Enumerable.Empty <TypeProperty>(), functionOverloads, bannedFunctions, decorators);
 }
 /// <summary>
 ///     Get value extension
 /// </summary>
 /// <param name="type">The namespace type</param>
 /// <returns>NamespaceType</returns>
 public static int GetValue(this NamespaceType type)
 {
     return((int)type);
 }
Exemplo n.º 35
0
 public SimpleElementAttribute(NamespaceType namespaceType)
 {
     NamespaceType = namespaceType;
 }
Exemplo n.º 36
0
        /// <summary>
        /// Process a generic `Assign` statement.
        /// </summary>
        /// <param name="nsType"></param>
        protected void ProcessAssignment(NamespaceType nsType)
        {
            DmlSyntaxError badAssign = DmlSyntaxError.BadAssignmentStatement();
            Advance(exception: badAssign);

            Instruction assigner; // The instruction that performs the assignment.

            // Check for a global identifier.
            if (DmlTokens.IsMatch(CurrentToken, DmlTokens.AT))
            {
                Advance(exception: badAssign);
                if (DmlTokens.IsMatch(CurrentToken, DmlTokens.UQNAME))
                    assigner = new AssignGlobal(CurrentToken);
                else
                    throw DmlSyntaxError.BadGlobalName(CurrentToken);
            }
            // Check for an instance bound indentifier.
            else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.DOLLAR))
            {
                switch (nsType)
                {
                    case NamespaceType.BulletInit:
                    case NamespaceType.BulletUpdate:
                        Advance(exception: badAssign);
                        if (DmlTokens.IsName(CurrentToken))
                        {
                            switch (CurrentToken)
                            {
                                // Assign directly to the bullet direction.
                                case DmlTokens.INTRINSIC_DIRECTION:
                                    assigner = AssignIntrinsicBulletProperty.Direction;
                                    break;
                                // Assign directly to the bullet speed.
                                case DmlTokens.INTRINSIC_SPEED:
                                    assigner = AssignIntrinsicBulletProperty.Speed;
                                    break;
                                // Assign directly to the bullet colour.
                                case DmlTokens.INTRINSIC_COLOUR:
                                    assigner = AssignIntrinsicBulletProperty.Colour;
                                    break;
                                case DmlTokens.INTRINSIC_SPRITE:
                                    assigner = AssignIntrinsicBulletProperty.Sprite;
                                    break;
                                default:
                                    assigner = new AssignBulletBound(CurrentToken);
                                    break;
                            }
                        }
                        else
                            throw DmlSyntaxError.BadVariableName(CurrentToken);
                        break;
                    default:
                        throw DmlSyntaxError.BadAssignmentNamespace();
                }

            }
            // Check for an ordinary local name.
            else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.UQNAME))
                assigner = new AssignLocal(CurrentToken);
            else
            {
                throw DmlSyntaxError.BadVariableName(CurrentToken);
            }

            // Read the expression.
            Advance(exception: badAssign);
            string[] expression_tokens = GetUntil(DmlTokens.EOL);
            ProcessExpression(expression_tokens);
            Instructions.Add(assigner);
        }