예제 #1
0
        internal void GeneratePersistFields(RSTypeAssembly inAssembly)
        {
            using (PooledList <RSPersistFieldInfo> persistFields = PooledList <RSPersistFieldInfo> .Alloc())
            {
                foreach (var persistField in Reflect.FindFields <RSPersistFieldAttribute>(OwnerType, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
                {
                    FieldInfo field = persistField.Info;
                    RSPersistFieldAttribute fieldAttr = persistField.Attribute;

                    RSPersistFieldInfo fieldInfo = new RSPersistFieldInfo(fieldAttr, field);
                    persistFields.Add(fieldInfo);
                }

                if (persistFields.Count > 0)
                {
                    m_PersistFields = new Dictionary <string, RSPersistFieldInfo>(persistFields.Count);
                    for (int i = 0; i < persistFields.Count; ++i)
                    {
                        RSPersistFieldInfo info = persistFields[i];
                        info.Link(inAssembly);
                        m_PersistFields.Add(info.Name, info);
                    }
                }
            }
        }
예제 #2
0
        private IEnumerable <IRSRuntimeEntity> EnumerateEntityLinks(MultiReturn <IRSRuntimeEntity> inEntities, string inLinks, bool inbUseFirstLink)
        {
            using (PooledList <StringSlice> paths = PooledList <StringSlice> .Alloc())
            {
                int sliceCount = StringSlice.Split(inLinks, EntityLinkSplitChars, StringSplitOptions.None, paths);

                foreach (var entity in inEntities)
                {
                    IRSRuntimeEntity currentEntity = entity;
                    for (int i = 0; currentEntity != null && i < sliceCount - 1; ++i)
                    {
                        StringSlice path = paths[i];
                        currentEntity = currentEntity.Links?.EntityWithLink(path);
                    }

                    if (currentEntity != null)
                    {
                        var links = currentEntity.Links;
                        if (links == null)
                        {
                            continue;
                        }

                        if (inbUseFirstLink)
                        {
                            yield return(links.EntityWithLink(paths[sliceCount - 1]));
                        }
                        else
                        {
                            foreach (var linkedEntity in links.EntitiesWithLink(paths[sliceCount - 1]))
                            {
                                yield return(linkedEntity);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Performs an ordered sequence of actions.
        /// </summary>
        public IEnumerator PerformActions(RSActionData[] inActions)
        {
            using (new SharedRef <ExecutionScope>(this))
            {
                if (inActions == null || inActions.Length <= 0)
                {
                    yield break;
                }

                for (int i = 0; i < inActions.Length; ++i)
                {
                    if (!inActions[i].Enabled)
                    {
                        continue;
                    }

                    var ret = PerformAction(inActions[i]);

                    if (ret.Set != null)
                    {
                        PooledList <IEnumerator> waits = null;

                        foreach (var val in ret.Set)
                        {
                            switch (val.Type)
                            {
                            case ActionResultType.Iterator:
                            {
                                if (waits == null)
                                {
                                    waits = PooledList <IEnumerator> .Alloc();
                                }

                                waits.Add((IEnumerator)val.Value);
                                break;
                            }
                            }
                        }

                        if (waits != null && waits.Count > 0)
                        {
                            IEnumerator combinedWait = Routine.Combine(waits);
                            waits.Dispose();
                            waits = null;

                            yield return(combinedWait);
                        }
                    }
                    else
                    {
                        switch (ret.Single.Type)
                        {
                        case ActionResultType.Iterator:
                            yield return(ret.Single.Value);

                            break;
                        }
                    }
                }
            }
        }