Example #1
0
        /// <summary>
        /// checks if a custom mapping is specified for the target idl type.
        /// </summary>
        private bool IsCustomMappedToIdlType(Type idlType)
        {
            if (!(typeof(IIdlEntity).IsAssignableFrom(idlType)))
            {
                return(false);
            }
            GeneratorMappingPlugin mappingPlugin = GeneratorMappingPlugin.GetSingleton();

            return(mappingPlugin.IsCustomMappingTarget(idlType));
        }
Example #2
0
 /// <summary>get the name of the idl-file for the mapped type</summary>
 public string GetIdlFileForMappedType(MapTypeInfo mapped)
 {
     if (!IsCustomMappedToIdlType(mapped.Type))
     {
         object res = m_filesForMappedTypes[mapped];
         return((string)res);
     }
     else
     {
         GeneratorMappingPlugin     mappingPlugin = GeneratorMappingPlugin.GetSingleton();
         GeneratorCustomMappingDesc mappingDesc   = mappingPlugin.GetMappingForIdlTarget(mapped.Type);
         return(mappingDesc.IdlFileName);
     }
 }
 static GeneratorMappingPlugin() {
     s_registry = new GeneratorMappingPlugin();
 }
Example #4
0
        /// <summary>returns the type to be mapped or terminate</summary>
        private static Type ParseArgs(string[] args)
        {
            int i = 0;

            System.IO.FileInfo configFile = null;
            while ((i < args.Length) && (args[i][0] == '-'))
            {
                switch (args[i])
                {
                case "-h":
                    HowTo();
                    i++;
                    break;

                case "-o":
                    i++;
                    s_destination = args[i++];
                    break;

                case "-c":
                    i++;
                    configFile = new System.IO.FileInfo(args[i++]);
                    break;

                default:
                    Error(String.Format("Error: invalid option {0}", args[i]));
                    break;
                }
            }
            if (!Directory.Exists(s_destination))
            {
                Directory.CreateDirectory(s_destination);
            }

            if (i < args.Length - 2)
            {
                Error("Error: typename or assembly missing");
            }
            else if (i > args.Length + 2)
            {
                Error("Error: too many parameters");
            }

            Assembly assembly = null;
            Type     type     = null;

            try {
                assembly = Assembly.LoadFrom(args[i + 1]);
            } catch (Exception e) {
                Error(String.Format("Error while loading assembly: {0}", e.Message));
            }

            // append private assembly search path: directory of assembly containing type to map -> find assemblies it depends on
            SetupAppDomain(assembly);

            try {
                type = assembly.GetType(args[i], true);
            } catch (Exception e) {
                Error(String.Format("Error while loading type: {0}", e.Message));
            }

            if (configFile != null)
            {
                // add custom mappings from file
                GeneratorMappingPlugin plugin = GeneratorMappingPlugin.GetSingleton();
                plugin.AddMappingsFromFile(configFile);
            }

            return(type);
        }
Example #5
0
        /// <summary>
        /// checks if a custom mapping is specified from the specified clsType.
        /// </summary>
        private bool IsCustomMappedFromClsType(Type clsType)
        {
            GeneratorMappingPlugin mappingPlugin = GeneratorMappingPlugin.GetSingleton();

            return(mappingPlugin.IsCustomMappingPresentForCls(clsType));
        }
Example #6
0
 static GeneratorMappingPlugin()
 {
     s_registry = new GeneratorMappingPlugin();
 }