Пример #1
0
        public IEnumerable <Type> GetConcreteTypesDerivingFrom(Type baseType)
        {
            IEnumerable <Type> concreteDerivedTypes =
                ConcreteTypes.Where(baseType.IsAssignableFrom);

            return(concreteDerivedTypes);
        }
Пример #2
0
        private void TranslateFieldsToPath() // // Should be done via Reflexion!
        {
            MapPathToTypes.Clear();
#if UNITY_EDITOR
            System.Reflection.BindingFlags BindingFlagsPrivate = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance;

            var fieldPath = new List <string>(); // 0 - last one, last - first one!

            var AllTypes = typeof(KAU.Player.IProgressManagerLastTime).Assembly.GetTypes();

            var typeOfIdata = typeof(KAU.PlayerSystem.IData);

            // 1. get all IData
            var allListOfIData = (from typeToCheck in AllTypes
                                  where typeOfIdata.IsAssignableFrom(typeToCheck) && !typeToCheck.IsAbstract && !typeToCheck.IsInterface
                                  select typeToCheck
                                  ).ToList();

            // 2. for each IData - find enclosing type field recursivly
            foreach (var ConcreteTypes in allListOfIData)
            {
                fieldPath.Clear();
                // Debug.LogWarning(" Working TYpe : " + ConcreteTypes.ToString());
                GetNextEnclosedType(ConcreteTypes, fieldPath, BindingFlagsPrivate, 0, false);
                fieldPath.Reverse();
                string pathToUse = "";
                for (int i = 0; i < fieldPath.Count; i++)
                {
                    if (!string.IsNullOrEmpty(fieldPath[i]))
                    {
                        pathToUse += fieldPath[i];
                    }

                    if ((i + 1) < fieldPath.Count)
                    {
                        pathToUse += "/";
                    }
                }
                MapPathToTypes.Add(ConcreteTypes, pathToUse);
                Debug.LogWarning(" TYpe path : " + ConcreteTypes.ToString() + " path : " + pathToUse);
            }
#endif
        }