コード例 #1
0
        public virtual bool Parse(XmlDbRow myRow, XmlDbTable table)
        {
            mName = myRow.GetString("Name");

            string error = null;

            if (!Parse(myRow, ref error))
            {
                BooterLogger.AddError(Name + " : " + error);
                return(false);
            }

            if ((table == null) || (table.Rows == null) || (table.Rows.Count == 0))
            {
                BooterLogger.AddError(Name + ": Missing Table");
                return(false);
            }
            else
            {
                List <IScoring <T, SubSP> > rawScoring = new List <IScoring <T, SubSP> >();

                int index = 1;
                foreach (XmlDbRow row in table.Rows)
                {
                    Type classType = row.GetClassType("FullClassName");
                    if (classType == null)
                    {
                        BooterLogger.AddError(Name + ": Unknown FullClassName " + row.GetString("FullClassName"));
                        continue;
                    }

                    IScoring <T, SubSP> scoring = null;
                    try
                    {
                        scoring = classType.GetConstructor(new Type[0]).Invoke(new object[0]) as IScoring <T, SubSP>;
                    }
                    catch
                    { }

                    if (scoring == null)
                    {
                        BooterLogger.AddError(Name + " (" + index + "): Constructor Fail " + row.GetString("FullClassName") + " as " + typeof(IScoring <T, SubSP>));
                    }
                    else
                    {
                        error = null;
                        if (scoring.Parse(row, ref error))
                        {
                            rawScoring.Add(scoring);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(error))
                            {
                                BooterLogger.AddError(Name + " index " + index + " : " + error);
                            }
                            else
                            {
                                BooterLogger.AddTrace(Name + " index " + index + " : <Warning>");
                            }
                        }
                    }

                    index++;
                }

                List <ICombinedScoring <T, SubSP> > combinedList = Common.DerivativeSearch.Find <ICombinedScoring <T, SubSP> >(Common.DerivativeSearch.Caching.NoCache);

                foreach (ICombinedScoring <T, SubSP> combined in combinedList)
                {
                    IScoring <T, SubSP> scoring = combined as IScoring <T, SubSP>;
                    if (scoring == null)
                    {
                        continue;
                    }

                    if (combined.Combine(rawScoring))
                    {
                        rawScoring.Add(scoring);
                    }
                }

                List <IScoring <T, SubSP> > scoringList = new List <IScoring <T, SubSP> >(rawScoring);
                rawScoring.Clear();

                foreach (IScoring <T, SubSP> scoring in scoringList)
                {
                    if (scoring.IsConsumed)
                    {
                        continue;
                    }

                    rawScoring.Add(scoring);
                }

                if (rawScoring.Count > 0)
                {
                    mHelper.SetRawScoring(rawScoring);
                    return(true);
                }
                else
                {
                    BooterLogger.AddError(Name + ": No valid scoring");
                    return(false);
                }
            }
        }