Beispiel #1
0
        private void CacheStatic(IEnumerable <Assembly> inAssemblies)
        {
            if (m_StaticMethods != null)
            {
                return;
            }

            m_StaticMethods = new Dictionary <StringHash32, MethodDescription>(32);
            inAssemblies    = inAssemblies ?? Reflect.FindAllUserAssemblies();

            foreach (var attrPair in Reflect.FindMethods <TAttr>(inAssemblies, StaticAttributeSearch, false))
            {
                attrPair.Attribute.AssignId(attrPair.Info);

                if (m_StaticMethods.ContainsKey(attrPair.Attribute.Id))
                {
                    UnityEngine.Debug.LogErrorFormat("[MethodCache] Multiple instances of static method with id '{0}' found", attrPair.Attribute.Id.ToDebugString());
                    continue;
                }

                MethodDescription desc = CreateDescription(attrPair.Attribute, attrPair.Info);
                if (!desc.TryProcess(this))
                {
                    UnityEngine.Debug.LogErrorFormat("[MethodCache] Static method '{0}' on type '{1}' is incompatible", desc.Id.ToDebugString(), desc.Method.DeclaringType.FullName);
                    continue;
                }

                m_StaticMethods.Add(desc.Id, desc);
            }
        }
Beispiel #2
0
            public virtual bool TryProcess(MethodCache <TAttr> inParent)
            {
                foreach (var attrPair in Reflect.FindMethods <TAttr>(Type, InstanceAttributeSearch))
                {
                    attrPair.Attribute.AssignId(attrPair.Info);

                    if (m_Methods.ContainsKey(attrPair.Attribute.Id))
                    {
                        UnityEngine.Debug.LogErrorFormat("[MethodCache] Multiple instances of method with id '{0}' found on type '{1}'", attrPair.Attribute.Id.ToDebugString(), Type.FullName);
                        continue;
                    }

                    MethodDescription desc = inParent.CreateDescription(attrPair.Attribute, attrPair.Info);
                    if (!desc.TryProcess(inParent))
                    {
                        UnityEngine.Debug.LogErrorFormat("[MethodCache] Method '{0}' on type '{1}' is incompatible", desc.Id, Type.FullName);
                        continue;
                    }

                    m_Methods.Add(desc.Id, desc);
                }

                return(true);
            }