//******************************************************************************************************
// Identifier.cs - Gbtc
//
// Copyright © 2015, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 12/18/2015 - Stephen C. Wills
// Generated original version of source code.
//
//******************************************************************************************************
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace GSF.PQDIF
{
///
/// Represents an identifier as defined by the PQDIF standard.
///
public class Identifier
{
#region [ Members ]
// Fields
private string m_name;
private string m_standardName;
private string m_value;
private string m_description;
#endregion
#region [ Constructors ]
// Identifiers are readonly and can only be created by
// defining them in the TagDefinitions.xml file.
private Identifier()
{
}
#endregion
#region [ Properties ]
///
/// Gets the name of the identifier as defined by the GSF.PQDIF library.
///
public string Name => m_name;
///
/// Gets the name of the identifier as defined by the standard.
///
public string StandardName => m_standardName;
///
/// Gets a string representation of the value of this identifier.
///
public string Value => m_value;
///
/// Gets a description of the identifier.
///
public string Description => m_description;
#endregion
#region [ Static ]
// Static Methods
///
/// Generates a list of identifiers valid for the given tag from the given XML document.
///
/// The XML document containing tag definitions.
/// The tag for which valid identifier values are to be generated.
/// The list of identifiers valid for the given tag.
public static List GenerateIdentifiers(XDocument doc, Tag tag)
{
XElement tagValues = doc.Descendants("tagValues").Single();
XElement tagElement = tagValues.Element(tag.StandardName);
if ((object)tagElement == null)
return new List();
return tagElement
.Elements()
.Select(element => new Identifier()
{
m_name = (string)element.Element("name"),
m_standardName = (string)element.Element("standardName"),
m_value = (string)element.Element("value"),
m_description = (string)element.Element("description")
})
.ToList();
}
#endregion
}
}