Пример #1
0
        public void AddType(Type t, string ns)
        {
            Utility.AssertNotNull(t, "t");
            Utility.AssertNotNull(ns, "namespace");

            MyContext.AssertTypeIsAccessible(t);

            NamespaceImport import = this.GetImport(ns);

            import.Add(new TypeImport(t, BindingFlags.Public | BindingFlags.Static, false));
        }
Пример #2
0
        internal NamespaceImport GetImport(string ns)
        {
            if (ns.Length == 0)
            {
                return(MyRootImport);
            }

            NamespaceImport import = MyRootImport.FindImport(ns) as NamespaceImport;

            if (import == null)
            {
                import = new NamespaceImport(ns);
                MyRootImport.Add(import);
            }

            return(import);
        }
Пример #3
0
        public void AddMethod(MethodInfo mi, string ns)
        {
            Utility.AssertNotNull(mi, "mi");
            Utility.AssertNotNull(ns, "namespace");

            MyContext.AssertTypeIsAccessible(mi.ReflectedType);

            if (mi.IsStatic == false | mi.IsPublic == false)
            {
                string msg = Utility.GetGeneralErrorMessage(GeneralErrorResourceKeys.OnlyPublicStaticMethodsCanBeImported);
                throw new ArgumentException(msg);
            }

            NamespaceImport import = this.GetImport(ns);

            import.Add(new MethodImport(mi));
        }