当前位置: 首页>>代码示例>>C#>>正文


C# ConfigFile.Load方法代码示例

本文整理汇总了C#中ConfigFile.Load方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigFile.Load方法的具体用法?C# ConfigFile.Load怎么用?C# ConfigFile.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigFile的用法示例。


在下文中一共展示了ConfigFile.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadWheelsFromFiles

        /// <summary>
        /// Go through our media/wheels/ directory and find all of the wheel definitions we have, then make dictionaries out of them
        /// and add them to our one big dictionary.		
        /// </summary>
        public void ReadWheelsFromFiles()
        {
            // since we can run this whenever (like when we're tweaking files), we want to clear our dictionary first
            wheels.Clear();

            // get all of the filenames of the files in media/wheels/
            IEnumerable<string> files = Directory.EnumerateFiles("media/vehicles/", "*.wheel", SearchOption.AllDirectories);

            foreach (string filename in files) {
                // I forgot ogre had this functionality already built in
                ConfigFile cfile = new ConfigFile();
                cfile.Load(filename, "=", true);

                // each .wheel file can have multiple [sections]. We'll use each section name as the wheel name
                ConfigFile.SectionIterator sectionIterator = cfile.GetSectionIterator();
                while (sectionIterator.MoveNext()) {
                    string wheelname = sectionIterator.CurrentKey;
                    // make a dictionary
                    var wheeldict = new Dictionary<string, float>();
                    // go over every property in the file and add it to the dictionary, parsing it as a float
                    foreach (KeyValuePair<string, string> pair in sectionIterator.Current) {
                        wheeldict.Add(pair.Key, float.Parse(pair.Value, culture));
                    }

                    wheels[wheelname] = wheeldict;
                }

                cfile.Dispose();
                sectionIterator.Dispose();
            }
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:35,代码来源:WheelFactory.cs

示例2: SetupResources

        // Override resource sources (include Quake3 archives)
        public override void SetupResources()
        {
            ConfigFile cf = new ConfigFile();
            cf.Load("quake3settings.cfg", "\t:=", true);
            quakePk3 = cf.GetSetting("Pak0Location");
            quakeLevel = cf.GetSetting("Map");

            base.SetupResources();
            ResourceGroupManager.Singleton.AddResourceLocation(quakePk3, "Zip", ResourceGroupManager.Singleton.WorldResourceGroupName, true);
        }
开发者ID:andyhebear,项目名称:likeleon,代码行数:11,代码来源:Main.cs

示例3: Init

        public void Init()
        {
            // Create root object
             mRoot = new Root();

             // Define Resources
             ConfigFile cf = new ConfigFile();
             cf.Load("resources.cfg", "\t:=", true);
             ConfigFile.SectionIterator seci = cf.GetSectionIterator();
             String secName, typeName, archName;

             while (seci.MoveNext())
             {
            secName = seci.CurrentKey;
            ConfigFile.SettingsMultiMap settings = seci.Current;
            foreach (KeyValuePair<string, string> pair in settings)
            {
               typeName = pair.Key;
               archName = pair.Value;
               ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
            }
             }

             // Setup RenderSystem
             RenderSystem rs = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
             // or use "OpenGL Rendering Subsystem"
             mRoot.RenderSystem = rs;
             rs.SetConfigOption("Full Screen", "No");
             rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

             // Create Render Window
             mRoot.Initialise(false, "Main Ogre Window");
             NameValuePairList misc = new NameValuePairList();
             misc["externalWindowHandle"] = Handle.ToString();
             mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

             // Init resources
             TextureManager.Singleton.DefaultNumMipmaps = 5;
             ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

             // Create a Simple Scene
             SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
             Camera cam = mgr.CreateCamera("Camera");
             cam.AutoAspectRatio = true;
             mWindow.AddViewport(cam);

             Entity ent = mgr.CreateEntity("ninja", "ninja.mesh");
             mgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent);

             cam.Position = new Vector3(0, 200, -400);
             cam.LookAt(ent.BoundingBox.Center);
        }
开发者ID:andyhebear,项目名称:mogresdk,代码行数:52,代码来源:Form1.cs

示例4: Create

        public static IDbProvider Create(ConfigFile configFile)
        {
            configFile.Load();

            string dbType = configFile.Get(DbConstants.KEY_DB_TYPE);

            log.Info("Creating provider for" + dbType);

            switch (dbType)
            {
                case DbConstants.DB_TYPE_MYSQL:
                    return new MySqlDbProvider(configFile);
                case DbConstants.DB_TYPE_SQLITE:
                    return new SqliteDbProvider(configFile);
                default:
                    throw new Exception(string.Format("Don't know Data Provider type {0}", dbType));
            }
        }
开发者ID:ldemidov,项目名称:WebGoat.NET,代码行数:18,代码来源:DbProviderFactory.cs

示例5: InitResources

        /// <summary>
        /// Basically adds all of the resource locations but doesn't actually load anything.
        /// </summary>
        private static void InitResources()
        {
            ConfigFile file = new ConfigFile();
            file.Load("media/plugins/resources.cfg", "\t:=", true);
            ConfigFile.SectionIterator sectionIterator = file.GetSectionIterator();

            while (sectionIterator.MoveNext()) {
                string currentKey = sectionIterator.CurrentKey;
                foreach (KeyValuePair<string, string> pair in sectionIterator.Current) {
                    string key = pair.Key;
                    string name = pair.Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(name, key, currentKey);
                }
            }

            file.Dispose();
            sectionIterator.Dispose();
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:21,代码来源:LKernel+(ogre+initialisers).cs

示例6: DefineResources

        void DefineResources()
        {
            ConfigFile cf = new ConfigFile();
             cf.Load("resources.cfg", "\t:=", true);
             ConfigFile.SectionIterator seci = cf.GetSectionIterator();
             String secName, typeName, archName;

             while (seci.MoveNext())
             {
                 secName = seci.CurrentKey;
                 ConfigFile.SettingsMultiMap settings = seci.Current;
                 foreach (KeyValuePair<string, string> pair in settings)
                 {
                     typeName = pair.Key;
                     archName = pair.Value;
                     ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                 }
             }
        }
开发者ID:andyhebear,项目名称:mogresdk,代码行数:19,代码来源:Program.cs

示例7: Initialise

        public bool Initialise()
        {
            m_Shutdown = false;

            m_Rand = new Random();

            new Mogre.LogManager();
            m_Log = Mogre.LogManager.Singleton.CreateLog("OgreLogfile.log", true, true, false);

            m_Root = new Root();
            ConfigFile cf = new ConfigFile();
            cf.Load("Resources.cfg", "\t:=", true);

            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            while (seci.MoveNext())
            {
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                    ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
            }

            if (!m_Root.RestoreConfig())    // comment this line to view configuration dialog box
                if (!m_Root.ShowConfigDialog())
                    return false;

            m_RenderWindow = m_Root.Initialise(true);
            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            m_SceneManager = m_Root.CreateSceneManager(SceneType.ST_GENERIC);
            m_Camera = m_SceneManager.CreateCamera("MainCamera");
            m_Viewport = m_RenderWindow.AddViewport(m_Camera);
            m_Camera.NearClipDistance = 0.1f;
            m_Camera.FarClipDistance = 1000.0f;

            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr windowHnd;
            m_RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            m_InputManager = MOIS.InputManager.CreateInputSystem(pl);

            m_Keyboard = (MOIS.Keyboard)m_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
            m_Mouse = (MOIS.Mouse)m_InputManager.CreateInputObject(MOIS.Type.OISMouse, true);

            m_NewtonWorld = new World();
            m_NewtonWorld.SetWorldSize(new AxisAlignedBox(-500, -500, -500, 500, 500, 500));
            m_NewtonDebugger = new Debugger(m_NewtonWorld);
            m_NewtonDebugger.Init(m_SceneManager);

            m_GameCamera = new GameCamera();
            m_ObjectManager = new ObjectManager();
            m_StateManager = new StateManager();
            m_PhysicsManager = new PhysicsManager();
            m_SoundDict = new SoundDict();

            /*
             * To co tu mamy nalezy przeniesc jak najszybciej do ogitora
             * Materialy dla kazdej mapy moga byc inne inne parametry inne powiazania itp wiec tworzone
             * sa oddzielnie dla kazdej nowej mapy, a potem przy obiektach konkretny material jest przypsiywany
             * przy starcie ladowania physicsmanager powinien byc wyczyszczony
             */

            //inicjalizacja konkretnych obiektow, w sumie tylko nadanie nazw w dictionary
            m_PhysicsManager.addMaterial("Metal");
            //podstawowe
            m_PhysicsManager.addMaterial("Ground");
            m_PhysicsManager.addMaterial("Trigger");
            m_PhysicsManager.addMaterial("Player");
            m_PhysicsManager.addMaterial("NPC");

            //laczenie materialow w pary
            //dla kazdej mapy rozne powiazania (zapewne beda sie powtarzac ale im wieksza ilosc
            //materialow tym wieksze obciazenie dla silnika wiec nalezy to ograniczac
            //dla kazdej pary materialow mozna ustawic rozne parametry kolizji
            //jak tarcie, elastycznosc, miekkosc kolizji oraz callback ktory jest wywolywany przy kolizji
            m_PhysicsManager.addMaterialPair("Metal", "Metal");
            m_PhysicsManager.getMaterialPair("MetalMetal").SetDefaultFriction(1.5f, 1.4f);
            m_PhysicsManager.setPairCallback("MetalMetal", "MetalCallback");

            //obowiazkowe
            m_PhysicsManager.addMaterialPair("Trigger", "Player");//wyzwalacze pozycja obowiazkowa
            m_PhysicsManager.setPairCallback("TriggerPlayer", "TriggerCallback");

            //obowiazkowe
            m_PhysicsManager.addMaterialPair("Ground", "Player");//ground material podstawowy
            m_PhysicsManager.getMaterialPair("GroundPlayer").SetDefaultElasticity(0);
            m_PhysicsManager.setPairCallback("GroundPlayer", "GroundPlayerCallback");

            // NPC:
            //m_PhysicsManager.addMaterialPair("NPC", "NPC");//ground material podstawowy
            //m_PhysicsManager.getMaterialPair("NPCNPC").SetDefaultElasticity(0);
            //m_PhysicsManager.setPairCallback("NPCNPC", "NPCNPCCallback");

            //m_PhysicsManager.addMaterialPair("Ground", "NPC");//ground material podstawowy
            //m_PhysicsManager.getMaterialPair("GroundNPC").SetDefaultElasticity(0);
            // m_PhysicsManager.setPairCallback("GroundNPC", "GroundPlayerCallback");
            /*
                                    * Koniec inicjalizacji materialow ktora musi sie znalezc w opisie mapy, dla niekumatych w ogitorze.
                                    */
//.........这里部分代码省略.........
开发者ID:secred,项目名称:Tachycardia,代码行数:101,代码来源:Core.cs

示例8: ImportResources

        private void ImportResources()
        {
            ConfigFile config = new ConfigFile();
            config.Load("resources.cfg", "=", true);

            ConfigFile.SectionIterator itr = config.GetSectionIterator();
            while (itr.MoveNext())
            {
                foreach (var line in itr.Current)
                    ResourceGroupManager.Singleton.AddResourceLocation(line.Value, line.Key, itr.CurrentKey);
            }
        }
开发者ID:nigelchanyk,项目名称:Archetype,代码行数:12,代码来源:Application.cs

示例9: InitMogre

        public void InitMogre()
        {
            //-----------------------------------------------------
            // 1 enter ogre
            //-----------------------------------------------------
            root = new Root();

            //-----------------------------------------------------
            // 2 configure resource paths
            //-----------------------------------------------------
            ConfigFile cf = new ConfigFile();
            cf.Load("resources.cfg", "\t:=", true);

            // Go through all sections & settings in the file
            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            String secName, typeName, archName;

            // Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
            while (seci.MoveNext()) {
                secName = seci.CurrentKey;
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings) {
                    typeName = pair.Key;
                    archName = pair.Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                }
            }

            //-----------------------------------------------------
            // 3 Configures the application and creates the window
            //-----------------------------------------------------
            bool foundit = false;
            foreach (RenderSystem rs in root.GetAvailableRenderers()) {
                root.RenderSystem = rs;
                String rname = root.RenderSystem.Name;
                if (rname == "Direct3D9 Rendering Subsystem") {
                    foundit = true;
                    break;
                }
            }

            if (!foundit)
                return; //we didn't find it... Raise exception?

            //we found it, we might as well use it!
            root.RenderSystem.SetConfigOption("Full Screen", "No");
            root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");

            root.Initialise(false);
            NameValuePairList misc = new NameValuePairList();
            misc["externalWindowHandle"] = hWnd.ToString();
            window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            //-----------------------------------------------------
            // 4 Create the SceneManager
            //
            //		ST_GENERIC = octree
            //		ST_EXTERIOR_CLOSE = simple terrain
            //		ST_EXTERIOR_FAR = nature terrain (depreciated)
            //		ST_EXTERIOR_REAL_FAR = paging landscape
            //		ST_INTERIOR = Quake3 BSP
            //-----------------------------------------------------
            sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
            sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);

            //-----------------------------------------------------
            // 5 Create the camera
            //-----------------------------------------------------
            camera = sceneMgr.CreateCamera("SimpleCamera");
            camera.Position = new Vector3(0f, 0f, 100f);
            // Look back along -Z
            camera.LookAt(new Vector3(0f, 0f, -300f));
            camera.NearClipDistance = 5;

            viewport = window.AddViewport(camera);
            viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f);

            Entity ent = sceneMgr.CreateEntity("ogre", "ogrehead.mesh");
            SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("ogreNode");
            node.AttachObject(ent);
        }
开发者ID:andyhebear,项目名称:mogrelibrarys,代码行数:83,代码来源:MogreForm.cs

示例10: setupResources

        void setupResources() {
            // Load resource paths from config file
            var cf = new ConfigFile();
            cf.Load(RESOURCES_CFG, "\t:=", true);

            // Go through all sections & settings in the file
            var seci = cf.GetSectionIterator();
            while (seci.MoveNext()) {
                foreach (var pair in seci.Current) {
                    ResourceGroupManager.Singleton.AddResourceLocation(
                        pair.Value, pair.Key, seci.CurrentKey);
                }
            }
        }
开发者ID:andyhebear,项目名称:mogre-procedural,代码行数:14,代码来源:MogreForm.cs

示例11: DefineResources

        /// <summary>
        /// Process the config file and add all the proper resource locations
        /// </summary>
        private void DefineResources()
        {
            // load the configuration file
            ConfigFile cf = new ConfigFile();
            cf.Load(RESOURCE_FILE, "\t:=", true);

            // process each section in the configuration file
            ConfigFile.SectionIterator itr = cf.GetSectionIterator();
            while (itr.MoveNext())
            {
                string sectionName = itr.CurrentKey;
                ConfigFile.SettingsMultiMap smm = itr.Current;

                // each section is set of key/value pairs
                // value is the resource type (FileSystem, Zip, etc)
                // key is the location of the resource set
                foreach (KeyValuePair<string, string> kv in smm)
                {
                    // add the resource location to Ogre
                    ResourceGroupManager.Singleton.AddResourceLocation(kv.Value, kv.Key, sectionName);
                }
            }
        }
开发者ID:andyhebear,项目名称:ymfas,代码行数:26,代码来源:TestEngine_Init.cs

示例12: LoadResources

        protected virtual void LoadResources()
        {
            // Load resource paths from config file
            var cf = new ConfigFile();
            cf.Load(mResourcesCfg, "\t:=", true);

            // Go through all sections & settings in the file
            var seci = cf.GetSectionIterator();
            while (seci.MoveNext()) {
                foreach (var pair in seci.Current) {
                    ResourceGroupManager.Singleton.AddResourceLocation(
                        pair.Value, pair.Key, seci.CurrentKey);
                }
            }

            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
        }
开发者ID:vavrekmichal,项目名称:StrategyGame,代码行数:17,代码来源:BaseApplication.cs

示例13: Initiliase

        public bool Initiliase(bool autoCreateWindow)
        {
            root = new Root();

            ConfigFile cf = new ConfigFile();
            cf.Load("resources.cfg", "\t:=", true);

            // Go through all sections & settings in the file
            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            String secName, typeName, archName;

            // Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
            while (seci.MoveNext())
            {
                secName = seci.CurrentKey;
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                {
                    typeName = pair.Key;
                    archName = pair.Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                }
            }

            //-----------------------------------------------------
            // 3 Configures the application and creates the window
            //-----------------------------------------------------
            string renderSystem = "Direct3D9 Rendering Subsystem";

            if (!FindRenderSystem(renderSystem))
                throw new Exception("Unable to find render system: " + renderSystem);

            //we found it, we might as well use it!
            root.RenderSystem.SetConfigOption("VSync", "Yes");      // graphics card doesn't work so hard, physics engine should be more stable
            root.RenderSystem.SetConfigOption("Full Screen", "No");
            root.RenderSystem.SetConfigOption("Video Mode", "1024 x 768 @ 32-bit colour");

            // scene manager
            sceneManager = root.CreateSceneManager(SceneType.ST_GENERIC);

            // render window
            this.renderWindow = root.Initialise(autoCreateWindow, "GlueEngine");
            return true;
        }
开发者ID:andyhebear,项目名称:glueeengine,代码行数:45,代码来源:GraphicsManager.cs

示例14: Initialise

        public void Initialise()
        {
            m_Root = new Root();
            ConfigFile cf = new ConfigFile();
            cf.Load("Resources.cfg", "\t:=", true);

            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            while (seci.MoveNext())
            {
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                    ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
            }

            if (!m_Root.RestoreConfig())
                if (!m_Root.ShowConfigDialog())
                    return;

            m_RenderWindow = m_Root.Initialise(true);
            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            m_SceneManager = m_Root.CreateSceneManager(SceneType.ST_GENERIC);
            m_Camera = m_SceneManager.CreateCamera("MainCamera");
            m_Viewport = m_RenderWindow.AddViewport(m_Camera);
            m_Camera.NearClipDistance = 0.1f;
            m_Camera.FarClipDistance = 1000.0f;

            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr windowHnd;
            m_RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            m_InputManager = MOIS.InputManager.CreateInputSystem(pl);

            m_Keyboard = (MOIS.Keyboard)m_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false);
            m_Mouse = (MOIS.Mouse)m_InputManager.CreateInputObject(MOIS.Type.OISMouse, false);

            m_NewtonWorld = new World();
            m_NewtonDebugger = new Debugger(m_NewtonWorld);
            m_NewtonDebugger.Init(m_SceneManager);

            m_GameCamera = new GameCamera();
            m_ObjectManager = new ObjectManager();
        }
开发者ID:Marchew,项目名称:Tachycardia,代码行数:45,代码来源:Core.cs

示例15: DefineResources

        private void DefineResources()
        {
            ConfigFile configFile = new ConfigFile();
            configFile.Load("resources.cfg", "\t:=", true);

            var section = configFile.GetSectionIterator();
            while (section.MoveNext())
            {
                foreach (var line in section.Current)
                {
                    ResourceGroupManager.Singleton.AddResourceLocation(
                        line.Value, line.Key, section.CurrentKey);
                }
            }
        }
开发者ID:anthony-martin,项目名称:Triangles-in-space,代码行数:15,代码来源:Renderer.cs


注:本文中的ConfigFile.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。