Пример #1
0
    private IBELObject BorderPropertyFromTopic(AbsoluteTopicName relativeToTopic, AbsoluteTopicName abs, Border border, CompositeCacheRule rule)
    {
      ContentBase cb = ContentBaseForTopic(abs);
      if (cb == null)
      {
        return null;
      }
      rule.Add(cb.CacheRuleForAllPossibleInstancesOfTopic(abs));
      if (!cb.TopicExists(abs))
      {
        return null;
      }

      // OK, looks like the topic exist -- let's see if the property is there
      string borderPropertyName = BorderPropertyName(border);
      string prop = GetTopicProperty(abs, borderPropertyName);
      if (prop == null || prop == "")
      {
        return null;
      }

      // Yup, so evaluate it!
      string code = "federation.GetTopic(\"" + abs.Fullname + "\")." + borderPropertyName + "(federation.GetTopicInfo(\"" + relativeToTopic + "\"))";

      BehaviorInterpreter interpreter = new BehaviorInterpreter(code, this, this.WikiTalkVersion, null);
      if (!interpreter.Parse())
      {
        throw new Exception("Border property expression failed to parse.");
      }
      TopicContext topicContext = new TopicContext(this, this.ContentBaseForTopic(abs), new TopicInfo(this, abs));
      IBELObject obj = interpreter.EvaluateToObject(topicContext, null);
      if (interpreter.ErrorString != null)
      {
        obj = new BELString(interpreter.ErrorString);
      }

      foreach (CacheRule r in interpreter.CacheRules)
      {
        rule.Add(r);
      }
      return obj;
    }
Пример #2
0
        private IBELObject BorderPropertyFromTopic(QualifiedTopicRevision relativeToTopic, QualifiedTopicRevision abs, Border border)
        {
            NamespaceManager namespaceManager = NamespaceManagerForTopic(abs);
            if (namespaceManager == null)
            {
                return null;
            }

            if (!namespaceManager.TopicExists(abs.LocalName, ImportPolicy.DoNotIncludeImports))
            {
                return null;
            }

            // OK, looks like the topic exist -- let's see if the propertyName is there
            string borderPropertyName = BorderPropertyName(border);
            string prop = GetTopicPropertyValue(abs, borderPropertyName);
            if (prop == null || prop == "")
            {
                return null;
            }

            // Yup, so evaluate it!
            string code = "federation.GetTopic(\"" + abs.DottedName + "\")." + borderPropertyName + "(federation.GetTopicInfo(\"" + relativeToTopic + "\"))";

            BehaviorInterpreter interpreter = new BehaviorInterpreter(abs.DottedName + "#" + borderPropertyName, code, this, this.WikiTalkVersion, null);
            if (!interpreter.Parse())
            {
                throw new Exception("Border property expression failed to parse.");
            }
            TopicContext topicContext = new TopicContext(this, this.NamespaceManagerForTopic(abs), new TopicVersionInfo(this, abs));
            IBELObject obj = interpreter.EvaluateToObject(topicContext, null);
            if (interpreter.ErrorString != null)
            {
                obj = new BELString(interpreter.ErrorString);
            }

            return obj;
        }