CSharpGL.ManifestResourceLoader.GetLocation C# (CSharp) Method

GetLocation() static private method

static private GetLocation ( string textFileName, int stackIndex, Assembly &executingAssembly, string &location ) : void
textFileName string
stackIndex int
executingAssembly System.Reflection.Assembly
location string
return void
        internal static void GetLocation(string textFileName, int stackIndex, out Assembly executingAssembly, out string location)
        {
            StackTrace stack = new StackTrace();
            StackFrame frame = stack.GetFrame(stackIndex);
            MethodBase method = frame.GetMethod();
            Type type = method.ReflectedType;
            executingAssembly = type.Assembly; //Assembly.GetExecutingAssembly();
            string pathToDots = textFileName.Replace("\\", ".");
            location = string.Format("{0}.{1}", executingAssembly.GetName().Name, pathToDots);
        }

Usage Example

Ejemplo n.º 1
0
            internal static TeapotModel Load()
            {
                Assembly executingAssembly;
                string   location;

                ManifestResourceLoader.GetLocation(@"IBufferables\TeapotModel.obj", 1, out executingAssembly, out location);

                using (Stream stream = executingAssembly.GetManifestResourceStream(location))
                {
                    using (var reader = new StreamReader(stream))
                    {
                        TeapotModel model = LoadModels(reader);
                        GenNormals(model);

                        return(model);
                    }
                }
            }