NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode Class Reference
Inheritance diagram for Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode:
Collaboration diagram for Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode:

Public Member Functions

 PermissionSyntaxNode (string name, int line)
 
- Public Member Functions inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< PermissionConfiguration >
void Add (ISyntaxNode node)
 
void Assemble (ISyntaxNode node)
 
Compile ()
 
void CompileNode ()
 
IEnumerator< ISyntaxNodeGetEnumerator ()
 
void Resolve (SymbolTable table)
 
void Validate (SymbolTable table)
 

Protected Member Functions

override PermissionConfiguration InternalCompile ()
 
override void InternalResolve (SymbolTable table)
 
override void ValidateMandatories ()
 Override to validates the mandatory types in this syntax node. More...
 
override void ValidateTypes ()
 Override to validates the types in this syntax node. More...
 
- Protected Member Functions inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< PermissionConfiguration >
 SyntaxNode (Symbol symbol, string name, int line, bool requirePath=false)
 
void AddError (string message)
 
void AddReferenceNameError (ISyntaxNode node, string keyword, string name)
 
void AddReferenceTypeError (ISyntaxNode node, string keyword, string section, string name)
 
void CheckAllIsPresent (IEnumerable< Symbol > list)
 
void CheckIsUnique (IEnumerable< Symbol > list)
 
Uri CheckLink (string link, string keyword)
 
void CheckOneIsPresent (IEnumerable< Symbol > list)
 
void CheckOnlyOneIsPresent (IEnumerable< Symbol > list)
 
void CheckTypeIs< TU > (Symbol symbol)
 
void CheckTypeIs< TU, TV > (Symbol symbol)
 
virtual void InternalResolve (SymbolTable table)
 Override to resolve references to other syntax nodes from this syntax node. More...
 
virtual void ValidateReferences (SymbolTable table)
 Override to validates the references in this syntax node. More...
 

Private Attributes

uint appUserId
 
uint fileUserId
 
uint groupId
 

Additional Inherited Members

- Public Attributes inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< PermissionConfiguration >
ConfigurationNode CompiledNode
 
IEnumerable< string > Errors
 
bool HasErrors
 
- Properties inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< PermissionConfiguration >
int Line [get]
 
string Name [get]
 
List< ISyntaxNodeNodes [get]
 
bool RequirePath [get]
 
Symbol Symbol [get]
 

Detailed Description

Definition at line 31 of file PermissionSyntaxNode.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.PermissionSyntaxNode ( string  name,
int  line 
)
inline

Definition at line 33 of file PermissionSyntaxNode.cs.

References Ntp.Analyzer.Config.Table.KeywordPermission.

34  : base(Symbol.KeywordPermission, name, line)
35  {
36  }

Member Function Documentation

override PermissionConfiguration Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.InternalCompile ( )
inlineprotectedvirtual

Implements Ntp.Analyzer.Config.Syntax.SyntaxNode< PermissionConfiguration >.

Definition at line 42 of file PermissionSyntaxNode.cs.

43  {
44  var appUserName = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordExecUser) as StringSettingNode;
45  var fileUserName = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordUser) as StringSettingNode;
46  var groupName = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordGroup) as StringSettingNode;
47  var fileMode = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordMode) as IntegerSettingNode;
48 
49  return new PermissionConfiguration(
50  Name,
51  appUserId,
52  appUserName?.Value,
53  fileUserId,
54  fileUserName?.Value,
55  groupId,
56  groupName?.Value,
57  (uint?) fileMode?.Value
58  );
59  }
override void Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.InternalResolve ( SymbolTable  table)
inlineprotected

Definition at line 61 of file PermissionSyntaxNode.cs.

References Ntp.Common.IO.Permission.GetGroupId(), and Ntp.Common.IO.Permission.GetUserId().

62  {
63  // Find app user ID
64  var appUserIdNode = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordExecUser) as IntegerSettingNode;
65  var appUserNameNode = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordExecUser) as StringSettingNode;
66  if (appUserNameNode != null)
67  {
68  appUserId = Permission.GetUserId(appUserNameNode.Value);
69  }
70  else if (appUserIdNode != null)
71  {
72  appUserId = (uint?) appUserIdNode.Value;
73  }
74 
75  // Find file user ID
76  var fileUserIdNode = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordUser) as IntegerSettingNode;
77  var fileUserNameNode = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordUser) as StringSettingNode;
78  if (fileUserNameNode != null)
79  {
80  fileUserId = Permission.GetUserId(fileUserNameNode.Value);
81  }
82  else if (fileUserIdNode != null)
83  {
84  fileUserId = (uint?) fileUserIdNode.Value;
85  }
86 
87  // Find file group ID
88  var groupIdNode = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordGroup) as IntegerSettingNode;
89  var groupNameNode = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordGroup) as StringSettingNode;
90  if (groupNameNode != null)
91  {
92  groupId = Permission.GetGroupId(groupNameNode.Value);
93  }
94  else if (groupIdNode != null)
95  {
96  groupId = (uint?) groupIdNode.Value;
97  }
98  }
static uint GetGroupId(string groupName)
Definition: Permission.cs:48
static uint GetUserId(string userName)
Definition: Permission.cs:58

Here is the call graph for this function:

override void Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.ValidateMandatories ( )
inlineprotectedvirtual

Override to validates the mandatory types in this syntax node.

When overriding this method do not call the base method.

Reimplemented from Ntp.Analyzer.Config.Syntax.SyntaxNode< PermissionConfiguration >.

Definition at line 100 of file PermissionSyntaxNode.cs.

101  {
102  CheckIsUnique(new List<Symbol>
103  {
104  Symbol.KeywordExecUser,
105  Symbol.KeywordUser,
106  Symbol.KeywordGroup,
107  Symbol.KeywordMode
108  });
109  }
override void Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.ValidateTypes ( )
inlineprotectedvirtual

Override to validates the types in this syntax node.

When overriding this method do not call the base method.

Reimplemented from Ntp.Analyzer.Config.Syntax.SyntaxNode< PermissionConfiguration >.

Definition at line 111 of file PermissionSyntaxNode.cs.

112  {
113  CheckTypeIs<IntegerSettingNode, StringSettingNode>(Symbol.KeywordExecUser);
114  CheckTypeIs<IntegerSettingNode, StringSettingNode>(Symbol.KeywordUser);
115  CheckTypeIs<IntegerSettingNode, StringSettingNode>(Symbol.KeywordGroup);
116  CheckTypeIs<IntegerSettingNode>(Symbol.KeywordMode);
117  }

Member Data Documentation

uint Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.appUserId
private

Definition at line 38 of file PermissionSyntaxNode.cs.

uint Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.fileUserId
private

Definition at line 39 of file PermissionSyntaxNode.cs.

uint Ntp.Analyzer.Config.Syntax.PermissionSyntaxNode.groupId
private

Definition at line 40 of file PermissionSyntaxNode.cs.


The documentation for this class was generated from the following file: