Пример #1
0
            /// <summary>
            /// Is the given java class name + method name + method descriptor a virtual method?
            /// </summary>
            public bool IsImportedVirtualMethod(IClassLoader classLoader, Action <ClassFile> classLoaded, string name, string descriptor, out MethodAttributes methodAttributes, out string netName, out string baseDescriptor, out string baseSignature)
            {
                var cf = Resolve(classLoader, classLoaded, null);

                descriptor = Descriptors.StripMethodReturnType(descriptor);
                foreach (var importMethod in dexMethods)
                {
                    var method = importMethod.Resolve(cf);
                    if ((method.Name == name) && (Descriptors.StripMethodReturnType(method.Descriptor) == descriptor))
                    {
                        methodAttributes = (MethodAttributes)importMethod.Method.Attributes;
                        netName          = importMethod.Method.Name;
                        baseDescriptor   = method.Descriptor;
                        baseSignature    = (method.Signature != null) ? method.Signature.Original : null;
                        if (baseSignature == baseDescriptor)
                        {
                            baseSignature = null;
                        }
                        return(true);
                    }
                }
                methodAttributes = 0;
                netName          = null;
                baseDescriptor   = null;
                baseSignature    = null;
                return(false);
            }
Пример #2
0
        public T GetOrCreateModule <T>() where T : KalkModule, new()
        {
            var typeOfT = typeof(T);

            if (_modules.TryGetValue(typeOfT, out var module))
            {
                return((T)module);
            }
            var moduleT = new T();

            module = moduleT;
            _modules.Add(typeOfT, module);

            if (!module.IsBuiltin)
            {
                Builtins.SetValue(module.Name, module, true);
                // Register the module descriptor
                Descriptors.Add(module.Name, module.Descriptor);
            }

            module.Initialize(this);

            if (module.IsBuiltin)
            {
                module.InternalImport();
            }

            return(moduleT);
        }
 public void default_is_read()
 {
     Descriptors.ContainsKey(string.Empty).ShouldBeTrue();
     Descriptors[string.Empty]
     .Check(x => x.File.ShouldBe(FileSystem.GetFile("sauron.wrapdesc")))
     .Check(x => x.Value.Name.ShouldBe("sauron"));
 }
Пример #4
0
        public ProgramMapTable(byte[] packetBuffer, int index)
        {
            var pointer = packetBuffer[index];

            if (pointer > 0)
            {
                index += pointer;
            }
            else
            {
                index++;
            }
            TableId              = packetBuffer[index];
            SectionLength        = (packetBuffer[index + 1] & Helper.B00000011) * 256 + packetBuffer[index + 2];
            ProgramNumber        = packetBuffer[index + 3] * 256 + packetBuffer[index + 4];
            VersionNumber        = (packetBuffer[index + 5] & Helper.B00111110) >> 1;
            CurrentNextIndicator = packetBuffer[index + 5] & 1;
            SectionNumber        = packetBuffer[index + 6];
            LastSectionNumber    = packetBuffer[index + 7];
            PcrId = (packetBuffer[index + 8] & Helper.B00011111) * 256 + packetBuffer[index + 9];
            var programInfoLength = (packetBuffer[index + 10] & Helper.B00001111) * 256 + packetBuffer[index + 11];

            Descriptors = ProgramMapTableDescriptor.ReadDescriptors(packetBuffer, programInfoLength, index + 12);
            var newIndex = index + 12 + Descriptors.Sum(p => p.Size);

            Streams = new List <ProgramMapTableStream>();
            while (newIndex - index < SectionLength - 4)
            {
                var stream = new ProgramMapTableStream(packetBuffer, newIndex);
                Streams.Add(stream);
                newIndex += stream.Size;
            }
        }
Пример #5
0
        public Spell Ablative_Barrier()
        {
            Name = "Ablative Barrier";

            School     = new Conjuration();
            Sub_School = new Conjuration.Creation();
            Descriptors.Add(new Force());
            Level.Add("Alchemist", 2);
            Level.Add("Bloodrager", 2);
            Level.Add("Magus", 2);
            Level.Add("Occultist", 2);
            Level.Add("Psychic", 3);
            Level.Add("Sorcerer/Wizard", 3);
            Level.Add("Summoner", 2);
            Level.Add("Unchained Summoner", 3);

            Casting_Time = "1 standard action";
            Components.AddRange(new List <string> {
                "V", "S", "M(a piece of metal cut from a shield)"
            });

            Range            = "touch";
            Target           = "creature touched";
            Duration         = "1 hour/level or until discharged";
            Saving_Throw     = "Will negates (harmless)";
            Spell_Resistance = "no";

            Description = "Invisible layers of solid force surround and protect the target, granting that target a +2 armor bonus to AC. Additionally, the first 5 points of lethal damage the target takes from each attack are converted into nonlethal damage. Against attacks that already deal nonlethal damage, the target gains DR 5/—. Once this spell has converted 5 points of damage to nonlethal damage per caster level (maximum 50 points), the spell is discharged.";

            return(this);
        }
Пример #6
0
        protected void RegisterVariable(string name, object value, string category = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            var names = name.Split(',');

            KalkDescriptor descriptor = null;

            foreach (var subName in names)
            {
                Content.SetValue(subName, value, true);

                if (descriptor == null || !Descriptors.TryGetValue(names[0], out descriptor))
                {
                    descriptor = new KalkDescriptor();
                }
                Descriptors.Add(subName, descriptor);
                descriptor.Names.Add(subName);
            }
        }
Пример #7
0
 public void BuildNPCFromEmbed(Embed embed)
 {
     foreach (var activityField in embed.Fields.Where(fld => fld.Name == NPCResources.Activity))
     {
         Activities.Add(activityField.Value);
     }
     foreach (var dispositionField in embed.Fields.Where(fld => fld.Name == NPCResources.Disposition))
     {
         Dispositions.Add(dispositionField.Value);
     }
     foreach (var goal in embed.Fields.Where(fld => fld.Name == NPCResources.Goal))
     {
         Goals.Add(goal.Value);
     }
     foreach (var role in embed.Fields.Where(fld => fld.Name == NPCResources.Role))
     {
         Roles.Add(role.Value);
     }
     foreach (var desc in embed.Fields.Where(fld => fld.Name == NPCResources.Descriptor))
     {
         Descriptors.Add(desc.Value);
     }
     Name      = embed.Fields.FirstOrDefault(fld => fld.Name == NPCResources.Name).Value;
     IconUrl   = embed.Thumbnail.HasValue ? embed.Thumbnail.Value.Url : null;
     EmbedDesc = embed.Description;
 }
Пример #8
0
        private static void Assert(string code, string descriptorName)
        {
            var analyzer   = new CommutativityAnalyzer();
            var references = new[]
            {
                MetadataReference.CreateFromFile(typeof(string).Assembly.Location),
                MetadataReference.CreateFromFile(typeof(Console).Assembly.Location),
            };
            var allCode = CommutativeAttribute + code;

            if (descriptorName != null)
            {
                var descriptor = Descriptors.ByName(descriptorName);

                RoslynAssert.Diagnostics(
                    analyzer,
                    ExpectedDiagnostic.Create(descriptor),
                    allCode,
                    metadataReferences: references);
            }
            else
            {
                RoslynAssert.NoAnalyzerDiagnostics(analyzer, allCode);
            }
        }
Пример #9
0
 public void OnEnable()
 {
     if (!Descriptors.Contains(StateDescriptor.STATIC))
     {
         Descriptors.Add(StateDescriptor.STATIC);
     }
 }
Пример #10
0
        /// <summary>
        /// Creates a new <see cref="Descriptor"/> from the <see cref="TcpClient"/>.
        /// </summary>
        /// <param name="client">The <see cref="TcpClient"/> to create the descriptor from.</param>
        public async Task NewDescriptorAsync(TcpClient client)
        {
            var newDescriptor = new Descriptor(client);

            Descriptors.Add(newDescriptor);

            await newDescriptor.SendAsync("Username (new for new account): ");
        }
Пример #11
0
        public byte[] GetFileDescriptorSet()
        {
            var descriptor = Descriptors.Last();
            var output     = new FileDescriptorSet();

            output.File.AddRange(GetSelfAndDependency(descriptor.File).Select(x => x.SerializedData));
            return(output.ToByteArray());
        }
Пример #12
0
 internal RequestInfo(RUSDeviceId deviceId, Command address, EntityDescriptor[] descriptors, IEnumerable <int> userCommandDescriptors, Func <RequestInfo, IEnumerable <IDataEntity> > entitiesFactory)
 {
     _entitiesFactory       = entitiesFactory ?? (_ => new IDataEntity[0]);
     DeviceId               = deviceId;
     Address                = address;
     Descriptors            = descriptors ?? throw new ArgumentNullException(nameof(descriptors));
     UserCommandDescriptors = Descriptors.SubArray(userCommandDescriptors).ToArray();
 }
Пример #13
0
 /// <summary>
 /// Creates a new type of diagnostic
 /// </summary>
 /// <param name="defaultSeverity">The default severity of the diagnostic</param>
 /// <param name="id">The ID number of the diagnostic</param>
 /// <param name="title">The title of the diagnostic</param>
 /// <param name="messageFormat">The format string used to format the diagnostic</param>
 public D(DiagnosticSeverity defaultSeverity, int id, string title, string messageFormat)
 {
     if (!Descriptors.TryGetValue(id, out Descriptor))
     {
         Descriptor      = new($"SPI{id:D4}", title, messageFormat, "SpacePi", defaultSeverity, true);
         Descriptors[id] = Descriptor;
     }
     Instances = NewInstances;
 }
Пример #14
0
 /// <summary>
 /// Are the given methods the same wrt name and parameters?
 /// </summary>
 private static bool AreSame(this MethodDefinition method, MethodDefinition other)
 {
     if (method.Name != other.Name)
     {
         return(false);
     }
     return((method.Descriptor == other.Descriptor) ||
            (Descriptors.StripMethodReturnType(method.Descriptor) == Descriptors.StripMethodReturnType(other.Descriptor)));
 }
 /// <summary>
 /// Now, this is a fairly trivial, if a bit naive Code Generation implementation. We are
 /// solely interested in making sure that fundamental building blocks of Code Generation,
 /// such as inserting a Leading Preamble Text, are taking place successfully.
 /// </summary>
 /// <inheritdoc />
 public override Task GenerateAsync(DocumentTransformationContext context, IProgress <Diagnostic> progress
                                    , CancellationToken cancellationToken)
 => Task.Run(
     () =>
 {
     Descriptors.Add(new CodeGeneratorDescriptor {
         CompilationUnits = { context.SourceCompilationUnit }
     });
 }, cancellationToken);
Пример #16
0
        internal override Action <IServiceCollection> GetBuild()
        {
            return(services =>
            {
                services.AddMemoryCache();
                services.AddSingleton(provider => MemoryCacheHandler.New(provider.GetService <IMemoryCache>(), Options));

                Descriptors.ForEach(services.TryAdd);
            });
        }
Пример #17
0
 public MainPageView()
 {
     InitializeComponent();
     flyout.ListView.SelectionChanged += ListView_SelectionChanged;
     FlyoutLayoutBehavior              = FlyoutLayoutBehavior.SplitOnLandscape;
     ViewModel             = App.ServiceProvider.GetRequiredService <MainPageViewModel>();
     this.BindingContext   = ViewModel;
     flyout.BindingContext = ViewModel;
     FlowSettingsChanged(Descriptors.GetFlowSettings <EditFormSettingsDescriptor>("students"));
 }
Пример #18
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ResultDescriptor"/> class.
        /// </summary>
        /// <param name="code">The error code.</param>
        /// <param name="module">The module name (ex: <c>Blaze.RawInput</c>).</param>
        /// <param name="apiCode">The API-specific error code (ex: <c>D2D1_ERR_...</c>).</param>
        /// <param name="description">The optional description of the result code. This can be <c>null</c>.</param>
        public ResultDescriptor(Result code, string module, string nativeApiCode, string apiCode, string description = null)
        {
            Result        = code;
            Module        = module;
            NativeApiCode = nativeApiCode;
            ApiCode       = apiCode;
            Description   = description ?? GetDescriptionFromResultCode(Code) ?? "Unknown";

            Descriptors.TryAdd(code, this);
        }
Пример #19
0
        /// <summary>
        /// Uses singleton middleware objects.
        /// Same object is used for all requests
        /// </summary>
        public void UseMiddleware(IMiddleware middleware)
        {
            MiddlewareDescriptor desc = new MiddlewareDescriptor
            {
                Instance              = middleware,
                MiddlewareType        = middleware.GetType(),
                ConstructorParameters = null
            };

            Descriptors.Add(desc);
        }
Пример #20
0
 public Descriptor GetDescriptor(string type, bool includeEmbeddeds = false)
 {
     return(Descriptors.ContainsKey(type)
         ? Descriptors[type]
         : !includeEmbeddeds
             ? null
             : AllDescriptors.Values.FirstOrDefault(d =>
                                                    d.Type == type &&
                                                    d.Interfaces.Contains("udm.EmbeddedDeployable") &&
                                                    !d.IsVirtual));
 }
Пример #21
0
 public void Add(Descriptor descriptor)
 {
     if (descriptor.Name == DefaultName)
     {
         Descriptors[0] = descriptor;
     }
     else
     {
         Descriptors.Add(descriptor);
     }
 }
Пример #22
0
        /// <summary>
        /// Load the keywords which contains the specified characters.
        /// </summary>
        /// <param name="characters">The char.</param>
        private void LoadKeywordsToListBox(string characters)
        {
            if (CaseSensitive == false)
            {
                characters = characters.ToLower();
            }

            var listOfKeywords = Descriptors.Where(d => d.token.StartsWith(characters) && d.isUsedForAutoComplete == UsedForAutoComplete.Yes)
                                 .Select(d => d.token);

            AddKeywordsToListBox(listOfKeywords.ToArray());
        }
Пример #23
0
        public Embed GetEmbed()
        {
            bool firstFieldInline = Roles.Count() + Descriptors.Count() + Goals.Count() <= 3;
            List <EmbedFieldBuilder> rolesField = new List <EmbedFieldBuilder>();

            for (int i = 0; i < Roles.Length; i++)
            {
                if (i == 0)
                {
                    rolesField.Add(new EmbedFieldBuilder().WithIsInline(firstFieldInline).WithName(NPCResources.Role).WithValue(Roles[i]));
                }
                else
                {
                    rolesField.Add(new EmbedFieldBuilder().WithIsInline(true).WithName(NPCResources.Role).WithValue(Roles[i]));
                }
            }

            List <EmbedFieldBuilder> goalFields = new List <EmbedFieldBuilder>();

            for (int i = 0; i < Goals.Length; i++)
            {
                if (i == 0)
                {
                    goalFields.Add(new EmbedFieldBuilder().WithIsInline(firstFieldInline).WithName(NPCResources.Goal).WithValue(Goals[i]));
                }
                else
                {
                    goalFields.Add(new EmbedFieldBuilder().WithIsInline(true).WithName(NPCResources.Goal).WithValue(Goals[i]));
                }
            }

            List <EmbedFieldBuilder> descFields = new List <EmbedFieldBuilder>();

            for (int i = 0; i < Descriptors.Length; i++)
            {
                if (i == 0)
                {
                    descFields.Add(new EmbedFieldBuilder().WithIsInline(firstFieldInline).WithName(NPCResources.Descriptor).WithValue(Descriptors[i]));
                }
                else
                {
                    descFields.Add(new EmbedFieldBuilder().WithIsInline(true).WithName(NPCResources.Descriptor).WithValue(Descriptors[i]));
                }
            }

            return(new EmbedBuilder()
                   .WithTitle($"__{NPCResources.NPC}__")
                   .WithFields(new EmbedFieldBuilder().WithName(NPCResources.Name).WithValue(Name).WithIsInline(false))
                   .WithFields(rolesField)
                   .WithFields(goalFields)
                   .WithFields(descFields)
                   .Build());
        }
Пример #24
0
        /// <summary>
        /// Releases pool item by instance
        /// </summary>
        /// <returns></returns>
        public void ReleaseInstance(object instance)
        {
            PoolServiceDescriptor descriptor;

            lock (Descriptors)
                descriptor = Descriptors.Find(x => x.Instance == instance);

            if (descriptor != null)
            {
                Release(descriptor);
            }
        }
Пример #25
0
        public RelationshipProxy(SoapRelationship soapRelationship)
            : this()
        {
            BaseSoapRelationship = soapRelationship;

            foreach (KeyValuePair <SoapDescriptorType, Guid> nodeDescriptorPair in BaseSoapRelationship.Nodes)
            {
                DescriptorProxy descriptor = new DescriptorProxy(nodeDescriptorPair.Value, nodeDescriptorPair.Key, this, BaseSoapRelationship);

                Descriptors.Add(descriptor);
            }
        }
Пример #26
0
        private void OnListChange()
        {
            var selectedIndex = SelectedIndex;

            Descriptors.Clear();
            DocManager.Inst.Project.expressions.Values.ToList().ForEach(Descriptors.Add);
            if (selectedIndex >= descriptors.Count)
            {
                selectedIndex = Index;
            }
            SelectedIndex = selectedIndex;
        }
        /// <summary>
        /// Now, this is a fairly trivial, if a bit naive Code Generation implementation.
        /// We are solely interested in making sure that fundamental building blocks of
        /// Code Generation, such as inserting a Leading Preamble Text, are taking place
        /// successfully.
        /// </summary>
        /// <inheritdoc />
        public override Task GenerateAsync(DocumentTransformationContext context, IProgress <Diagnostic> progress
                                           , CancellationToken cancellationToken)
        {
            const string dispose   = nameof(IDisposable.Dispose);
            const string disposing = nameof(disposing);
            // ReSharper disable once InconsistentNaming
            const string IsDisposed = nameof(IsDisposed);

            IEnumerable <CodeGeneratorDescriptor> Generate()
            {
                var namespaceDecl = context.SourceCompilationUnit.DescendantNodesAndSelf().OfType <NamespaceDeclarationSyntax>().Single();
                var classDecl     = context.SourceCompilationUnit.DescendantNodesAndSelf().OfType <ClassDeclarationSyntax>().Single();

                yield return(new CodeGeneratorDescriptor
                {
                    CompilationUnits =
                    {
                        CompilationUnit()
                        .WithUsings(SingletonList(GetUsingNamespaceDirective <IDisposable>()))
                        .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                         NamespaceDeclaration(namespaceDecl.Name)
                                         .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                                          ClassDeclaration(classDecl.Identifier)
                                                          .WithModifiers(TokenList(PublicKeywordToken, PartialKeywordToken))
                                                          .WithBaseList(BaseList(
                                                                            SingletonSeparatedList <BaseTypeSyntax>(
                                                                                SimpleBaseType(IdentifierName($"I{Buz}"))
                                                                                )
                                                                            ))
                                                          .WithMembers(List(new[]
                        {
                            GetDisposeMethodDecl(dispose,                                              disposing),
                            GetIsDisposedPropertyDecl(IsDisposed),
                            GetDisposeImplementationMethodDecl(dispose,                                IsDisposed)
                        }))
                                                          ))
                                         ))
                    }
                });
            }

            void RunGenerate()
            {
                foreach (var d in Generate())
                {
                    Descriptors.Add(d);
                }
            }

            return(Task.Run(RunGenerate, cancellationToken));
        }
        /// <summary>
        /// Now, this is a fairly trivial, if a bit naive Code Generation implementation.
        /// We are solely interested in making sure that fundamental building blocks of
        /// Code Generation, such as inserting a Leading Preamble Text, are taking place
        /// successfully.
        /// </summary>
        /// <inheritdoc />
        public override Task GenerateAsync(DocumentTransformationContext context, IProgress <Diagnostic> progress
                                           , CancellationToken cancellationToken)
        {
            IEnumerable <CodeGeneratorDescriptor> Generate()
            {
                var namespaceDecl = context.SourceCompilationUnit.DescendantNodesAndSelf().OfType <NamespaceDeclarationSyntax>().Single();
                var classDecl     = context.SourceCompilationUnit.DescendantNodesAndSelf().OfType <ClassDeclarationSyntax>().Single();

                // ReSharper disable once InconsistentNaming
                const string Initialize = nameof(Initialize);
                var          other      = $"{classDecl.Identifier}";

                yield return(new CodeGeneratorDescriptor
                {
                    CompilationUnits =
                    {
                        CompilationUnit()
                        .WithUsings(SingletonList(GetUsingNamespaceDirective <ICloneable>()))
                        .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                         NamespaceDeclaration(namespaceDecl.Name)
                                         .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                                          ClassDeclaration(classDecl.Identifier)
                                                          .WithModifiers(classDecl.Modifiers)
                                                          .WithBaseList(BaseList(
                                                                            SingletonSeparatedList <BaseTypeSyntax>(
                                                                                SimpleBaseType(IdentifierName(nameof(ICloneable)))
                                                                                )
                                                                            ))
                                                          .WithMembers(List(new[]
                        {
                            GetCopyCtorDecl(other, Initialize),
                            GetInitializeMethodDecl(Initialize, other),
                            GetICloneableCloneMethodDecl(other)
                        }))
                                                          ))
                                         ))
                    }
                });
            }

            void RunGenerate()
            {
                foreach (var d in Generate())
                {
                    Descriptors.Add(d);
                }
            }

            return(Task.Run(RunGenerate, cancellationToken));
        }
Пример #29
0
 public Embed GetEmbed()
 {
     return(new EmbedBuilder()
            .WithTitle($"__{NPCResources.NPCTitle}__")
            .WithThumbnailUrl(IconUrl)
            .WithFields(new EmbedFieldBuilder().WithName(NPCResources.Name).WithValue(Name).WithIsInline(false))
            .WithFields(Roles.EmbedFieldBuilderFromList(NPCResources.Role, true))
            .WithFields(Goals.EmbedFieldBuilderFromList(NPCResources.Goal, true))
            .WithFields(Descriptors.EmbedFieldBuilderFromList(NPCResources.Descriptor, true))
            .WithFields(Activities.EmbedFieldBuilderFromList(NPCResources.Activity, true))
            .WithFields(Dispositions.EmbedFieldBuilderFromList(NPCResources.Disposition, true))
            .WithFooter(GameName.Ironsworn.ToString())
            .WithDescription(EmbedDesc)
            .Build());
 }
Пример #30
0
        private void _filesForm_FileSelectionChanged(object sender, FileSelectionChangedEventArgs eventArgs)
        {
            var errors = eventArgs.Files.SelectMany(f => f.ValidationErrors);

            _errors.SetErrors(errors);

            if (eventArgs.Files.Count != 1)
            {
                return;
            }
            var fileLocation = eventArgs.Files.First().FileInfo.FullName;
            var desc         = Descriptors.Select(descriptor => descriptor.GetAttributes(fileLocation)).SelectMany(items => items).ToDictionary(item => item.Key, item => item.Value);

            _descriptionForm.SetDictionary(desc);
        }