I have come up with a problem that I want to encapsulate a method into a DLL file, but this method calls the method of zennoposter itself, which causes Microsoft visual studio can recognize this method.
How to encapsulate a method which covers the zennoposter method into my DLL file ?
FOR EXAMPLE A case that needs to call the script in the process of script execution, I need to write a lot of codes. But if I can encapsulate them into
Callscripts ( “Example”, “5”), which can save the time when editing to the most extent. But the Miscrosoft visual studio can recognize ZennoPoster.TasksList;ZennoPoster.SetExecutionSettings;and other methods, so I can’t get to the goal.
How to encapsulate a method which covers the zennoposter method into my DLL file ?
FOR EXAMPLE A case that needs to call the script in the process of script execution, I need to write a lot of codes. But if I can encapsulate them into
Callscripts ( “Example”, “5”), which can save the time when editing to the most extent. But the Miscrosoft visual studio can recognize ZennoPoster.TasksList;ZennoPoster.SetExecutionSettings;and other methods, so I can’t get to the goal.
C#:
var searchName = "Example1";
var searchResult = false;
// get the task list from the ZennoPoster
var tasks = ZennoPoster.TasksList;
foreach (var tsk in tasks)
{
// loading Xml documnt with task content
var doc = new System.Xml.XmlDocument();
doc.LoadXml("<Task>" + tsk + "</Task>");
// Search task by name
var nameElement = doc.SelectSingleNode("Task/Name");
if(nameElement == null) continue;
var name = nameElement.InnerText;
// if we found our task
if (name == searchName)
{
// take task id
var idElement = doc.SelectSingleNode("Task/Id");
if (idElement == null) continue;
var id = Guid.Parse(idElement.InnerText);
// take execution settings element
var esElement = doc.SelectSingleNode("Task/ExecutionSettings");
if (esElement == null) continue;
// take limit of threads of the task
var threadsElement = doc.SelectSingleNode("Task/ExecutionSettings/LimitOfThreads");
if (threadsElement == null) continue;
// change the value
threadsElement.InnerText = "5";
// set new settings
ZennoPoster.SetExecutionSettings(id, esElement.InnerXml);
{
// take execution settings element
var esElement1 = doc.SelectSingleNode("Task/ExecutionSettings");
if (esElement1 == null) continue;
// take limit of threads of the task
var threadsElement1 = doc.SelectSingleNode("Task/ExecutionSettings/NumberOfTries");
if (threadsElement1 == null) continue;
// change the value
threadsElement1.InnerText = project.Variables["rowCount"].Value;
// set new settings
ZennoPoster.SetExecutionSettings(id, esElement1.InnerXml);
}
searchResult = true;
break;
}
}
if (!searchResult)
thrownew Exception("Task " + searchName + " not found!");
Последнее редактирование модератором: