Example #1
0
        private static void FillMap(IDictionary <string, List <Type> > map)
        {
            Type entityType = typeof(Entity);

            Type[] types = Assembly.GetExecutingAssembly().GetTypes();
            foreach (Type type in types)
            {
                if (entityType.IsAssignableFrom(type))
                {
                    object[] attributes = type.GetCustomAttributes(typeof(MetaDataAttribute), false);
                    if (attributes.Length > 0)
                    {
                        MetaDataAttribute attribute = (MetaDataAttribute)attributes[0];
                        string            token     = attribute.AssetTypeToken;
                        if (!string.IsNullOrEmpty(token))
                        {
                            List <Type> list;
                            if (!map.TryGetValue(token, out list))
                            {
                                map[token] = list = new List <Type>();
                            }
                            list.Add(type);
                        }
                    }
                }
            }

            foreach (List <Type> list in map.Values)
            {
                list.Sort(delegate(Type a, Type b) { return(Comparer <int?> .Default.Compare(GetAssetStateFilter(a), GetAssetStateFilter(b))); });
                list.Reverse();
            }
        }
Example #2
0
        private static byte?GetAssetStateFilter(ICustomAttributeProvider type)
        {
            object[]          attributes = type.GetCustomAttributes(typeof(MetaDataAttribute), false);
            MetaDataAttribute attribute  = (MetaDataAttribute)attributes[0];

            return(attribute.AssetState);
        }