Esempio n. 1
0
        public void ParseMetadata(string fileName)
        {
            this.Source = fileName;
            this.Name   = new FileInfo(fileName).Name.Replace(new FileInfo(fileName).Extension, "");

            MDMLib.Document document = OpenMetadata(fileName, MDMLib.openConstants.oREAD);

            // Run through all variables of the mdm lib document.
            foreach (MDMLib.Variable _variable in document.Variables)
            {
                // Check if the variable is a field.
                if ((_variable is MDMLib.IMDMField) == false)
                {
                    continue;
                }

                if (!_variable.HasCaseData)
                {
                    continue;
                }

                MDMLib.IMDMField field = (MDMLib.IMDMField)_variable;

                if (this.Variables.ContainsKey(field.FullName))
                {
                    continue;
                }

                this.Variables.Add(field.FullName.Trim(), new TaxonomyVariable(
                                       field.FullName.Trim(),
                                       field.Label.Trim().ToLower(),
                                       this
                                       ));


                // Run through all categories of the variable.
                foreach (MDMLib.IElement _category in _variable.Categories)
                {
                    if (this.Variables[field.FullName.Trim()].Categories.ContainsKey(_category.Name.Trim()))
                    {
                        continue;
                    }

                    this.Variables[field.FullName.Trim()].Categories.Add(_category.Name.Trim(), new TaxonomyCategory(
                                                                             this.Variables[field.FullName.Trim()],
                                                                             _category.Name.Trim(),
                                                                             _category.Label.Trim().ToLower()
                                                                             ));

                    if (_category.Factor != null)
                    {
                        this.Variables[field.FullName.Trim()].Categories[_category.Name.Trim()].Value = _category.Factor;
                    }
                }
            }
        }
Esempio n. 2
0
        private void Read()
        {
            MDMLib.Document document = OpenMetadata(this.FileName, MDMLib.openConstants.oREAD);

            // Run through all variables of the mdm lib document.
            foreach (MDMLib.Variable _variable in document.Variables)
            {
                // Check if the variable is a field.
                if ((_variable is MDMLib.IMDMField) == false)
                {
                    continue;
                }

                if (!_variable.HasCaseData)
                {
                    continue;
                }

                MDMLib.IMDMField field = (MDMLib.IMDMField)_variable;

                if (this.Variables.ContainsKey(field.FullName))
                {
                    continue;
                }

                this.Variables.Add(field.FullName, new Variable(
                                       field.FullName,
                                       field.Label
                                       ));
                this.Categories.Add(field.FullName, new Dictionary <string, string>());
                this.CategoryFactors.Add(field.FullName, new Dictionary <string, double>());


                // Run through all categories of the variable.
                foreach (MDMLib.IElement _category in _variable.Categories)
                {
                    if (this.Categories[field.FullName].ContainsKey(_category.Name))
                    {
                        continue;
                    }

                    double factor;

                    double.TryParse(_category.Factor, out factor);

                    this.Categories[field.FullName].Add(_category.Name, _category.Label);
                    this.CategoryFactors[field.FullName].Add(_category.Name, factor);
                }
            }
        }