Created
July 27, 2016 09:49
-
-
Save milannankov/3b44472c53ea76040bd6391c06a10fe9 to your computer and use it in GitHub Desktop.
Logi Info Plugin Settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Plugin | |
{ | |
public void GetCustomData(ref rdServerObjects rdObjects) | |
{ | |
// Get plugin settings | |
var settings = new PluginSettings(ref rdObjects); | |
// Generate data using settings | |
var xmlDocument = new XmlDocument(); | |
xmlDocument = rdObjects.CurrentData; | |
var xmlElement = (XmlElement)xmlDocument.SelectSingleNode("//rdData"); | |
var dataElement1 = xmlDocument.CreateElement("myData"); | |
var xmlAttribute = xmlDocument.CreateAttribute("Id"); | |
xmlAttribute.Value = "1"; | |
dataElement1.Attributes.Append(xmlAttribute); | |
xmlAttribute = xmlDocument.CreateAttribute("DataString"); | |
// use DataString settings | |
xmlAttribute.Value = settings.DataString; | |
dataElement1.Attributes.Append(xmlAttribute); | |
xmlElement.AppendChild(dataElement1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PluginSettings | |
{ | |
public PluginSettings(ref rdServerObjects rdObjects) | |
{ | |
// Get all elements in the Constants node in (Application/_Settings) | |
var constants = rdObjects | |
.SettingsDefinition | |
.SelectNodes("//Constants") | |
.OfType<XmlElement>().FirstOrDefault(); | |
if(constants == null) | |
{ | |
throw new Exception("No plugin config constants defined"); | |
} | |
// Get the DataString setting | |
this.DataString = constants.Attributes["MyPluginSettingsDataString"].Value; | |
} | |
public string DataString | |
{ | |
get; | |
private set; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment