Esempio n. 1
0
        protected LoaderOptions CopyOptions()
        {
            var loaderOpts = new LoaderOptions();

            CopyFromTo(this, loaderOpts);
            return(loaderOpts);
        }
Esempio n. 2
0
 public void SetLoaderOptions(LoaderOptions copyFrom)
 {
     if (copyFrom != default(LoaderOptions))
     {
         CopyFromTo(copyFrom, this);
     }
 }
Esempio n. 3
0
 static public void CopyFromTo(LoaderOptions from, LoaderOptions to)
 {
     foreach (FieldInfo fi in typeof(LoaderOptions).GetFields())
     {
         if (!typeof(IComparable <string>).IsAssignableFrom(fi.FieldType))
         {
             continue;
         }
         fi.SetValue(to, StarNulls("" + (fi.GetValue(from) ?? "*")));
     }
 }
Esempio n. 4
0
 public TemplateInfoImpl(Unifiable pattern, XmlNode cateNode, XmlNode templateNode,
                         LoaderOptions options, Unifiable responseInfo,
                         Unifiable guard, Unifiable topicInfo, Node patternNode, Unifiable thatInfo)
     : base(pattern, cateNode, options)
 {
     if (templateNode == null || responseInfo.FullPath == Unifiable.Empty)
     {
         throw new NotImplementedException();
     }
     TemplateRating = 1.0;
     Guard          = guard;
     if ((thatInfo != null && !thatInfo.IsCatchAll) || (guard != null && !guard.IsCatchAll) ||
         (topicInfo != null && !topicInfo.IsCatchAll))
     {
         IsHighlyUsefull = true;
     }
     //CategoryXml = cateNode;
     That            = thatInfo;
     Response        = responseInfo;
     Topic           = topicInfo;
     Pattern         = pattern;
     GraphmasterNode = patternNode;
     srcNode         = templateNode;
     //ParentCategoryInfo = categoryInfo;
     try
     {
         {
             bool doCut;
             if (StaticXMLUtils.TryParseBool(templateNode, "cut", out doCut) || StaticXMLUtils.TryParseBool(cateNode, "cut", out doCut))
             {
                 NeckCut = doCut;
             }
         }
         string scoreString = StaticXMLUtils.GetAttribValue(templateNode, "score", null);
         scoreString    = scoreString ?? StaticXMLUtils.GetAttribValue(cateNode, "score", null);
         TemplateRating = scoreString != null?double.Parse(scoreString) : 1.0;
     }
     catch
     {
     }
     if (TemplateRating != 1.0)
     {
         AltBot.writeDebugLine("!! SCORE =" + TemplateRating + " for " + this);
     }
 }
Esempio n. 5
0
        public static R FromLoaderOper <R>(Func <R> action, GraphMaster gm, LoaderOptions loadOpts)
        {
            OutputDelegate prev = userTraceRedir;

            try
            {
                userTraceRedir = gm.writeToLog;
                try
                {
                    if (!loadOpts.NeedsLoaderLock)
                    {
                        return(action());
                    }
                    lock (ErrorList)
                    {
                        lock (gm.LockerObject)
                        {
                            return(action());
                        }
                    }
                }
                catch (Exception e)
                {
                    AltBot.writeDebugLine("ERROR: LoaderOper {0}", e);
                    if (!ChatOptions.AllowRuntimeErrors)
                    {
                        return(default(R));
                    }
                    throw;
                    //return default(R);
                }
            }
            finally
            {
                userTraceRedir = prev;
            }
        }
Esempio n. 6
0
 protected CategoryInfoImpl1(Unifiable pattern, XmlNode cateNode, LoaderOptions options)
     : base(cateNode)
 {
     Pattern  = pattern;
     Filename = options.CurrentFilename;
 }
Esempio n. 7
0
        public static CategoryInfo MakeCategoryInfo(Unifiable info, XmlNode cateNode, LoaderOptions filename,
                                                    XmlNode templateNode, Unifiable template, Unifiable guard, Unifiable topicInfo, Node patternNode, Unifiable thatInfo, IEnumerable <ConversationCondition> conds)
        {
            if (NoInfo)
            {
                return(null);
            }
            var vv = new TemplateInfoImpl(info, cateNode, templateNode, filename, template, guard, topicInfo, patternNode,
                                          thatInfo);

            vv.AddRules(conds);
            return(vv);
        }
Esempio n. 8
0
 public static CategoryInfo GetCategoryInfo(Unifiable info, XmlNode node, LoaderOptions filename, XmlNode templateNode,
                                            Unifiable template, Unifiable guard, Unifiable topicInfo, Node patternNode, Unifiable thatInfo, IEnumerable <ConversationCondition> conds)
 {
     return(filename.Graph.FindCategoryInfo(info, node, filename, templateNode, template, guard, topicInfo,
                                            patternNode, thatInfo, conds));
 }
 protected Unifiable ProcessLoad(LoaderOptions loaderOptions)
 {
     return(Unifiable.Empty);
 }