public void GenerateCode(CompilationUnit unit, IList<TypeName> parcelableNames, ConverterOptions opts)
        {
            w.WriteLine ("// This file is automatically generated and not supposed to be modified.");
            w.WriteLine ("using System;");
            w.WriteLine ("using Boolean = System.Boolean;");
            w.WriteLine ("using String = System.String;");
            w.WriteLine ("using List = Android.Runtime.JavaList;");
            w.WriteLine ("using Map = Android.Runtime.JavaDictionary;");

            this.unit = unit;
            name_cache = new NameResoltionCache (database, unit, parcelableNames);
            self_ns = name_cache.ToCSharpNamespace (unit.Package);

            if (unit.Imports != null) {
                var nss = new List<string> ();
                foreach (var imp in unit.Imports) {
                    string dummy, pkg = imp.GetPackage ();
                    string ns = database.NamespaceMappings.TryGetValue (pkg, out dummy) ? dummy : imp.GetNamespace ();
                    if (nss.Contains (ns))
                        continue;
                    nss.Add (ns);
                    w.WriteLine ("using " + ns + ";");
                }
            }
            if (unit.Package != null) {
                w.WriteLine ();
                w.WriteLine ("namespace {0}", self_ns);
                w.WriteLine ("{");
            }

            foreach (var type in unit.Types) {
                if (type is Parcelable) {
                    if (type is Parcelable) {
                        switch (opts.ParcelableHandling) {
                        case ParcelableHandling.Ignore:
                            continue;
                        case ParcelableHandling.Error:
                            throw new InvalidOperationException ("Parcelable AIDL cannot be converted to C#");
                        case ParcelableHandling.Stub:
                            StubParcelable ((Parcelable) type);
                            break;
                        }
                    }
                }
                else if (type is Interface)
                    GenerateCode ((Interface) type);
            }

            if (unit.Package != null)
                w.WriteLine ("}");

            this.unit = null;
        }
        public void GenerateCode(CompilationUnit unit, IList <TypeName> parcelableNames, ConverterOptions opts)
        {
            w.WriteLine("// This file is automatically generated and not supposed to be modified.");
            w.WriteLine("using System;");
            w.WriteLine("using Boolean = System.Boolean;");
            w.WriteLine("using String = System.String;");
            w.WriteLine("using List = Android.Runtime.JavaList;");
            w.WriteLine("using Map = Android.Runtime.JavaDictionary;");

            this.unit  = unit;
            name_cache = new NameResoltionCache(database, unit, parcelableNames);
            self_ns    = name_cache.ToCSharpNamespace(unit.Package);

            if (unit.Imports != null)
            {
                var nss = new List <string> ();
                foreach (var imp in unit.Imports)
                {
                    string dummy, pkg = imp.GetPackage();
                    string ns = database.NamespaceMappings.TryGetValue(pkg, out dummy) ? dummy : imp.GetNamespace();
                    if (nss.Contains(ns))
                    {
                        continue;
                    }
                    nss.Add(ns);
                    w.WriteLine("using " + ns + ";");
                }
            }
            if (unit.Package != null)
            {
                w.WriteLine();
                w.WriteLine("namespace {0}", self_ns);
                w.WriteLine("{");
            }

            foreach (var type in unit.Types)
            {
                if (type is Parcelable)
                {
                    if (type is Parcelable)
                    {
                        switch (opts.ParcelableHandling)
                        {
                        case ParcelableHandling.Ignore:
                            continue;

                        case ParcelableHandling.Error:
                            throw new InvalidOperationException("Parcelable AIDL cannot be converted to C#");

                        case ParcelableHandling.Stub:
                            StubParcelable((Parcelable)type);
                            break;
                        }
                    }
                }
                else if (type is Interface)
                {
                    GenerateCode((Interface)type);
                }
            }

            if (unit.Package != null)
            {
                w.WriteLine("}");
            }

            this.unit = null;
        }
 public NameResoltionCache(BindingDatabase database, CompilationUnit unit, IList<TypeName> parcelableNames)
 {
     this.database = database;
     this.unit = unit;
     parcelable_names = parcelableNames;
     cache ["IBinder"] = "Android.OS.IBinder";
     cache ["CharSequence"] = "Java.Lang.ICharSequence";
     cache ["List"] = "Android.Runtime.JavaList";
     cache ["Map"] = "Android.Runtime.JavaDictionary";
 }