FdoToolbox.Core.ETL.Specialized.FdoClassCopyOptions.ToElement C# (CSharp) Method

ToElement() private method

private ToElement ( ) : FdoCopyTaskElement
return FdoToolbox.Core.Configuration.FdoCopyTaskElement
        internal FdoCopyTaskElement ToElement()
        {
            FdoCopyTaskElement el = new FdoCopyTaskElement();
            el.name = this.Name;
            el.createIfNotExists = this.CreateIfNotExists;
            el.Options = new FdoCopyOptionsElement();
            el.Options.DeleteTarget = this.DeleteTarget;
            el.Options.Filter = this.SourceFilter;
            el.Options.FlattenGeometries = this.FlattenGeometries;
            el.Options.FlattenGeometriesSpecified = true;
            el.Options.ForceWKB = this.ForceWkb;
            el.Options.ForceWKBSpecified = true;

            if (this.BatchSize > 0)
                el.Options.BatchSize = this.BatchSize.ToString();

            el.Source = new FdoCopySourceElement();

            el.Source.connection = this.SourceConnectionName;
            el.Source.schema = this.SourceSchema;
            el.Source.@class = this.SourceClassName;

            el.Target = new FdoCopyTargetElement();

            el.Target.connection = this.TargetConnectionName;
            el.Target.schema = this.TargetSchema;
            el.Target.@class = this.TargetClassName;

            List<FdoPropertyMappingElement> propMappings = new List<FdoPropertyMappingElement>();
            List<FdoExpressionMappingElement> exprMappings = new List<FdoExpressionMappingElement>();

            List<string> check = new List<string>(this.CheckSourceProperties);
            Dictionary<string, FdoPropertyMappingElement> convRules = new Dictionary<string, FdoPropertyMappingElement>();
            foreach (FdoDataPropertyConversionRule rule in this.ConversionRules)
            {
                FdoPropertyMappingElement map = new FdoPropertyMappingElement();
                //map.sourceDataType = rule.SourceDataType.ToString();
                //map.targetDataType = rule.TargetDataType.ToString();
                map.nullOnFailedConversion = rule.NullOnFailure;
                map.truncate = rule.Truncate;
                map.source = rule.SourceProperty;
                map.target = rule.TargetProperty;
                if (check.Contains(map.source))
                    map.createIfNotExists = true;

                convRules.Add(map.source, map);
            }

            foreach (string prop in this.SourcePropertyNames)
            {
                if (convRules.ContainsKey(prop))
                {
                    propMappings.Add(convRules[prop]);
                }
                else
                {
                    FdoPropertyMappingElement map = new FdoPropertyMappingElement();
                    map.source = prop;
                    map.target = this.GetTargetProperty(prop);
                    if (check.Contains(map.source))
                        map.createIfNotExists = true;

                    propMappings.Add(map);
                }
            }

            foreach (string alias in this.SourceAliases)
            {
                FdoExpressionMappingElement map = new FdoExpressionMappingElement();
                map.alias = alias;
                map.Expression = this.GetExpression(alias);
                map.target = this.GetTargetPropertyForAlias(alias);
                if (check.Contains(map.alias))
                    map.createIfNotExists = true;

                exprMappings.Add(map);
            }

            el.PropertyMappings = propMappings.ToArray();
            el.ExpressionMappings = exprMappings.ToArray();

            return el;
        }