Ejemplo n.º 1
0
        static private bool MatchTriggerParameter(RSTriggerInfo inInfo, RSTypeInfo inTypeInfo)
        {
            if (inTypeInfo == null)
            {
                return(true);
            }

            if (inInfo.ParameterType == null)
            {
                return(inTypeInfo == RSBuiltInTypes.Void);
            }

            return(inTypeInfo.CanConvert(inInfo.ParameterType.Type));
        }
Ejemplo n.º 2
0
        public IEnumerator ScanAssembliesAsync(Action <float, string> inOnProgress = null)
        {
            if (m_IsLoaded)
            {
                yield break;
            }

            m_IsLoading = true;
            m_IsLoaded  = false;

            List <Assembly> allowedAssemblies = new List <Assembly>(GetAssembliesToScan());
            List <RSInfo>   toLink            = new List <RSInfo>();

            inOnProgress?.Invoke(0, "Loading groups");

            foreach (var groupInfo in Reflect.FindFields <RSGroupAttribute>(allowedAssemblies, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                RSGroupInfo groupMeta = new RSGroupInfo(groupInfo.Attribute, groupInfo.Info);
                m_Groups.Add(groupMeta.IdHash, groupMeta);
                groupInfo.Info.SetValue(null, groupMeta.GroupId);
                yield return(null);
            }

            inOnProgress?.Invoke(1f / 6, "Loading components");

            foreach (var componentInfo in Reflect.FindTypes <RSComponentAttribute>(allowedAssemblies))
            {
                RSComponentInfo componentMeta = new RSComponentInfo(componentInfo.Attribute, componentInfo.Info);
                m_Components.Add(componentMeta.IdHash, componentMeta);
                m_ComponentTypeMap.Add(componentInfo.Info, componentMeta);
                toLink.Add(componentMeta);
                yield return(null);
            }

            inOnProgress?.Invoke(2f / 6, "Loading queries");

            foreach (var queryInfo in Reflect.FindMethods <RSQueryAttribute>(allowedAssemblies, BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                RSQueryInfo queryMeta = new RSQueryInfo(queryInfo.Attribute, queryInfo.Info);
                m_Queries.Add(queryMeta.IdHash, queryMeta);
                toLink.Add(queryMeta);
                yield return(null);
            }

            inOnProgress?.Invoke(3f / 6, "Loading actions");

            foreach (var actionInfo in Reflect.FindMethods <RSActionAttribute>(allowedAssemblies, BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                RSActionInfo actionMeta = new RSActionInfo(actionInfo.Attribute, actionInfo.Info);
                m_Actions.Add(actionMeta.IdHash, actionMeta);
                toLink.Add(actionMeta);
                yield return(null);
            }

            inOnProgress?.Invoke(4f / 6, "Loading triggers");

            foreach (var triggerInfo in Reflect.FindFields <RSTriggerAttribute>(allowedAssemblies, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly))
            {
                RSTriggerInfo triggerMeta = new RSTriggerInfo(triggerInfo.Attribute, triggerInfo.Info);
                m_Triggers.Add(triggerMeta.IdHash, triggerMeta);
                triggerInfo.Info.SetValue(null, triggerMeta.TriggerId);
                toLink.Add(triggerMeta);
                yield return(null);
            }

            inOnProgress?.Invoke(5f / 6, "Linking elements");

            foreach (var meta in toLink)
            {
                meta.Link(TypeAssembly);
                yield return(null);
            }

            toLink.Clear();

            m_IsLoading = false;
            m_IsLoaded  = true;

            inOnProgress?.Invoke(1, "Done");
        }