Ejemplo n.º 1
0
        public override IMap DeepClone()
        {
            ISourceMap sourceMap = new SourceMap();

            DeepCopy(sourceMap);
            return(sourceMap);
        }
Ejemplo n.º 2
0
        public static IDomainMap LoadFromAttributes(Assembly asm, bool useCache,bool validate)
        {
            IDomainMap domainMap = new DomainMap();

            foreach (DomainMapAttribute domainMapAttribute in asm.GetCustomAttributes(typeof(DomainMapAttribute), false))
            {
                DomainMap.FromDomainMapAttribute(domainMapAttribute, asm, domainMap);
                break;
            }

            foreach (SourceMapAttribute sourceMapAttribute in asm.GetCustomAttributes(typeof(SourceMapAttribute), false))
            {
                ISourceMap sourceMap = new SourceMap();
                sourceMap.DomainMap = domainMap;

                SourceMap.FromSourceMapAttribute(sourceMapAttribute, sourceMap);
                break;
            }

            //Make this 2-pass so that mapped inheritance hierarchies can be found.

            foreach (Type type in asm.GetTypes())
            {
                foreach (ClassMapAttribute classMapAttribute in type.GetCustomAttributes(typeof(ClassMapAttribute), false))
                {
                    IClassMap classMap = new ClassMap();
                    classMap.DomainMap = domainMap;
                    classMap.Name = type.Name;
                    string waste = classMapAttribute.DocElement ; // The idiot compiler won't compile unless I use the stinkin' classMapAttribute somehow...
                    break;
                }
            }

            foreach (Type type in asm.GetTypes())
            {
                foreach (ClassMapAttribute classMapAttribute in type.GetCustomAttributes(typeof(ClassMapAttribute), false))
                {
                    IClassMap classMap = domainMap.MustGetClassMap(type);
                    ClassMap.FromClassMapAttribute(classMapAttribute, type, classMap);

                    foreach (PropertyInfo propInfo in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
                    {
                        foreach (PropertyMapAttribute propertyMapAttribute in propInfo.GetCustomAttributes(typeof(PropertyMapAttribute), false))
                        {
                            IPropertyMap propertyMap = new PropertyMap();
                            propertyMap.ClassMap = classMap;
                            PropertyMap.FromPropertyMapAttribute(propertyMapAttribute, propInfo, propertyMap);

                            break;
                        }
                    }

                    break;
                }
            }

            RecalculateModel(domainMap);

            domainMap.Dirty = false;

            if (validate)
                ((DomainMap)domainMap).Validate();

            return domainMap;
        }
		protected virtual void DeserializeSourceMap(IDomainMap domainMap, XmlNode xmlSource)
		{
			ISourceMap sourceMap = new SourceMap();
			XmlNode xmlConnStr;
			XmlNodeList xmlTables;
			sourceMap.DomainMap = domainMap;
			if (!(xmlSource.Attributes["persistence-type"] == null))
			{
				sourceMap.PersistenceType = (PersistenceType) Enum.Parse(typeof (PersistenceType), xmlSource.Attributes["persistence-type"].Value);
			}
			if (!(xmlSource.Attributes["name"] == null))
			{
				sourceMap.Name = xmlSource.Attributes["name"].Value;
			}
			if (!(xmlSource.Attributes["schema"] == null))
			{
				sourceMap.Schema = xmlSource.Attributes["schema"].Value;
			}
			if (!(xmlSource.Attributes["catalog"] == null))
			{
				sourceMap.Catalog = xmlSource.Attributes["catalog"].Value;
			}
			if (!(xmlSource.Attributes["provider"] == null))
			{
				sourceMap.ProviderType = (ProviderType) Enum.Parse(typeof (ProviderType), xmlSource.Attributes["provider"].Value);
			}
			if (!(xmlSource.Attributes["type"] == null))
			{
				sourceMap.SourceType = (SourceType) Enum.Parse(typeof (SourceType), xmlSource.Attributes["type"].Value);
			}
			if (!(xmlSource.Attributes["provider-path"] == null))
			{
				sourceMap.ProviderAssemblyPath = xmlSource.Attributes["provider-path"].Value;
			}
			if (!(xmlSource.Attributes["provider-conn"] == null))
			{
				sourceMap.ProviderConnectionTypeName = xmlSource.Attributes["provider-conn"].Value;
			}
			if (!(xmlSource.Attributes["doc-path"] == null))
			{
				sourceMap.DocPath = xmlSource.Attributes["doc-path"].Value;
			}
			if (!(xmlSource.Attributes["doc-root"] == null))
			{
				sourceMap.DocRoot = xmlSource.Attributes["doc-root"].Value;
			}
			if (!(xmlSource.Attributes["doc-encoding"] == null))
			{
				sourceMap.DocEncoding = xmlSource.Attributes["doc-encoding"].Value;
			}
			if (!(xmlSource.Attributes["url"] == null))
			{
				sourceMap.Url = xmlSource.Attributes["url"].Value;
			}
			if (!(xmlSource.Attributes["domain-key"] == null))
			{
				sourceMap.DomainKey = xmlSource.Attributes["domain-key"].Value;
			}
			ArrayList metaData = sourceMap.MetaData;
			DeserializeMetaData(xmlSource, ref metaData);
			xmlConnStr = xmlSource.SelectSingleNode("connection-string");
			if (xmlConnStr != null)
			{
				sourceMap.ConnectionString = xmlConnStr.InnerText;
			}
			xmlTables = xmlSource.SelectNodes("table");
			foreach (XmlNode xmlTable in xmlTables)
			{
				DeserializeTableMap(sourceMap, xmlTable);
			}
		}
Ejemplo n.º 4
0
 public override IMap DeepClone()
 {
     ISourceMap sourceMap = new SourceMap();
     DeepCopy(sourceMap);
     return sourceMap;
 }