Beispiel #1
0
        private ISQLiteSerializer <T> GetSerializer <T>()
        {
            if (NativeSerializers.TryGetValue(typeof(T), out var serializer))
            {
                return((ISQLiteSerializer <T>)serializer);
            }

            return(new GenericSerializer <T>(_serializer));
        }
Beispiel #2
0
        public static TypeModel Create(IEnumerable <Type> supportedTypes)
        {
            var types         = new List <Type>();
            var nonSurrogates = new List <Type>();

            foreach (var type in supportedTypes)
            {
                if (IsSurrogate(type))
                {
                    types.Add(type);
                }
                else
                {
                    if (BuiltInSurrogates.TryGetValue(type, out var surrogateType))
                    {
                        types.Add(surrogateType);
                    }
                    nonSurrogates.Add(type);
                }
            }

            types.AddRange(nonSurrogates);

            var model = new TypeModel();

            foreach (var type in types)
            {
                model.Add(type);
            }
            return(model);
        }
 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);
Beispiel #4
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);
        }