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

            return(new GenericSerializer <T>(_serializer));
        }
コード例 #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);
        }
コード例 #3
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);
コード例 #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);
        }