Exemplo n.º 1
0
 public static TValue GetValueOrDefault <TKey, TValue>(this System.Collections.Generic.IReadOnlyDictionary <TKey, TValue> dictionary, TKey key)
 {
     if (dictionary.TryGetValue(key, out TValue value))
     {
         return(value);
     }
     else
     {
         return(default);
Exemplo n.º 2
0
        public ReadOnlyDictionaryValueCollection(System.Collections.Generic.IReadOnlyDictionary <TKey, TValue> dictionary)
        {
            if (dictionary == null)
            {
                throw global::McgInterop.Helpers.NewException_ArgumentNullException_dictionary();
            }

            this.dictionary = dictionary;
        }
Exemplo n.º 3
0
 /**
  * Helper for success callbacks that just returns the Status.OK by default
  *
  * @param message The message to add to the success result.
  */
 public void success(JObject message)
 {
     try
     {
         System.Collections.Generic.IReadOnlyDictionary <String, Object> writableMap = ReactJsonConverter.jsonToReact(message);
         successCallback.Invoke(writableMap);
     }
     catch (Exception ex)
     {
         errorCallback.Invoke("Internal error converting results:" + ex.Message);
     }
 }
Exemplo n.º 4
0
        internal override Node ReplaceRegisterWithLocal(
            System.Collections.Generic.IReadOnlyDictionary <RegisterNode, Local> map,
            System.Collections.Generic.List <Node> newTrees,
            Function f)
        {
            List <Node> l = new List <Node>();

            foreach (var ch in Sequence)
            {
                l.Add(ch.ReplaceRegisterWithLocal(map, newTrees, f));
            }
            Sequence = l;
            //TODO: what to do with NextNode?
            return(base.ReplaceRegisterWithLocal(map, newTrees, f));
        }
Exemplo n.º 5
0
        private static bool IsSupported(PublishedPlugin pluginRequirements,
                                        System.Collections.Generic.IReadOnlyDictionary <string, int> interfaces)
        {
            var requirements = pluginRequirements.RequiredInterfaces;

            if (requirements == null)
            {
                return(true);
            }

            foreach (var requirement in requirements)
            {
                if (interfaces.TryGetValue(requirement.FullName, out var actualVersion))
                {
                    if (requirement.Version != actualVersion)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 6
0
        static CollectionsTable()
        {
            var nativeSerializers = new System.Collections.Generic.Dictionary <Type, ISQLiteSerializer>
            {
                { typeof(byte), new ByteSerializer() },
                { typeof(sbyte), new SByteSerializer() },
                { typeof(ushort), new UInt16Serializer() },
                { typeof(short), new Int16Serializer() },
                { typeof(uint), new UInt32Serializer() },
                { typeof(int), new Int32Serializer() },
                { typeof(long), new Int64Serializer() },
                { typeof(ulong), new UInt64Serializer() },
                { typeof(IPAddress), new IpAddressSerializer() },
                { typeof(string), new StringSerializer() },
                { typeof(float), new SingleSerializer() },
                { typeof(double), new DoubleSerializer() },
                { typeof(byte[]), new ByteArraySerializer() },
                { typeof(RowId), new ValueKeySerializer() },
                { typeof(DateTime), new DateTimeSerializer() }
            };

            NativeSerializers = nativeSerializers;
        }
Exemplo n.º 7
0
        public async Task InitalizeAsync()
        {
            this._client.MessageCreated         += this._command.Client_MessageCreated;
            this._client.Ready                  += Client_Ready;
            this._client.GuildDownloadCompleted += Client_GuildDownloadComplete;
            this._client.ClientErrored          += (x, y) =>
            {
                x.Logger.LogError(y.Exception, $"Client Errored in {y.EventName}");
                return(Task.CompletedTask);
            };

            System.Collections.Generic.IReadOnlyDictionary <int, CommandsNextExtension>?cnext = await this._client.UseCommandsNextAsync(GetCNextConfig());

            foreach (var c in cnext.Values)
            {
                c.RegisterCommands(Assembly.GetAssembly(typeof(CommandHandlingService)));

                c.CommandErrored  += this._error.Client_CommandErrored;
                c.CommandExecuted += this._error.Client_CommandExecuted;

                c.SetHelpFormatter <CustomHelpFormatter>();

                var slash = c.Client.UseSlashCommands(new()
                {
                    Services = this._serviceProvider
                });

#if DEBUG
                slash.RegisterCommands <BanCommand>(431462786900688896);
                slash.RegisterCommands <SetupInteractions>(431462786900688896);
#else
                slash.RegisterCommands <BanCommand>();
                slash.RegisterCommands <SetupInteractions>();
#endif
                slash.SlashCommandErrored += (x, y) =>
                {
                    Task.Run(async() =>
                    {
                        if (y.Exception is SlashExecutionChecksFailedException ex)
                        {
                            await y.Context.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource,
                                                                new DiscordInteractionResponseBuilder()
                                                                .WithContent("You do not have permission to run that command."));
                        }
                        else
                        {
                            x.Client.Logger.LogError(y.Exception, $"Slash Command Errored.");
                        }
                    });
                    return(Task.CompletedTask);
                };
            }

            System.Collections.Generic.IReadOnlyDictionary <int, DSharpPlus.Interactivity.InteractivityExtension>?interact = await this._client.UseInteractivityAsync(new());

            await this._rest.InitializeAsync();

            await this._verify.InitalizeAsync();
        }
Exemplo n.º 8
0
 protected override void InitializeProperties(System.Collections.Generic.IReadOnlyDictionary <string, IPropertyData> properties)
 {
     base.InitializeProperties(properties);
     StringExpressionHelpers.UpdateOnLoad(Properties[MongoDBWriteShared.Names.Criteria], properties, MongoDBWriteShared.Names.CriteriaExpressions, true);
     StringExpressionHelpers.UpdateOnLoad(Properties[MongoDBWriteShared.Names.UpdateOperation], properties, MongoDBWriteShared.Names.UpdateOperationExpressions, true);
 }
Exemplo n.º 9
0
 private IEnumerable <NotifierUpdater> _BuildNotifier(object soul, Type soul_type, System.Collections.Generic.IReadOnlyDictionary <PropertyInfo, int> propertyIds)
 {
     return(from p in _GetPropertys(soul_type, propertyIds)
            let property = p.Item2
                           let id = p.Item1
                                    where property.PropertyType.GetInterfaces().Any(t => t == typeof(ITypeObjectNotifiable))
                                    let propertyValue = property.GetValue(soul)
                                                        select new NotifierUpdater(id, propertyValue as ITypeObjectNotifiable));
 }
Exemplo n.º 10
0
 private IEnumerable <Tuple <int, PropertyInfo> > _GetPropertys(Type soul_type, System.Collections.Generic.IReadOnlyDictionary <PropertyInfo, int> property_ids)
 {
     return(from p in PropertyInfos
            select new Tuple <int, PropertyInfo>(property_ids[p], p));
 }
Exemplo n.º 11
0
 private IEnumerable <PropertyUpdater> _BuildProperty(object soul, Type soul_type, System.Collections.Generic.IReadOnlyDictionary <PropertyInfo, int> propertyIds)
 {
     foreach (var item in _GetPropertys(soul_type, propertyIds))
     {
         PropertyInfo property = item.Item2;
         var          id       = item.Item1;
         if (property.PropertyType.GetInterfaces().Any(t => t == typeof(IDirtyable)))
         {
             object     propertyValue = property.GetValue(soul);
             IDirtyable dirtyable     = propertyValue as IDirtyable;
             yield return(new PropertyUpdater(dirtyable, id));
         }
     }
 }