/// <summary> /// The primary function that gets the namespace from the scope. /// </summary> /// <param name="scope"></param> /// <param name="moduleNamespace"></param> /// <param name="forceCreation">force creation of namespace in scope if dosen't exist before.</param> /// <returns></returns> public static QsNamespace GetNamespace(QsScope scope, string moduleNamespace, bool forceCreation) { QsNamespace NameSpace = null; // try to get the namespace object from the scope // then see if it represent a custom namespace also or not. // then return the object that hold the whole thing. if (scope != null) { if (scope.HasValue(moduleNamespace)) { NameSpace = (QsNamespace)scope.GetValue(moduleNamespace); } if (NameSpace == null) { // no namespace in this scope NameSpace = new QsNamespace(moduleNamespace); // search if this namespace represent hardcoded namespace System.Type nst = GetQsNamespaceType(moduleNamespace); NameSpace._NamespaceType = nst; if (forceCreation | (nst != null)) { scope.SetValue(moduleNamespace, NameSpace); } } } return(NameSpace); }
/// <summary> /// Gets a strongly typed namespace that were defined with static class type and has static methods /// that can be used to provide qs compatible methods. /// </summary> /// <param name="moduleNamespace"></param> /// <returns></returns> public static QsNamespace GetTypedNamespace(string moduleNamespace) { QsNamespace NameSpace = new QsNamespace(moduleNamespace); // search if this namespace represent hardcoded namespace System.Type nst = GetQsNamespaceType(moduleNamespace); NameSpace._NamespaceType = nst; return(NameSpace); }
/// <summary> /// Get sequence object from the scope memory. /// </summary> /// <param name="scope"></param> /// <param name="qsNamespace"></param> /// <param name="sequenceName"></param> /// <returns></returns> public static QsSequence GetSequence(QsScope scope, string qsNamespace, string sequenceName) { if (string.IsNullOrEmpty(qsNamespace)) { // no namespace included then it is from the local scope. var seq = (QsSequence)QsEvaluator.GetScopeValueOrNull(scope, qsNamespace, sequenceName); return(seq); } else { QsNamespace ns = QsNamespace.GetNamespace(scope, qsNamespace); return((QsSequence)ns.GetValueOrNull(sequenceName)); } }