Exemplo n.º 1
0
        public static void Init(bool dispose = true)
        {
            if (dispose)
            {
                if (Textures != null)
                {
                    foreach (var texture in Textures.Values)
                    {
                        texture.Dispose();
                    }
                }

                if (Uncached != null)
                {
                    foreach (var texture in Uncached)
                    {
                        texture.Dispose();
                    }
                }
            }

            GfxObjCache.Init();
            SetupCache.Init();

            Textures = new Dictionary <uint, Texture2D>();
            Uncached = new List <Texture2D>();
        }
        private static bool CheckAndSetupAssociatedMapping(Type associatedDtoMapping)
        {
            if (!associatedDtoMapping.IsSubclassOf(typeof(EfGenericDtoBase)))
            {
                throw new InvalidOperationException("You have not supplied a class based on EfGenericDto to set up the mapping.");
            }

            if (SetupCache.ContainsKey(associatedDtoMapping))
            {
                return(SetupCache[associatedDtoMapping].NeedsDecompile);
            }

            //Otherwise it has not been set up so create it and then get flag
            var associatedDto = Activator.CreateInstance(associatedDtoMapping, new object[] { });       //this sets up the mapping

            return(((EfGenericDtoBase)associatedDto).NeedsDecompile);
        }
        /// <summary>
        /// Constructor. This ensures that the mappings are set up on creation of the class
        /// and sets the NeedsDecompile property based on checking
        /// </summary>
        protected EfGenericDtoBase()
        {
            var setupInfo = SetupCache.GetOrAdd(GetType(), setup => MapperSetup());

            NeedsDecompile = setupInfo.NeedsDecompile;
        }