コード例 #1
0
ファイル: ScriptFile.cs プロジェクト: JanJorgensen/StepBro
        internal void ResolveFileUsings(Converter <string, IScriptFile> resolver)
        {
            var c = m_fileUsings.Count;

            for (int i = 0; i < c; i++)
            {
                if (m_fileUsings[i].Identifier.Reference == null)
                {
                    try
                    {
                        var resolved = resolver(m_fileUsings[i].Identifier.Name);
                        if (resolved != null)
                        {
                            m_fileUsings[i] = new UsingData(m_fileUsings[i].Line, m_fileUsings[i].Identifier.Name, IdentifierType.FileByName, resolved);
                            resolved.RegisterDependant(this);
                        }
                        else
                        {
                            m_errors.UnresolvedUsing(m_fileUsings[i].Line, -1, m_fileUsings[i].Identifier.Name);
                        }
                    }
                    catch (Exception ex)
                    {
                        m_errors.InternalError(m_fileUsings[i].Line, -1, "Exception thrown when resolving using. Exception: " + ex.GetType().Name + ", " + ex.Message);
                    }
                }
            }
        }
コード例 #2
0
        public void TestLoadTestModule()
        {
            IAddonManager addons = AddonManager.Create();

            var testFile = GetTestModulePath();

            addons.LoadAssembly(testFile, false);

            var typeReference = addons.TryGetType(null, "TestModule.TestClassWithOnlyProperties");

            Assert.IsNotNull(typeReference);
            typeReference = addons.TryGetType(null, "TestModule.SubNamespace.Deep.VeryDeep.MuchDeeper.TestClassInDeepNamespace");
            Assert.IsNotNull(typeReference);
            typeReference = addons.TryGetType(null, "TestModule.SubNamespace.Deep.VeryDeep.MuchDeeper.TestClassInDeepNamespace.SubClass");
            Assert.IsNotNull(typeReference);

            var usings = new UsingData[] { new UsingData(-1, addons.Lookup(null, "TestModule")) };

            typeReference = addons.TryGetType(usings, "TestClassWithOnlyProperties");
            Assert.IsNotNull(typeReference);
            Assert.AreEqual("TestClassWithOnlyProperties", typeReference.Name);

            typeReference = addons.TryGetType(usings, "SubNamespace.Deep.VeryDeep.MuchDeeper.TestClassInDeepNamespace.SubClass");
            Assert.IsNotNull(typeReference);
            Assert.AreEqual("SubClass", typeReference.Name);

            usings        = new UsingData[] { new UsingData(-1, addons.Lookup(null, "TestModule")), new UsingData(-1, addons.Lookup(null, "TestModule.SubNamespace.Deep")) };
            typeReference = addons.TryGetType(usings, "VeryDeep.MuchDeeper.TestClassInDeepNamespace.SubClass");
            Assert.IsNotNull(typeReference);
            Assert.AreEqual("SubClass", typeReference.Name);

            //var moduleClass = typeReference as ICodeModuleClass;
            //Assert.IsNotNull(moduleClass);
        }
コード例 #3
0
ファイル: ScriptFile.cs プロジェクト: JanJorgensen/StepBro
        internal void ResolveNamespaceUsings(Converter <string, IIdentifierInfo> resolver)
        {
            var c = m_namespaceUsings.Count;

            for (int i = 0; i < c; i++)
            {
                if (m_namespaceUsings[i].Identifier.Type == IdentifierType.UnresolvedType)
                {
                    var resolved = resolver(m_namespaceUsings[i].Identifier.Name);
                    if (resolved != null)
                    {
                        m_namespaceUsings[i] = new UsingData(m_namespaceUsings[i].Line, resolved);
                    }
                    else
                    {
                        m_errors.UnresolvedUsing(m_fileUsings[i].Line, -1, m_fileUsings[i].Identifier.Name);
                    }
                }
            }
        }