Exemplo n.º 1
0
		private static void Generate(OracleTypeCollection collectionType, TextWriter writer)
		{
			var owner = collectionType.FullyQualifiedName.NormalizedOwner.Trim('"');
			var name = collectionType.FullyQualifiedName.NormalizedName.Trim('"');

			var elementFullyQualifiedName = collectionType.ElementDataType.FullyQualifiedName;
			var elementClassName = elementFullyQualifiedName.HasOwner ? $"{elementFullyQualifiedName.NormalizedOwner.Trim('"')}_" : null;
			elementClassName = $"{elementClassName}{elementFullyQualifiedName.NormalizedName.Trim('"')}";

			writer.WriteLine($"[OracleCustomTypeMapping(\"{owner}.{name}\")]");
			writer.WriteLine($"public class {owner}_{name} : CustomCollectionTypeBase<{owner}_{name}, {elementClassName}>");
			writer.WriteLine("{");
			writer.WriteLine("}");
			writer.WriteLine();

			writer.WriteLine(CustomCollectionTypeBase);
			writer.WriteLine();
		}
Exemplo n.º 2
0
        private static OracleSchemaObject MapSchemaType(IDataRecord reader)
        {
            var owner = QualifyStringObject(reader["OWNER"]);

            OracleTypeBase schemaType;
            var            typeType = (string)reader["TYPECODE"];

            switch (typeType)
            {
            case OracleTypeBase.TypeCodeXml:
                schemaType = new OracleTypeObject().WithTypeCode(OracleTypeBase.TypeCodeXml);
                break;

            case OracleTypeBase.TypeCodeAnyData:
                schemaType = new OracleTypeObject().WithTypeCode(OracleTypeBase.TypeCodeAnyData);
                break;

            case OracleTypeBase.TypeCodeObject:
                schemaType = new OracleTypeObject();
                break;

            case OracleTypeBase.TypeCodeCollection:
                schemaType = new OracleTypeCollection();
                break;

            default:
                if (!String.IsNullOrEmpty(owner))
                {
                    throw new NotSupportedException($"Type '{typeType}' is not supported. ");
                }

                schemaType = new OracleTypeObject().WithTypeCode(typeType);
                break;
            }

            schemaType.FullyQualifiedName = OracleObjectIdentifier.Create(owner, QualifyStringObject(reader["TYPE_NAME"]));

            return(schemaType);
        }
        private static void CreateOracleCollectionType(ModuleBuilder customTypeModuleBuilder, OracleTypeCollection collectionType, IDictionary <string, Type> customTypes)
        {
            var targetType         = typeof(object);
            var enclosingCharacter = String.Empty;

            if (collectionType.ElementDataType != null)
            {
                if (collectionType.ElementDataType.FullyQualifiedName.HasOwner)
                {
                    if (customTypes.TryGetValue(collectionType.ElementDataType.FullyQualifiedName.ToString().Replace("\"", null), out Type targetCustomType))
                    {
                        targetType = targetCustomType;
                    }
                }
                else
                {
                    targetType = OracleToNetTypeMapper.MapOracleTypeToNetType(collectionType.ElementDataType.FullyQualifiedName);

                    if (targetType == typeof(string))
                    {
                        enclosingCharacter = "'";
                    }
                }
            }

            var baseFactoryType = typeof(OracleTableValueFactoryBase <>);

            baseFactoryType = baseFactoryType.MakeGenericType(targetType);
            var fullyQualifiedCollectionTypeName = collectionType.FullyQualifiedName.ToString().Replace("\"", null);;
            var customTypeClassName = $"{DynamicAssemblyNameBase}.CollectionTypes.{MakeValidMemberName(fullyQualifiedCollectionTypeName)}";

            var customTypeBuilder = customTypeModuleBuilder.DefineType(customTypeClassName, TypeAttributes.Public | TypeAttributes.Class, baseFactoryType);

            AddOracleCustomTypeMappingAttribute(customTypeBuilder, fullyQualifiedCollectionTypeName);

            var baseConstructor = baseFactoryType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null);

            AddConstructor(customTypeBuilder, baseConstructor);

            ImplementAbstractStringValueProperty(customTypeBuilder, "FullyQualifiedName", fullyQualifiedCollectionTypeName);
            ImplementAbstractStringValueProperty(customTypeBuilder, "EnclosingCharacter", enclosingCharacter);
            ImplementAbstractStringValueProperty(customTypeBuilder, "ElementTypeName", collectionType.ElementDataType.FullyQualifiedName.ToString());

            customTypes.Add(fullyQualifiedCollectionTypeName, customTypeBuilder.CreateType());
        }
Exemplo n.º 4
0
		private static void Generate(OracleTypeCollection collectionType, TextWriter writer)
		{
			var owner = collectionType.FullyQualifiedName.NormalizedOwner.Trim('"');
			var name = collectionType.FullyQualifiedName.NormalizedName.Trim('"');

			var elementFullyQualifiedName = collectionType.ElementDataType.FullyQualifiedName;
			var elementClassName = elementFullyQualifiedName.HasOwner ? $"{elementFullyQualifiedName.NormalizedOwner.Trim('"')}_" : null;
			elementClassName = $"{elementClassName}{elementFullyQualifiedName.NormalizedName.Trim('"')}";

			writer.WriteLine($"[OracleCustomTypeMapping(\"{owner}.{name}\")]");
			writer.WriteLine($"public class {owner}_{name} : CustomCollectionTypeBase<{owner}_{name}, {elementClassName}>");
			writer.WriteLine("{");
			writer.WriteLine("}");
			writer.WriteLine();

			writer.WriteLine(CustomCollectionTypeBase);
			writer.WriteLine();
		}