Пример #1
0
        public bool CanConvert(RSTypeInfo inTarget)
        {
            if ((Flags & TypeFlags.SkipConversionCheck) != 0)
            {
                return(true);
            }

            if (inTarget == this || inTarget == m_BaseType)
            {
                return(true);
            }

            if (inTarget == RSBuiltInTypes.String || inTarget == RSBuiltInTypes.Any)
            {
                return(true);
            }

            if ((inTarget.Flags & TypeFlags.IsEnum) != 0 && (Flags & TypeFlags.IsEnum) != 0)
            {
                return(true);
            }

            if (m_Conversions != null && m_Conversions.Contains(inTarget))
            {
                return(true);
            }

            if (m_BaseType != null)
            {
                return(m_BaseType.CanConvert(inTarget));
            }

            return(false);
        }
Пример #2
0
        internal override void Link(RSTypeAssembly inAssembly)
        {
            m_MethodSettings.Configure(m_MethodInfo, m_Parameters, true);
            OwnerType = m_MethodSettings.BoundType;

            ReturnType     = RSInterop.RSTypeFor(m_MethodInfo.ReturnType, inAssembly);
            m_DefaultValue = m_DefaultSystemValue != null?RSInterop.ToRSValue(m_DefaultSystemValue) : ReturnType.DefaultValue;

            GenerateParameters(inAssembly);
        }
Пример #3
0
        private bool TryCreateMeta(Type inType, out RSTypeInfo outMetadata)
        {
            if (inType.IsEnum)
            {
                Enum defaultVal = (Enum)Enum.ToObject(inType, 0);
                outMetadata = new RSTypeInfo(inType, null, RSValue.FromEnum(defaultVal));
                outMetadata.InitializeEnum();
                return(true);
            }

            outMetadata = null;
            return(false);
        }
Пример #4
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));
        }
Пример #5
0
        /// <summary>
        /// Outputs to a collection of all trigger metadatas.
        /// </summary>
        public void GetAllTriggers(ICollection <RSTriggerInfo> outTriggers, RSTypeInfo inParameterType = null)
        {
            Assert.True(outTriggers != null, "Cannot output triggers to null collection");

            foreach (var triggerMeta in m_Triggers.Values)
            {
                if (!MatchTriggerParameter(triggerMeta, inParameterType))
                {
                    continue;
                }

                outTriggers.Add(triggerMeta);
            }
        }
Пример #6
0
        private bool TryGetMeta(Type inType, out RSTypeInfo outMetadata)
        {
            if (m_Types.TryGetValue(inType, out outMetadata))
            {
                return(true);
            }

            foreach (var assembly in m_Dependencies)
            {
                if (assembly.TryGetMeta(inType, out outMetadata))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #7
0
        /// <summary>
        /// Outputs to a collection of all query metadatas.
        /// </summary>
        public void GetAllQueries(ICollection <RSQueryInfo> outQueries, RSTypeInfo inReturnType = null, bool inbNoParams = false)
        {
            Assert.True(outQueries != null, "Cannot output queries to null collection");

            foreach (var queryMeta in m_Queries.Values)
            {
                if (inReturnType != null && !queryMeta.ReturnType.CanConvert(inReturnType))
                {
                    continue;
                }

                if (inbNoParams && queryMeta.Parameters != null && queryMeta.Parameters.Length > 0)
                {
                    continue;
                }

                outQueries.Add(queryMeta);
            }
        }
Пример #8
0
 internal void SetBase(RSTypeInfo inBase)
 {
     m_BaseType = inBase;
     AddConversions(m_BaseType);
 }
Пример #9
0
 public void AddTypeMeta(RSTypeInfo inType)
 {
     m_Types.Add(inType.SystemType, inType);
 }
Пример #10
0
        /// <summary>
        /// Outputs to a collection of queries directly associated with the given entity.
        /// </summary>
        public void GetAllQueriesForEntity(IRSEntity inEntity, ICollection <RSQueryInfo> outQueries, RSTypeInfo inReturnType = null, bool inbNoParams = false)
        {
            Assert.True(outQueries != null, "Cannot output queries to null collection");
            Assert.True(inEntity != null, "Cannot get queries for null entity");

            GetAllQueriesForType(m_EntityType, outQueries, inReturnType, inbNoParams);
            foreach (var component in inEntity.GetRSComponentTypes(this))
            {
                Assert.True(component != null, "Null component");
                GetAllQueriesForType(component, outQueries, inReturnType, inbNoParams);
            }
        }
Пример #11
0
        /// <summary>
        /// Outputs to a collection of queries associated with the given type.
        /// </summary>
        public void GetAllQueriesForType(Type inType, ICollection <RSQueryInfo> outQueries, RSTypeInfo inReturnType = null, bool inbNoParams = false)
        {
            Assert.True(outQueries != null, "Cannot output queries to null collection");
            Assert.True(inType != null, "Cannot get queries for null type");

            foreach (var queryMeta in m_Queries.Values)
            {
                Type type = queryMeta.OwnerType;
                if (type != null && type.IsAssignableFrom(inType))
                {
                    if (inReturnType != null && !queryMeta.ReturnType.CanConvert(inReturnType))
                    {
                        continue;
                    }

                    if (inbNoParams && queryMeta.Parameters != null && queryMeta.Parameters.Length > 0)
                    {
                        continue;
                    }

                    outQueries.Add(queryMeta);
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Outputs to a collection of triggers directly associated with the given entity.
        /// </summary>
        public void GetAllTriggersForEntity(IRSEntity inEntity, ICollection <RSTriggerInfo> outTriggers, RSTypeInfo inParameterType = null)
        {
            Assert.True(outTriggers != null, "Cannot output triggers to null collection");
            Assert.True(inEntity != null, "Cannot get triggers for null entity data");

            GetAllTriggersForType(m_EntityType, outTriggers, inParameterType);
            foreach (var componentType in inEntity.GetRSComponentTypes(this))
            {
                Assert.True(componentType != null, "Null component data");
                GetAllTriggersForType(componentType, outTriggers, inParameterType);
            }
        }
Пример #13
0
        /// <summary>
        /// Outputs to a collection of triggers associated with the given type.
        /// </summary>
        public void GetAllTriggersForType(Type inType, ICollection <RSTriggerInfo> outTriggers, RSTypeInfo inParameterType = null)
        {
            Assert.True(outTriggers != null, "Cannot output triggers to null collection");
            Assert.True(inType != null, "Cannot get triggers for null type");

            foreach (var triggerMeta in m_Triggers.Values)
            {
                Type type = triggerMeta.OwnerType;
                if (type != null && type.IsAssignableFrom(inType))
                {
                    if (!MatchTriggerParameter(triggerMeta, inParameterType))
                    {
                        continue;
                    }

                    outTriggers.Add(triggerMeta);
                }
            }
        }
Пример #14
0
 internal void Link(RSTypeAssembly inAssembly)
 {
     Type = RSInterop.RSTypeFor(m_FieldType, inAssembly);
 }