示例#1
0
        private static T BuildNLoad <T>(ContentBuilder builder, ContentManager content, string file, string processor, string importer)
        {
            builder.Clear();
            builder.Add(file, Path.GetFileName(file), importer, processor);

            string buildError = builder.Build();

            if (string.IsNullOrEmpty(buildError))
            {
                return(content.Load <T>(Path.GetFileName(file)));
            }
            throw new System.NullReferenceException(buildError);
        }
示例#2
0
        public static bool TryLoad <T>(this ContentBuilder builder, ContentManager content, string importer, string processor, string file, out T value)
        {
            builder.Clear();
            builder.Add(file, Path.GetFileName(file), importer, processor);

            string buildError = builder.Build();

            if (string.IsNullOrEmpty(buildError))
            {
                value = content.Load <T>(Path.GetFileName(file));
                return(true);
            }
            value = default(T);
            return(false);
        }