Exemplo n.º 1
0
        private void MergeAttachments()
        {
            foreach (AttachmentDefinition attachment in _attachments)
            {
                AttachmentDefinition    temp          = attachment;
                ProfilingTypeDefinition profilingType = _profilingTypes.FirstOrDefault(x => x.Uid == temp.TargetUid);
                if (profilingType != null)
                {
                    MergeExports(temp.Exports, profilingType.Exports);
                    MergeDependencies(temp.Dependencies, profilingType.Dependencies);
                    MergeAttributes(temp.Attributes, profilingType.Attributes);
                }

                ProfilingTargetDefinition profilingTarget = _profilingTargets.FirstOrDefault(x => x.Uid == temp.TargetUid);
                if (profilingTarget != null)
                {
                    MergeExports(temp.Exports, profilingTarget.Exports);
                    //MergeDependencies(temp.Dependencies, profilingTarget.Dependencies);
                }

                FrameworkDefinition framework = _frameworks.FirstOrDefault(x => x.Uid == temp.TargetUid);
                if (framework != null)
                {
                    MergeExports(temp.Exports, framework.Exports);
                    //MergeDependencies(temp.Dependencies, framework.Dependencies);
                }

                ProductivityDefinition productivity = _productivities.FirstOrDefault(x => x.Uid == temp.TargetUid);
                if (productivity != null)
                {
                    MergeExports(temp.Exports, productivity.Exports);
                    //MergeDependencies(temp.Dependencies, productivity.Dependencies);
                }
            }
        }
        private ExtensionDefinition ReadExtension(XmlReader reader, string baseDirectory)
        {
            //Move to <Extension> element
            MoveToElement(reader, ExtensionElementName);

            //Prepare Extension properties
            Guid uid = Guid.Empty;
            List <ProfilingTypeDefinition>        profilingTypes        = new List <ProfilingTypeDefinition>();
            List <ProfilingTargetDefinition>      profilingTargets      = new List <ProfilingTargetDefinition>();
            List <FrameworkDefinition>            frameworks            = new List <FrameworkDefinition>();
            List <ProductivityDefinition>         productivities        = new List <ProductivityDefinition>();
            List <ApplicationExtensionDefinition> applicationExtensions = new List <ApplicationExtensionDefinition>();
            List <LocalizationDefinition>         localizations         = new List <LocalizationDefinition>();
            List <AttachmentDefinition>           attachments           = new List <AttachmentDefinition>();

            //Read Extension attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case UidAttributeName:
                    uid = reader.ReadContentAsGuid();
                    break;
                }
            }

            //Move back to <Extension> element
            reader.MoveToElement();

            //Read <Extension> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement &&
                    string.Equals(ExtensionElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                case ProfilingTypeElementName:
                    ProfilingTypeDefinition profilingType = ReadProfilingType(reader, baseDirectory);
                    profilingTypes.Add(profilingType);
                    break;

                case ProfilingTargetElementName:
                    ProfilingTargetDefinition profilingTarget = ReadProfilingTarget(reader, baseDirectory);
                    profilingTargets.Add(profilingTarget);
                    break;

                case FrameworkElementName:
                    FrameworkDefinition framework = ReadFramework(reader, baseDirectory);
                    frameworks.Add(framework);
                    break;

                case ProductivityElementName:
                    ProductivityDefinition productivity = ReadProductivity(reader, baseDirectory);
                    productivities.Add(productivity);
                    break;

                case ApplicationExtensionElementName:
                    ApplicationExtensionDefinition applicationExtension = ReadApplicationExtension(reader, baseDirectory);
                    applicationExtensions.Add(applicationExtension);
                    break;

                case LocalizationElementName:
                    LocalizationDefinition localization = ReadLocalization(reader);
                    localizations.Add(localization);
                    break;

                case AttachmentElementName:
                    AttachmentDefinition attachment = ReadAttachment(reader, baseDirectory);
                    attachments.Add(attachment);
                    break;
                }
            }
            ExtensionDefinition extensionDefinition = new ExtensionDefinition(uid, baseDirectory, profilingTypes, profilingTargets, frameworks, productivities, applicationExtensions, attachments, localizations);

            return(extensionDefinition);
        }
        private ProductivityDefinition ReadProductivity(XmlReader reader, string baseDirectory)
        {
            //Move to <Productivity> element
            MoveToElement(reader, ProductivityElementName);

            //Prepare Productivity properties
            Guid uid = Guid.Empty;
            Guid profilingTypeUid = Guid.Empty;
            List <ExportDefinition>       exports       = new List <ExportDefinition>();
            List <LocalizationDefinition> localizations = new List <LocalizationDefinition>();
            List <AttributeDefinition>    attributes    = new List <AttributeDefinition>();
            List <DependencyDefinition>   dependencies  = new List <DependencyDefinition>();

            //Read Productivity attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case UidAttributeName:
                    uid = reader.ReadContentAsGuid();
                    break;

                case ProfilingTypeUidAttributeName:
                    profilingTypeUid = reader.ReadContentAsGuid();
                    break;
                }
            }

            //Move back to <Productivity> element
            reader.MoveToElement();

            //Read <Productivity> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement &&
                    string.Equals(ProductivityElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                case ExportElementName:
                    ExportDefinition export = ReadExport(reader, baseDirectory);
                    exports.Add(export);
                    break;

                case LocalizationElementName:
                    LocalizationDefinition localization = ReadLocalization(reader);
                    localizations.Add(localization);
                    break;

                case AttributeElementName:
                    AttributeDefinition attribute = ReadAttribute(reader);
                    attributes.Add(attribute);
                    break;

                case DependencyElementName:
                    DependencyDefinition dependency = ReadDependency(reader);
                    dependencies.Add(dependency);
                    break;
                }
            }

            ProductivityDefinition definition = new ProductivityDefinition(uid, exports, dependencies, localizations, attributes);

            return(definition);
        }