Ejemplo n.º 1
0
        private static void CollectIndirectAssemblies(AssemblyResolver assemblyResolver, DacPacRegistration dacpac, Action <string> collector)
        {
            foreach (DacPacRegistration ref_pac in dacpac.referenced_dacpacs.Values)
            {
                foreach (string ref_asm in ref_pac.referenced_assemblies.Keys)
                {
                    string asm_location = assemblyResolver.ResolveLocationByName(new AssemblyName(ref_asm));
                    collector(asm_location);
                }
                if (!string.IsNullOrEmpty(ref_pac.TestStoreAssemblyFullFileName))
                {
                    collector(ref_pac.TestStoreAssemblyFullFileName);
                }

                CollectIndirectAssemblies(assemblyResolver, ref_pac, collector);
            }
        }
Ejemplo n.º 2
0
        internal static void GenerateAccessors(KnownDibixTypes dbx, AssemblyResolver assemblyResolver, DacPacRegistration dacpac, bool doGenerate, CompilerParameters comparam, CodeCompileUnit ccu, string inputdir)
        {
            string dacpacDllFileName     = Path.GetFileName(dacpac.DacPacAssemblyFileName);
            string dacpacDllFullFileName = Path.Combine(inputdir, dacpacDllFileName);

            Console.WriteLine("Load '" + dacpacDllFullFileName + "'...");
            if (!File.Exists(dacpacDllFullFileName))
            {
                throw new StoreLakeSdkException("File could not be found:" + dacpacDllFullFileName);
            }

            Assembly asm = assemblyResolver.ResolveAssembyByLocation(dacpacDllFullFileName);

            if (doGenerate)
            {
                CollectIndirectAssemblies(assemblyResolver, dacpac, (string asm_location) =>
                {
                    AddReferencedAssemblies(assemblyResolver, comparam, asm_location);
                });

                foreach (AssemblyName ref_asm_name in asm.GetReferencedAssemblies())
                {
                    if (ref_asm_name.FullName.StartsWith("mscorlib", StringComparison.OrdinalIgnoreCase) ||
                        ref_asm_name.FullName.StartsWith("System.", StringComparison.OrdinalIgnoreCase) ||
                        ref_asm_name.FullName.StartsWith("System,", StringComparison.OrdinalIgnoreCase) ||
                        ref_asm_name.FullName.StartsWith("Newtonsoft.", StringComparison.OrdinalIgnoreCase)
                        )
                    {
                        // ignore
                    }
                    else
                    {
                        Console.WriteLine(ref_asm_name.FullName);
                        if (dacpac.referenced_assemblies.TryGetValue(ref_asm_name.FullName, out string ref_asm_location))
                        {
                        }
                        else
                        {
                            Assembly ref_asm = assemblyResolver.ResolveAssembyByName(ref_asm_name);
                            ref_asm_location = ref_asm.Location;


                            dacpac.referenced_assemblies.Add(ref_asm.GetName().FullName, ref_asm.Location);
                        }

                        AddReferencedAssemblies(assemblyResolver, comparam, ref_asm_location);
                    }
                }
                AddReferencedAssemblies(assemblyResolver, comparam, asm.Location);
                dacpac.referenced_assemblies.Add(asm.GetName().FullName, asm.Location);
                ;
                AddReferencedAssemblies(assemblyResolver, comparam, assemblyResolver.CacheType(typeof(System.Xml.Linq.XElement)).Location); // System.Xml.Linq

                dbx.Dibix_DatabaseAccessorAttribute.ToString().GetHashCode();

                Type databaseAccessorAttributeType = dbx.Dibix_DatabaseAccessorAttribute;

                foreach (Type type in asm.GetTypes())
                {
                    IList <CustomAttributeData> customAttributes = type.GetCustomAttributesData();
                    //Console.WriteLine("Type:" + type.FullName + "   A:" + customAttributes.Count);
                    //if (customAttributes.Count > 0 && type.FullName.EndsWith("Set"))
                    //{
                    //    Console.WriteLine("       A:" + customAttributes.Count);
                    //}

                    bool type_IsDefined__databaseAccessorAttributeType     = false;
                    bool type_IsDefined__dbx_Dibix_StructuredTypeAttribute = false;
                    foreach (CustomAttributeData customAttribute in customAttributes)
                    {
                        if (customAttribute.AttributeType == databaseAccessorAttributeType)
                        {
                            type_IsDefined__databaseAccessorAttributeType = true;
                        }

                        if (customAttribute.AttributeType == dbx.Dibix_StructuredTypeAttribute)
                        {
                            type_IsDefined__dbx_Dibix_StructuredTypeAttribute = true;
                        }
                    }

                    //if (type.IsDefined(databaseAccessorAttributeType))
                    //{
                    //    GenerateDatabaseAccessHandlerFacade(dbx, ccu, type);
                    //}
                    //else if (type.IsDefined(dbx.Dibix_StructuredTypeAttribute))
                    //{
                    //    GenerateStructureTypeRow(ccu, type);
                    //}
                    if (type_IsDefined__databaseAccessorAttributeType)
                    {
                        GenerateDatabaseAccessHandlerFacade(dbx, ccu, type);
                    }
                    else if (type_IsDefined__dbx_Dibix_StructuredTypeAttribute)
                    {
                        GenerateStructureTypeRow(ccu, type);
                    }
                }
            } // doGenerate
        }