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

            CopyFromTo(this, loaderOpts);
            return(loaderOpts);
        }
Ejemplo n.º 2
0
 public void SetLoaderOptions(LoaderOptions copyFrom)
 {
     if (copyFrom != default(LoaderOptions))
     {
         CopyFromTo(copyFrom, this);
     }
 }
Ejemplo 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) ?? "*")));
     }
 }
Ejemplo 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);
     }
 }
Ejemplo 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;
            }
        }
Ejemplo n.º 6
0
 protected CategoryInfoImpl1(Unifiable pattern, XmlNode cateNode, LoaderOptions options)
     : base(cateNode)
 {
     Pattern  = pattern;
     Filename = options.CurrentFilename;
 }
Ejemplo 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);
        }
Ejemplo 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));
 }
Ejemplo n.º 9
0
 protected Unifiable ProcessLoad(LoaderOptions loaderOptions)
 {
     return(Unifiable.Empty);
 }