コード例 #1
0
 public BuiltInCommandManager(IXmlOperations xmlOperations, string builtInCommandPath,
                              string applicationStartupPath)
 {
     _xmlOperations      = xmlOperations;
     builtInCommandPath  = applicationStartupPath + "\\" + builtInCommandPath;
     _builtInCommandPath = builtInCommandPath;
     BuiltInCommandDT    = _xmlOperations.GetXml(builtInCommandPath);
 }
コード例 #2
0
 public ProfileManager(IXmlOperations xmlOperations, string profileFilePath,
                       string applicationStartupPath)
 {
     _xmlOperations = xmlOperations;
     //TODO parallel reading
     profileFilePath  = applicationStartupPath + "\\" + profileFilePath;
     _profileFilePath = profileFilePath;
     ProfilesDT       = _xmlOperations.GetXml(profileFilePath);
 }
コード例 #3
0
 public CommandManager(IXmlOperations xmlOperations, string profileFilePath,
                       string customCommandsFilePath, string builtInComandsFilePath, string applicationStartupPath)
 {
     _xmlOperations         = xmlOperations;
     _profileManager        = new ProfileManager(profileFilePath, applicationStartupPath);
     _builtInCommandManager = new BuiltInCommandManager(builtInComandsFilePath, applicationStartupPath);
     //TODO parallel reading
     _customCommandsFilePath = Utilities.GetXmlPath(customCommandsFilePath, applicationStartupPath);
     CustomCommandsDT        = _xmlOperations.GetXml(_customCommandsFilePath);
 }
コード例 #4
0
        public CustomCommand GetCustomCommand(string commandName)
        {
            CustomCommand customCommand = null;
            //1. Find the profile of the given command
            DataView commandDV = new DataView(CustomCommandsDT)
            {
                Sort = "Name"
            };
            int commandIndex = commandDV.Find(commandName);

            if (commandIndex == -1)
            {
                return(null);
            }
            else
            {
                customCommand = new CustomCommand
                {
                    Name = commandName
                };
                var profileName = commandDV[commandIndex]["Profile"].ToString();
                //int profileIndex = profileDV.Find(profileName);
                //if (profileIndex == -1) return null;
                var profile = new Profile
                {
                    Name            = profileName,
                    CommandFilePath = GetProfileCommandPath(profileName)
                };
                customCommand.Profile = profile;
            }

            //2. Read the ProfileCommands file
            var profileCommandsDT = _xmlOperations.GetXml(customCommand.Profile.CommandFilePath);

            //3. Find the command details and return it
            using (DataView profileCommandsDV = new DataView(profileCommandsDT)
            {
                Sort = "Name"
            })
            {
                int profileCommandIndex = profileCommandsDV.Find(customCommand.Name);
                if (profileCommandIndex == -1)
                {
                    return(null);
                }
                customCommand.ActionScript = profileCommandsDV[profileCommandIndex]["ActionScript"].ToString();
                customCommand.Parameter    = profileCommandsDV[profileCommandIndex]["Parameter"].ToString();
            }
            return(customCommand);
        }