/// <include file='Resources/DocComments.xml' path='DocComments/ExpressionImports/AddType1/*' /> 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)); }
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); }
/// <include file='Resources/DocComments.xml' path='DocComments/ExpressionImports/AddMethod2/*' /> 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)); }
protected override bool EqualsInternal(ImportBase import) { NamespaceImport otherSameType = import as NamespaceImport; return((otherSameType != null) && MyNamespace.Equals(otherSameType.MyNamespace, this.Context.Options.MemberStringComparison)); }
internal bool HasNamespace(string ns) { NamespaceImport import = MyRootImport.FindImport(ns) as NamespaceImport; return(import != null); }
internal ExpressionImports() { // HACK - The author of this did not understand what was to be passed. MyRootImport = new NamespaceImport("True"); }