Exemple #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 ProfilingTargetDefinition ReadProfilingTarget(XmlReader reader, string baseDirectory)
        {
            //Move to <ProfilingTarget> element
            MoveToElement(reader, ProfilingTargetElementName);

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

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

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

            //Read <ProfilingTarget> element content
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement &&
                    string.Equals(ProfilingTargetElementName, 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;
                }
            }

            ProfilingTargetDefinition definition = new ProfilingTargetDefinition(uid, exports, localizations, attributes);

            return(definition);
        }
        public static Catalog Filter(Catalog catalog, ConfigurationSettings configurationSettings)
        {
            ExtensionDefinition extension;
            //Extensions
            List <ExtensionDefinition> extensions = new List <ExtensionDefinition>();
            //Productivities
            List <ProductivityDefinition> productivities = new List <ProductivityDefinition>(catalog.Productivities);
            //ProfilingTypes
            List <ProfilingTypeDefinition> profilingTypes = new List <ProfilingTypeDefinition>();

            foreach (ProfilingTypeSettings settings in configurationSettings.ProfilingTypesSettings)
            {
                ProfilingTypeDefinition profilingType = catalog.ProfilingTypes[settings.Uid];
                profilingTypes.Add(profilingType);
                extension = catalog.Extensions.First(x => x.ProfilingTypes.Contains(profilingType));
                if (!extensions.Contains(extension))
                {
                    extensions.Add(extension);
                }
            }
            //Frameworks
            List <FrameworkDefinition> frameworks = new List <FrameworkDefinition>();

            foreach (FrameworkSettings settings in configurationSettings.FrameworksSettings)
            {
                FrameworkDefinition framework = catalog.Frameworks[settings.Uid];
                frameworks.Add(framework);
                extension = catalog.Extensions.First(x => x.Frameworks.Contains(framework));
                if (!extensions.Contains(extension))
                {
                    extensions.Add(extension);
                }
            }
            //ProfilingTarget
            ProfilingTargetDefinition        profilingTarget  = catalog.ProfilingTargets[configurationSettings.ProfilingTargetSettings.Uid];
            List <ProfilingTargetDefinition> profilingTargets = new List <ProfilingTargetDefinition> {
                profilingTarget
            };

            extension = catalog.Extensions.First(x => x.ProfilingTargets.Contains(profilingTarget));
            if (!extensions.Contains(extension))
            {
                extensions.Add(extension);
            }
            catalog = new Catalog(extensions, frameworks, profilingTypes, profilingTargets, productivities);
            return(catalog);
        }
        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);
        }