Ejemplo n.º 1
0
        /// <summary>
        /// Adds the current question info to the xml
        /// </summary>
        /// <param name="questionInfo"></param>
        public void AddQuestionInfo(QuestionInfo questionInfo)
        {
            FoundType foundType = questionInfo.Matches().foundType;

            XElement questionAnswer = new XElement("QuestionAnswer", new XAttribute("CorrectMatch", foundType.ToString()));

            questionAnswer.Add(new XElement("Question", questionInfo.Question));
            questionAnswer.Add(new XElement("Answer", questionInfo.Answer));
            root.Add(questionAnswer);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read our XML configuration file
        /// </summary>
        public static void DetermineFileTypes()
        {
            //Add in our list of file paths
            foreach (Type FoundType in typeof(MM_Line_Data).Assembly.GetTypes())
            {
                UpdateCommandAttribute    UpdateCommand    = null;
                RetrievalCommandAttribute RetrievalCommand = null;
                FileNameAttribute         FileName         = null;

                foreach (object obj in FoundType.GetCustomAttributes(false))
                {
                    if (obj is UpdateCommandAttribute)
                    {
                        UpdateCommand = (UpdateCommandAttribute)obj;
                    }
                    else if (obj is FileNameAttribute)
                    {
                        FileName = (FileNameAttribute)obj;
                    }
                    else if (obj is RetrievalCommandAttribute)
                    {
                        RetrievalCommand = (RetrievalCommandAttribute)obj;
                    }
                }

                if (UpdateCommand != null && FileName != null)
                {
                    MM_EMSReader_TCP.InputTypes.Add(FileName.FileName, FoundType);
                    MM_EMSReader_TCP.UpdateCommands.Add(FileName.FileName, UpdateCommand.UpdateCommand);
                    if (!String.IsNullOrEmpty(Settings.Default.TEDESourceFolder))
                    {
                        MM_EMSReader_File.FileInfo.Add(FileName.FileName, new MM_EMSReader_File(Path.Combine(Settings.Default.TEDESourceFolder, FileName.FileName), UpdateCommand.UpdateCommand, FoundType));
                    }
                }

                // FileInfo.Add(FileName.FileName, new MM_EMSReader_FileInformation(Path.Combine(Settings.Default.SourceFolder,FileName.FileName), UpdateCommand.UpdateCommand, FoundType));

                //Check our update command, make sure it's okay
                if (UpdateCommand != null && FileName != null && typeof(IMM_ConversationMessage_Types).GetMethod(UpdateCommand.UpdateCommand) == null)
                {
                    MM_Notification.WriteLine(ConsoleColor.Yellow, "Unable to find update command {0} for type {1}", UpdateCommand.UpdateCommand, FileName.FileName);
                }
                if (RetrievalCommand != null && FileName != null && typeof(IMM_EMS_Types).GetMethod(RetrievalCommand.RetrievalCommand) == null)
                {
                    MM_Notification.WriteLine(ConsoleColor.Yellow, "Unable to find retrieval command {0} for type {1}", RetrievalCommand.RetrievalCommand, FileName.FileName);
                }
            }
        }
Ejemplo n.º 3
0
            public static IEnumerable <InterfaceType> FindImplementations <InterfaceType>()
                where InterfaceType : class
            {
                var AllTypes = Assembly.GetExecutingAssembly().GetTypes().Where(T => typeof(InterfaceType).IsAssignableFrom(T));

                List <InterfaceType> ConstructedTypes = new List <InterfaceType>();

                foreach (Type FoundType in AllTypes)
                {
                    ConstructorInfo TypeConstructor = FoundType.GetConstructor(Type.EmptyTypes);

                    if (TypeConstructor != null)
                    {
                        InterfaceType NewInstance = TypeConstructor.Invoke(null) as InterfaceType;

                        ConstructedTypes.Add(NewInstance);
                    }
                }

                return(ConstructedTypes);
            }