Ejemplo n.º 1
0
        public void Instantiate(SymbolTable symbolTable, UnboundReferences unboundReferences)
        {
            var parentContainer = ParentItem as AstContainerTaskBaseNode;
            var taskTemplate    = Template as AstTaskTemplateNode;
            var clonedMapping   = new Dictionary <IFrameworkItem, IFrameworkItem>();

            if (taskTemplate != null && parentContainer != null)
            {
                var clonedTasks = new List <AstTaskNode>();
                foreach (var task in taskTemplate.Tasks)
                {
                    clonedTasks.Add((AstTaskNode)task.Clone(parentContainer, clonedMapping));
                }

                parentContainer.Tasks.Replace(this, clonedTasks);
            }

            foreach (var bindingItem in taskTemplate.UnboundReferences)
            {
                var clonedBindingItem = new BindingItem(
                    bindingItem.BoundProperty,
                    bindingItem.XObject,
                    bindingItem.XValue,
                    clonedMapping[bindingItem.ParentItem],
                    bindingItem.BimlFile,
                    this);
                unboundReferences.Add(clonedBindingItem);
            }
        }
Ejemplo n.º 2
0
        public void Instantiate(SymbolTable symbolTable, UnboundReferences unboundReferences)
        {
            var parentContainer = ParentItem as AstContainerTaskBaseNode;
            var taskTemplate = Template as AstTaskTemplateNode;
            var clonedMapping = new Dictionary<IFrameworkItem, IFrameworkItem>();
            if (taskTemplate != null && parentContainer != null)
            {
                var clonedTasks = new List<AstTaskNode>();
                foreach (var task in taskTemplate.Tasks)
                {
                    clonedTasks.Add((AstTaskNode)task.Clone(parentContainer, clonedMapping));
                }

                parentContainer.Tasks.Replace(this, clonedTasks);
            }

            foreach (var bindingItem in taskTemplate.UnboundReferences)
            {
                var clonedBindingItem = new BindingItem(
                    bindingItem.BoundProperty,
                    bindingItem.XObject,
                    bindingItem.XValue,
                    clonedMapping[bindingItem.ParentItem],
                    bindingItem.BimlFile,
                    this);
                unboundReferences.Add(clonedBindingItem);
            }
        }
        public void Instantiate(SymbolTable symbolTable, UnboundReferences unboundReferences)
        {
            var parentEtl = ParentItem as AstEtlRootNode;
            var transformationTemplate = Template as AstTransformationTemplateNode;
            var clonedMapping          = new Dictionary <IFrameworkItem, IFrameworkItem>();

            if (transformationTemplate != null && parentEtl != null)
            {
                var clonedTransformations = new List <AstTransformationNode>();
                foreach (var transformation in transformationTemplate.Transformations)
                {
                    clonedTransformations.Add((AstTransformationNode)transformation.Clone(parentEtl, clonedMapping));
                }

                parentEtl.Transformations.Replace(this, clonedTransformations);
            }

            foreach (var bindingItem in transformationTemplate.UnboundReferences)
            {
                var clonedBindingItem = new BindingItem(
                    bindingItem.BoundProperty,
                    bindingItem.XObject,
                    bindingItem.XValue,
                    clonedMapping[bindingItem.ParentItem],
                    bindingItem.BimlFile,
                    this);
                unboundReferences.Add(clonedBindingItem);
            }
        }
Ejemplo n.º 4
0
        public static UnboundReferences ParseBimlFiles(IEnumerable <BimlFile> bimlFiles, ISymbolTableProvider astRootNode, LanguageSettings languageSettings)
        {
            var unboundReferences = new UnboundReferences();

            foreach (BimlFile bimlFile in bimlFiles)
            {
                var xdocument = bimlFile.XDocument;
                if (xdocument != null && xdocument.Root != null)
                {
                    try
                    {
                        SideEffectManager.SideEffectMode = AstSideEffectMode.NoSideEffects;
                        ParseDocument(bimlFile, astRootNode, unboundReferences, languageSettings);
                        SideEffectManager.SideEffectMode = AstSideEffectMode.ConsistencySideEffects;

                        bimlFile.IsParseable = true;
                    }
                    catch (Exception)
                    {
                        bimlFile.IsParseable = false;
                    }
                }
            }

            unboundReferences.ResolveAll(astRootNode.SymbolTable);
            return(unboundReferences);
        }
Ejemplo n.º 5
0
        public static UnboundReferences ParseBimlFiles(IEnumerable<BimlFile> bimlFiles, ISymbolTableProvider astRootNode, LanguageSettings languageSettings)
        {
            var unboundReferences = new UnboundReferences();
            foreach (BimlFile bimlFile in bimlFiles)
            {
                var xdocument = bimlFile.XDocument;
                if (xdocument != null && xdocument.Root != null)
                {
                    try
                    {
                        SideEffectManager.SideEffectMode = AstSideEffectMode.NoSideEffects;
                        ParseDocument(bimlFile, astRootNode, unboundReferences, languageSettings);
                        SideEffectManager.SideEffectMode = AstSideEffectMode.ConsistencySideEffects;

                        bimlFile.IsParseable = true;
                    }
                    catch (Exception)
                    {
                        bimlFile.IsParseable = false;
                    }
                }
            }

            unboundReferences.ResolveAll(astRootNode.SymbolTable);
            return unboundReferences;
        }
Ejemplo n.º 6
0
        public void Instantiate(SymbolTable symbolTable, UnboundReferences unboundReferences)
        {
            var rootNode        = ParentItem as AstRootNode;
            var packageTemplate = Template as AstPackageTemplateNode;
            var clonedMapping   = new Dictionary <IFrameworkItem, IFrameworkItem>();

            if (packageTemplate != null && rootNode != null)
            {
                var clonedPackage = (AstPackageNode)packageTemplate.Package.Clone(rootNode, clonedMapping);
                clonedPackage.Emit = this.Emit;

                // TODO: Some of the ViewModel stuff might not fully support Replace - so simulating with Remove and Insert
                int index = rootNode.Packages.IndexOf(this);
                rootNode.Packages.Remove(this);
                rootNode.Packages.Insert(index, clonedPackage);
            }

            foreach (var bindingItem in packageTemplate.UnboundReferences)
            {
                var clonedBindingItem = new BindingItem(
                    bindingItem.BoundProperty,
                    bindingItem.XObject,
                    bindingItem.XValue,
                    clonedMapping[bindingItem.ParentItem],
                    bindingItem.BimlFile,
                    this);
                unboundReferences.Add(clonedBindingItem);
            }
        }
Ejemplo n.º 7
0
        public void Instantiate(SymbolTable symbolTable, UnboundReferences unboundReferences)
        {
            var rootNode = ParentItem as AstRootNode;
            var tableTemplate = Template as AstTableTemplateNode;
            var clonedMapping = new Dictionary<IFrameworkItem, IFrameworkItem>();
            if (tableTemplate != null && rootNode != null)
            {
                var clonedTable = (AstTableNode)tableTemplate.Table.Clone(rootNode, clonedMapping);
                clonedTable.Emit = this.Emit;

                // TODO: Some of the ViewModel stuff might not fully support Replace - so simulating with Remove and Insert
                int index = rootNode.Tables.IndexOf(this);
                rootNode.Tables.Remove(this);
                rootNode.Tables.Insert(index, clonedTable);
            }

            foreach (var bindingItem in tableTemplate.UnboundReferences)
            {
                var clonedBindingItem = new BindingItem(
                    bindingItem.BoundProperty,
                    bindingItem.XObject,
                    bindingItem.XValue,
                    clonedMapping[bindingItem.ParentItem],
                    bindingItem.BimlFile,
                    this);
                unboundReferences.Add(clonedBindingItem);
            }
        }
        public void Instantiate(SymbolTable symbolTable, UnboundReferences unboundReferences)
        {
            var parentEtl = ParentItem as AstEtlRootNode;
            var transformationTemplate = Template as AstTransformationTemplateNode;
            var clonedMapping = new Dictionary<IFrameworkItem, IFrameworkItem>();
            if (transformationTemplate != null && parentEtl != null)
            {
                var clonedTransformations = new List<AstTransformationNode>();
                foreach (var transformation in transformationTemplate.Transformations)
                {
                    clonedTransformations.Add((AstTransformationNode)transformation.Clone(parentEtl, clonedMapping));
                }

                parentEtl.Transformations.Replace(this, clonedTransformations);
            }

            foreach (var bindingItem in transformationTemplate.UnboundReferences)
            {
                var clonedBindingItem = new BindingItem(
                    bindingItem.BoundProperty,
                    bindingItem.XObject,
                    bindingItem.XValue,
                    clonedMapping[bindingItem.ParentItem],
                    bindingItem.BimlFile,
                    this);
                unboundReferences.Add(clonedBindingItem);
            }
        }
Ejemplo n.º 9
0
 public ParserContext(XElement element, IFrameworkItem parentFrameworkItem, ITemplate currentTemplate, BimlFile bimlFile, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     XElement          = element;
     FrameworkItem     = parentFrameworkItem;
     Template          = currentTemplate;
     BimlFile          = bimlFile;
     UnboundReferences = unboundReferences;
     LanguageSettings  = languageSettings;
 }
Ejemplo n.º 10
0
 public ParserContext(XElement element, IFrameworkItem parentFrameworkItem, ITemplate currentTemplate, BimlFile bimlFile, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     XElement = element;
     FrameworkItem = parentFrameworkItem;
     Template = currentTemplate;
     BimlFile = bimlFile;
     UnboundReferences = unboundReferences;
     LanguageSettings = languageSettings;
 }
Ejemplo n.º 11
0
        public IIR Execute(IIR predecessorIR)
        {
            var xmlIR = predecessorIR as XmlIR;

            if (xmlIR == null)
            {
                // Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name);
            }

            var astIR = new AstIR(xmlIR)
            {
                AstRootNode = new AstRootNode(null)
            };

            var unboundReferences = new UnboundReferences();
            var languageSettings  = new LanguageSettings(_defaultXmlNamespace, typeof(AstNode));

            foreach (BimlFile bimlFile in astIR.BimlFiles)
            {
                if (bimlFile.XDocument.Root != null)
                {
                    AstParser.ParseDocument(bimlFile, astIR.AstRootNode, unboundReferences, languageSettings);
                }
            }

            unboundReferences.ResolveAll(astIR.AstRootNode.SymbolTable);
            CompileTimeResolver.ResolveAll(astIR.AstRootNode.SymbolTable, unboundReferences);

            if (unboundReferences.Count > 0)
            {
                foreach (var unboundReference in unboundReferences)
                {
                    string filename            = unboundReference.BimlFile.Name;
                    string refName             = unboundReference.XValue;
                    string refTypeFriendlyName = unboundReference.BoundProperty.PropertyType.Name;
                    string xml           = unboundReference.XObject.ToString();
                    int    line          = ((IXmlLineInfo)unboundReference.XObject).LineNumber;
                    int    offset        = ((IXmlLineInfo)unboundReference.XObject).LinePosition;
                    var    friendlyNames = (FriendlyNameAttribute[])unboundReference.BoundProperty.PropertyType.GetCustomAttributes(typeof(FriendlyNameAttribute), false);
                    if (friendlyNames != null && friendlyNames.Length > 0)
                    {
                        refTypeFriendlyName = friendlyNames[0].FriendlyName;
                    }

                    // TODO: Fatal Error
                    MessageEngine.Trace(filename, line, offset, Severity.Error, "V0101", null, "Could not resolve reference to '{0}' of type '{1}'. '{2}' is invalid.", refName, refTypeFriendlyName, xml);
                }

                throw new InvalidOperationException("Parsing was unsuccessful.");
            }

            return(astIR);
        }
Ejemplo n.º 12
0
        public IIR Execute(IIR predecessorIR)
        {
            var xmlIR = predecessorIR as XmlIR;
            if (xmlIR == null)
            {
                // Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name);
            }

            var astIR = new AstIR(xmlIR) { AstRootNode = new AstRootNode(null) };

            var unboundReferences = new UnboundReferences();
            var languageSettings = new LanguageSettings(_defaultXmlNamespace, typeof(AstNode));
            foreach (BimlFile bimlFile in astIR.BimlFiles)
            {
                if (bimlFile.XDocument.Root != null)
                {
                    AstParser.ParseDocument(bimlFile, astIR.AstRootNode, unboundReferences, languageSettings);
                }
            }

            unboundReferences.ResolveAll(astIR.AstRootNode.SymbolTable);
            CompileTimeResolver.ResolveAll(astIR.AstRootNode.SymbolTable, unboundReferences);

            if (unboundReferences.Count > 0)
            {
                foreach (var unboundReference in unboundReferences)
                {
                    string filename = unboundReference.BimlFile.Name;
                    string refName = unboundReference.XValue;
                    string refTypeFriendlyName = unboundReference.BoundProperty.PropertyType.Name;
                    string xml = unboundReference.XObject.ToString();
                    int line = ((IXmlLineInfo)unboundReference.XObject).LineNumber;
                    int offset = ((IXmlLineInfo)unboundReference.XObject).LinePosition;
                    var friendlyNames = (FriendlyNameAttribute[])unboundReference.BoundProperty.PropertyType.GetCustomAttributes(typeof(FriendlyNameAttribute), false);
                    if (friendlyNames != null && friendlyNames.Length > 0)
                    {
                        refTypeFriendlyName = friendlyNames[0].FriendlyName;
                    }

                    // TODO: Fatal Error
                    MessageEngine.Trace(filename, line, offset, Severity.Error, "V0101", null, "Could not resolve reference to '{0}' of type '{1}'. '{2}' is invalid.", refName, refTypeFriendlyName, xml);
                }

                throw new InvalidOperationException("Parsing was unsuccessful.");
            }

            return astIR;
        }
Ejemplo n.º 13
0
        private static void ResolveTemplateInstances(SymbolTable symbolTable, UnboundReferences unboundReferences)
        {
            foreach (ITemplate template in symbolTable[typeof(ITemplate)])
            {
                template.UnboundReferences.ResolveAll(symbolTable);
            }

            // Iteratively pick off templates that are not in a template until they've all been processed
            // This logic is required to enable nesting of template instances within templates
            var templateInstance = symbolTable[typeof(ITemplateInstance)].FirstOrDefault(item => item.FirstThisOrParent <ITemplate>() == null);

            while (templateInstance != null)
            {
                ((ITemplateInstance)templateInstance).Instantiate(symbolTable, unboundReferences);
                templateInstance = symbolTable[typeof(ITemplateInstance)].FirstOrDefault(item => item.FirstThisOrParent <ITemplate>() == null);
            }
        }
Ejemplo n.º 14
0
 protected AstTemplateNode(IFrameworkItem parentItem)
     : base(parentItem)
 {
     InitializeAstNode();
     UnboundReferences = new UnboundReferences();
 }
Ejemplo n.º 15
0
 public static UnboundReferences ParseDocument(BimlFile bimlFile, IFrameworkItem frameworkItem, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     RecursiveParseElement(new ParserContext(bimlFile.XDocument.Root, frameworkItem, null, bimlFile, unboundReferences, languageSettings));
     return(unboundReferences);
 }
Ejemplo n.º 16
0
 public static UnboundReferences ParseElement(XElement element, IFrameworkItem frameworkItem, BimlFile bimlFile, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     frameworkItem.BoundXObject = new XObjectMapping(element, null);
     RecursiveParseElement(new ParserContext(element, frameworkItem, null, bimlFile, unboundReferences, languageSettings));
     return(unboundReferences);
 }
Ejemplo n.º 17
0
 public static UnboundReferences ParseDocument(BimlFile bimlFile, IFrameworkItem frameworkItem, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     RecursiveParseElement(new ParserContext(bimlFile.XDocument.Root, frameworkItem, null, bimlFile, unboundReferences, languageSettings));
     return unboundReferences;
 }
Ejemplo n.º 18
0
 public static UnboundReferences ParseElement(XElement element, IFrameworkItem frameworkItem, BimlFile bimlFile, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     frameworkItem.BoundXObject = new XObjectMapping(element, null);
     RecursiveParseElement(new ParserContext(element, frameworkItem, null, bimlFile, unboundReferences, languageSettings));
     return unboundReferences;
 }
Ejemplo n.º 19
0
 private static void ResolveUnboundReferences(SymbolTable symbolTable, UnboundReferences unboundReferences)
 {
     unboundReferences.ResolveAll(symbolTable);
 }
Ejemplo n.º 20
0
 protected AstTemplateNode(IFrameworkItem parentItem)
     : base(parentItem)
 {
     InitializeAstNode();
     UnboundReferences = new UnboundReferences();
 }
Ejemplo n.º 21
0
 public static void ResolveAll(SymbolTable symbolTable, UnboundReferences unboundReferences)
 {
     ResolveTemplateInstances(symbolTable, unboundReferences);
     ResolveUnboundReferences(symbolTable, unboundReferences);
 }