Ejemplo n.º 1
0
        private void WriteProperties(IChemObject obj, CMLElement cmlElement)
        {
            var props = obj.GetProperties();

            foreach (var key in props.Keys)
            {
                var stringKey = (string)key;
                switch (stringKey)
                {
                case CDKPropertyName.Title:
                    // don't output this one. It's covered by AddTitle()
                    break;

                default:
                    if (!(stringKey.StartsWith("org.openscience.cdk", StringComparison.Ordinal)))
                    {
                        object value  = props[key];
                        var    scalar = new CMLScalar();
                        this.CheckPrefix(scalar);
                        scalar.Title = (string)key;
                        scalar.Value = value.ToString();
                        cmlElement.Add(scalar);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 private void CheckPrefix(CMLElement element)
 {
     if (string.IsNullOrWhiteSpace(prefix))
     {
         prefix = null;
     }
     if (prefix != null)
     {
         element.Name = (XNamespace)(this.prefix) + element.Name.LocalName;
     }
 }
Ejemplo n.º 3
0
        public CMLElement(CMLElement element)
            : base(element.Name)
        {
            foreach (var att in element.Attributes())
            {
                SetAttributeValue(att.Name, att.Value);
            }

            foreach (var child in element.Nodes())
            {
                Add(child); // dont clone
            }
        }
Ejemplo n.º 4
0
        private static bool AddDictRef(IChemObject obj, CMLElement cmlElement)
        {
            var properties = obj.GetProperties();

            foreach (var key in properties.Keys)
            {
                if (key is string keyName)
                {
                    if (keyName.StartsWith(DictionaryDatabase.DictRefPropertyName, StringComparison.Ordinal))
                    {
                        string dictRef = (string)properties[keyName];
                        cmlElement.SetAttributeValue("dictRef", dictRef);
                        return(true);
                    }
                }
            }
            return(false);
        }