예제 #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 AttachmentDefinition ReadAttachment(XmlReader reader, string baseDirectory)
        {
            //Move to <ProfilingType> element
            MoveToElement(reader, AttachmentElementName);
            Guid targetUid = Guid.Empty;
            List <ExportDefinition>     exports      = new List <ExportDefinition>();
            List <DependencyDefinition> dependencies = new List <DependencyDefinition>();
            List <AttributeDefinition>  attributes   = new List <AttributeDefinition>();

            //Read Attachment attributes
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case AttachmentTargetUidAttributeName:
                    targetUid = reader.ReadContentAsGuid();
                    break;
                }
            }

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

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

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

                case AttributeElementName:
                    AttributeDefinition attribute = ReadAttribute(reader);
                    attributes.Add(attribute);
                    break;
                }
            }
            AttachmentDefinition definition = new AttachmentDefinition(targetUid, exports, dependencies, attributes);

            return(definition);
        }
        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);
        }