Beispiel #1
0
        private bool CheckIsHardReferenceTo(Type a, Type b)
        {
            SyncRequirePlugin refRequireCheck = a.GetCustomAttribute <SyncRequirePlugin>();

            if (refRequireCheck == null)
            {
                return(false);
            }
            return(refRequireCheck.RequirePluguins.Contains(b));
        }
Beispiel #2
0
        private bool LateLoad(Type a)
        {
            SyncRequirePlugin     requireAttr       = a.GetCustomAttribute <SyncRequirePlugin>();
            SyncSoftRequirePlugin softRequirePlugin = a.GetCustomAttribute <SyncSoftRequirePlugin>();
            IEnumerable <SyncPluginDependency> deps = a.GetCustomAttributes <SyncPluginDependency>();
            SyncPluginID pid = a.GetCustomAttribute <SyncPluginID>();

            if (deps != null)
            {
                foreach (var item in deps)
                {
                    if (loadedList.Any(p => p.GetCustomAttribute <SyncPluginID>()?.GUID == item.GUID))
                    {
                        continue;
                    }
                    else
                    {
                        if (CheckIsReferenceTo(allList.FirstOrDefault(p => p.GetCustomAttribute <SyncPluginID>()?.GUID == item.GUID), pid.GUID))
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
            }

            if (requireAttr != null)
            {
                foreach (var item in requireAttr.RequirePluguins)
                {
                    //Dependency was been loaded
                    if (loadedList.Contains(item))
                    {
                        continue;
                    }
                    else
                    {
                        //Check cycle reference
                        if (CheckIsReferenceTo(item, a))
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
            }

            if (softRequirePlugin != null)
            {
                foreach (var item in softRequirePlugin.RequirePluguins)
                {
                    Type s = allList.FirstOrDefault(p => p.Name == item);
                    if (s == null)
                    {
                        continue;
                    }
                    else
                    {
                        if (CheckIsReferenceTo(s, a))
                        {
                            return(false);
                        }
                        if (!loadedList.Contains(s))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }