Last active
June 16, 2016 20:38
-
-
Save bzshang/11e3c3145d60dcc5c2861167392a9827 to your computer and use it in GitHub Desktop.
This file contains 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
using System.Collections.Generic; | |
using OSIsoft.AF; | |
using OSIsoft.AF.Search; | |
namespace ElementSearch | |
{ | |
public class AFElementSearchBuilder | |
{ | |
private AFDatabase _database; | |
private string _name; | |
private IList<AFSearchToken> _tokens; | |
public static AFElementSearchBuilder Create() | |
{ | |
return new AFElementSearchBuilder(); | |
} | |
private AFElementSearchBuilder() | |
{ | |
_database = new PISystems().DefaultPISystem.Databases.DefaultDatabase; | |
_name = "AFElementSearch"; | |
_tokens = new List<AFSearchToken>(); | |
} | |
public AFElementSearchBuilder SetDatabase(AFDatabase database) | |
{ | |
_database = database; | |
return this; | |
} | |
public AFElementSearchBuilder SetName(string name) | |
{ | |
_name = name; | |
return this; | |
} | |
public AFElementSearchBuilder AddToken(AFSearchToken searchToken) | |
{ | |
_tokens.Add(searchToken); | |
return this; | |
} | |
public AFElementSearch Build() | |
{ | |
return new AFElementSearch(_database, _name, _tokens); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment