Beispiel #1
0
        /// <summary>
        /// The Execute method is invoked in order to generate the
        /// source code for all of the entities that are defined in
        /// the specified FIX dictionary.
        /// </summary>
        /// <param name="srcPath"></param>
        /// <param name="dstPath"></param>
        private void Execute(string srcPath, string dstPath, string dstNamespace)
        {
            FixDictionary dxInstance = FixDxImporter.Import(srcPath);

            if (dxInstance != null)
            {
                string fixNamespace = "VfxEngine.Fix00";
                if (!string.IsNullOrEmpty(dstNamespace))
                {
                    fixNamespace = dstNamespace;
                }

                // REC: If the destination folder doesn't exist, create it:
                if (!Directory.Exists(dstPath))
                {
                    Directory.CreateDirectory(dstPath);
                }

                // REC: Generate the path to the tag definitions file:
                string dstPath_Tags = string.Format("{0}\\{1}.Tags.cs", dstPath, fixNamespace);

                // REC: Generate the tag definitions, write them to the file:
                GenerateTags(dxInstance, dstPath_Tags, fixNamespace);
            }
        }
Beispiel #2
0
        public void Run(string[] args)
        {
            // REC: Construct the service container that will be used
            // to provide the engine with references to the services it
            // will need to access when it starts:
            IVfxServices services = new VfxServices();

            // REC: Retrieve the current path to the executable:
            string execPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // REC: Construct the complete path to the configuration
            // settings file for the application:
            string pathSettings = Path.Combine(execPath, "FixSessions.xml");

            // REC: Attempt to load the application configuration into
            // an instance of a new XML document:
            XmlDocument configuration = new XmlDocument();

            configuration.Load(pathSettings);

            // REC: After the configuration file has been loaded, it must
            // be added to the application's service container so that the
            // engine can access it when it is started.
            services.AddService(typeof(IVfxSettings), new VfxSettings(configuration));

            // REC: The engine requires an IVfxFixApp implementation that
            // it can direct callbacks to as FIX events occur:
            services.AddService(typeof(IVfxFixApp), _fixApplication);

            // REC: Construct the complete path to the versions file that
            // contains the FIX version definitions for the application:
            string pathVersions = Path.Combine(execPath, "FixVersions.xml");

            // REC: Attempt to load the version definitions from the
            // version definitions file associated with the app:
            VfxFixVxRegistry vxRegistry = new VfxFixVxRegistry();

            vxRegistry.Import(pathVersions);


            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            // NOTE: You don't need to do this in your own apps, this is
            // done here because our example code stores all of the files
            // for the FIX dictionaries in a common directory, so the app
            // walks backwards up the directory tree in order to find the
            // folder that contains those files...
            //-----------------------------------------------------------
            string pathDictionaries = GetPathToExampleDictionaries();

            // REC: Scan the dictionaries directory and import all of
            // the dictionaries into a dictionary registry instance:
            IVfxFixDxRegistry dxRegistry = new VfxFixDxRegistry();

            foreach (string dxFile in Directory.GetFiles(pathDictionaries, "*.xml"))
            {
                // REC: Throughout the VersaFix system, dictionaries are
                // referred to by their file name, sans extension:
                string dxName = Path.GetFileNameWithoutExtension(dxFile);
                // REC: Import the actual dictionary data:
                FixDictionary dxEntry = FixDxImporter.Import(dxFile);
                // REC: Create an entry for the imported dictionary
                // in the dictionary registry:
                if (dxEntry != null)
                {
                    dxRegistry.CreateEntry(dxName, dxEntry);
                }
            }

            // REC: The engine requires IVfxFixVxRegistry so that it can
            // lookup information about configured FIX versions:
            services.AddService(typeof(IVfxFixVxRegistry), vxRegistry);

            // REC: The engine requires IVfxFixDxRegistry so that it can
            // lookup information about configured FIX dictionaries:
            services.AddService(typeof(IVfxFixDxRegistry), dxRegistry);

            // REC: If the initialization completed successfully, the
            // engine can be activated. The application will now start
            // establishing new FIX connections in acccordance with the
            // application's configuration settings:
            this._fixEngine.Activate(services);

            // REC: Sophisticated shutdown logic ;-)
            System.Console.ReadLine();
        }