Пример #1
0
 /// <summary>
 /// Opens a new namespace for current script.
 /// </summary>
 private void declareOpenNamespace(UseNode node)
 {
     if (!Namespaces.ContainsKey(node.Namespace))
     {
         Namespaces.Add(node.Namespace, true);
     }
 }
Пример #2
0
 public void AddNamespace(SDNamespace sdNamespace)
 {
     if (!Namespaces.ContainsKey(sdNamespace.Identifier))
     {
         Namespaces.Add(sdNamespace.Identifier, sdNamespace);
     }
 }
Пример #3
0
        private void RrecursiveParse(XPathNavigator navigator)
        {
            var namespaces = navigator.GetNamespacesInScope(XmlNamespaceScope.Local);

            foreach (var map in namespaces)
            {
                if (String.IsNullOrEmpty(map.Key))
                {
                    DefaultNamespaces.Add(map.Value);
                }
                else if (!Namespaces.ContainsKey(map.Key))
                {
                    Namespaces.Add(map.Key, map.Value);
                }
            }

            // process child element nodes
            if (navigator.HasChildren &&
                (ParseChildren || navigator.NodeType == XPathNodeType.Root) &&
                navigator.MoveToFirstChild())
            {
                do
                {
                    RrecursiveParse(navigator);
                }while (navigator.MoveToNext(XPathNodeType.Element));

                // move back to the original parent node
                navigator.MoveToParent();
            }
        }
Пример #4
0
 public void RemoveNamespace(String ns)
 {
     if (Namespaces.ContainsKey(ns))
     {
         Namespaces.Remove(ns);
     }
 }
Пример #5
0
 public void AddNamespace(String ns)
 {
     if (!Namespaces.ContainsKey(ns))
     {
         Namespaces.Add(ns, null);
     }
 }
Пример #6
0
 public Globals GetNamespace(string ns)
 {
     if (Namespaces.ContainsKey(ns))
         return Namespaces[ns];
     if (Parent != null)
         return Parent.GetNamespace(ns);
     return null;
 }
Пример #7
0
 public bool ContainsNamespace(string ns)
 {
     if (Namespaces.ContainsKey(ns))
         return true;
     if (Parent != null)
         return Parent.ContainsNamespace(ns);
     return false;
 }
Пример #8
0
 /// <summary>
 /// This method is used to return a reference to the namespace with the specified name
 /// </summary>
 /// <param name="FullName">
 /// A <see cref="System.String"/>
 /// </param>
 /// <returns>
 /// A <see cref="NamespaceProperties"/>
 /// </returns>
 internal NamespaceProperties GetNamespaceReference(string FullName)
 {
     if (Namespaces.ContainsKey(FullName))
     {
         return(Namespaces[FullName]);
     }
     return(null);
 }
Пример #9
0
        /// <summary>
        /// Adds a namespace to this project. "@" represents the root namespace.
        /// </summary>
        public void AddNamespace(string name)
        {
            if (Namespaces.ContainsKey(name))
            {
                throw new Exception("A namespace already exists with this name.");
            }

            Namespaces.Add(name, new List <ClassModule>());
        }
Пример #10
0
 public Globals GetNamespace(string ns)
 {
     if (Namespaces.ContainsKey(ns))
     {
         return(Namespaces[ns]);
     }
     if (Parent != null)
     {
         return(Parent.GetNamespace(ns));
     }
     return(null);
 }
Пример #11
0
 public void GetNamespaces(string code, string project)
 {
     if (Namespaces == null)
     {
         Namespaces = new Dictionary <string, Dictionary <int, string> >();
     }
     if (Namespaces.ContainsKey(code))
     {
         return;
     }
     Namespaces.Add(code, WikiApiFunctions.GetNamespaces(code, project));
 }
Пример #12
0
 public bool ContainsNamespace(string ns)
 {
     if (Namespaces.ContainsKey(ns))
     {
         return(true);
     }
     if (Parent != null)
     {
         return(Parent.ContainsNamespace(ns));
     }
     return(false);
 }
Пример #13
0
 // Left mostly to when used as a namespace
 public override BaseTypeInfo ResolvePropertyPath(Globals globals, params string[] path)
 {
     if (Classes.ContainsKey(path[0]))
         return Classes[path[0]];
     else if (Namespaces.ContainsKey(path[0]))
         return Namespaces[path[0]];
     foreach (FunctionInfo f in Functions)
     {
         if (f.Name.Equals(path[0]))
             return f;
     }
     return null;
 }
Пример #14
0
 public void AddRDFNamespace(string prefixAndNamespace, string uri)
 {
     if (!string.IsNullOrEmpty(prefixAndNamespace) && !string.IsNullOrEmpty(uri))
     {
         if (!Namespaces.ContainsKey(prefixAndNamespace))
         {
             Namespaces.Add(prefixAndNamespace, uri);
         }
         else
         {
             Namespaces[prefixAndNamespace] = uri;
         }
     }
 }
Пример #15
0
        /// <summary>
        /// Checks if a local name in <paramref name="LocalName"/> represents a subnamespace from the point of view of the namespace
        /// in <paramref name="Namespace"/>.
        /// </summary>
        /// <param name="Namespace">Namespace.</param>
        /// <param name="LocalName">Local name.</param>
        /// <returns>If the local name represents a subnamespace.</returns>
        public static bool IsSubNamespace(string Namespace, string LocalName)
        {
            lock (synchObject)
            {
                if (!isInitialized)
                {
                    throw NotInitializedException();
                }

                if (!namespacesPerNamespace.TryGetValue(Namespace, out SortedDictionary <string, bool> Namespaces))
                {
                    return(false);
                }

                return(Namespaces.ContainsKey(Namespace + "." + LocalName));
            }
        }
Пример #16
0
        private void AddNamespace(StringBuilder key, ITypeDefinition cls)
        {
            lock (Namespaces)
            {
                if (InstanceExists(key.ToString()))
                {
                    return;
                }

                if (!Namespaces.ContainsKey(cls.Namespace))
                {
                    Namespaces.Add(cls.Namespace, new NamespaceProperties(cls.Namespace));
                }

                Namespaces[cls.Namespace].AddInstance(cls);
            }
        }
Пример #17
0
 internal void AddRDFNamespaces(Dictionary <string, string> namespaces)
 {
     foreach (KeyValuePair <string, string> pair in namespaces)
     {
         string prefixAndNamespace = pair.Key;
         string uri = pair.Value;
         if (!string.IsNullOrEmpty(prefixAndNamespace) && !string.IsNullOrEmpty(uri))
         {
             if (!Namespaces.ContainsKey(prefixAndNamespace))
             {
                 Namespaces.Add(prefixAndNamespace, uri);
             }
             else
             {
                 Namespaces[prefixAndNamespace] = uri;
             }
         }
     }
 }
Пример #18
0
        private string GetDefaultKey(int index)
        {
            int charStart = 97;
            int charEnd   = 122;
            int charKey   = charStart + index;

            bool isAutomaticLetter = DefaultScheme == DefaultPrefixScheme.AutomaticLetter;
            bool isPrefixAndLetter = DefaultScheme == DefaultPrefixScheme.PrefixAndLetter;

            string key = DefaultPrefix;

            do
            {
                // if run out of letters
                bool isCharEnd = charKey > charEnd;

                if (!isCharEnd && isAutomaticLetter)
                {
                    //letter at index
                    key = ((char)charKey).ToString();
                }
                else if (!isCharEnd && isPrefixAndLetter)
                {
                    //default and letter at index
                    key = DefaultPrefix + ((char)charKey).ToString();
                }
                else if (index > 0)
                {
                    key = DefaultPrefix + index.ToString();
                }
                index++;
                charKey++;
            }while (Namespaces.ContainsKey(key));

            return(key);
        }
Пример #19
0
        /// <summary>
        /// Initializes the inventory engine, registering types and interfaces available in <paramref name="Assemblies"/>.
        /// </summary>
        public static void Initialize(params Assembly[] Assemblies)
        {
            SortedDictionary <string, Type> Types;
            SortedDictionary <string, Type> LastTypes = null;
            IEnumerable <Type> AssemblyTypes;
            Assembly           A;
            string             InterfaceName;
            string             TypeName;
            string             Namespace;
            string             ParentNamespace;
            string             LastNamespace = string.Empty;
            int i;

            if (isInitialized)
            {
                throw new Exception("Script engine is already initialized.");
            }

            CheckIncluded(ref Assemblies, typeof(Types).GetTypeInfo().Assembly);
            CheckIncluded(ref Assemblies, typeof(int).GetTypeInfo().Assembly);

            if (Array.IndexOf <Assembly>(Assemblies, A = typeof(Types).GetTypeInfo().Assembly) < 0)
            {
                int c = Assemblies.Length;
                Array.Resize <Assembly>(ref Assemblies, c + 1);
                Assemblies[c] = A;
            }

            foreach (Assembly Assembly in Assemblies)
            {
                try
                {
                    AssemblyTypes = Assembly.ExportedTypes;
                }
                catch (ReflectionTypeLoadException ex)
                {
                    foreach (Exception ex2 in ex.LoaderExceptions)
                    {
                        Log.Critical(ex2);
                    }

                    continue;
                }
                catch (Exception ex)
                {
                    Log.Critical(ex, Assembly.FullName);
                    continue;
                }

                foreach (Type Type in AssemblyTypes)
                {
                    TypeName = Type.FullName;
                    i        = TypeName.LastIndexOf('`');
                    if (i > 0 && int.TryParse(TypeName.Substring(i + 1), out int j))
                    {
                        TypeName = TypeName.Substring(0, i);
                    }

                    types[TypeName] = Type;

                    foreach (Type Interface in Type.GetTypeInfo().ImplementedInterfaces)
                    {
                        InterfaceName = Interface.FullName;
                        if (InterfaceName == null)
                        {
                            continue;                               // Generic interface.
                        }
                        if (!typesPerInterface.TryGetValue(InterfaceName, out Types))
                        {
                            Types = new SortedDictionary <string, Type>();
                            typesPerInterface[InterfaceName] = Types;
                        }

                        Types[TypeName] = Type;
                    }

                    Namespace = Type.Namespace;
                    if (Namespace != null)
                    {
                        if (Namespace == LastNamespace)
                        {
                            Types = LastTypes;
                        }
                        else
                        {
                            if (!typesPerNamespace.TryGetValue(Namespace, out Types))
                            {
                                Types = new SortedDictionary <string, Type>();
                                typesPerNamespace[Namespace] = Types;

                                i = Namespace.LastIndexOf('.');
                                while (i > 0)
                                {
                                    ParentNamespace = Namespace.Substring(0, i);

                                    if (!namespacesPerNamespace.TryGetValue(ParentNamespace, out SortedDictionary <string, bool> Namespaces))
                                    {
                                        Namespaces = new SortedDictionary <string, bool>();
                                        namespacesPerNamespace[ParentNamespace] = Namespaces;
                                    }
                                    else
                                    {
                                        if (Namespaces.ContainsKey(Namespace))
                                        {
                                            break;
                                        }
                                    }

                                    Namespaces[Namespace] = true;
                                    Namespace             = ParentNamespace;
                                    i = Namespace.LastIndexOf('.');
                                }

                                if (i < 0)
                                {
                                    rootNamespaces[Namespace] = true;
                                }
                            }

                            LastNamespace = Namespace;
                            LastTypes     = Types;
                        }

                        Types[TypeName] = Type;
                    }
                }
            }

            isInitialized = true;
        }