in src/CTA.Rules.RuleFiles/RulesFileParser.cs [101:214]
private void ProcessObject(Rootobject rootobject)
{
var namespaces = rootobject.NameSpaces;
foreach (var @namespace in namespaces)
{
if (@namespace.Actions != null && @namespace.Actions.Count > 0)
{
//Global Actions:
if (@namespace.@namespace == Constants.Project && @namespace.Assembly == Constants.Project)
{
var projectToken = _rootNodes.ProjectTokens.FirstOrDefault();
ParseActions(projectToken, @namespace.Actions);
}
//Namespace specific actions:
else
{
var usingToken = new UsingDirectiveToken() { Key = @namespace.@namespace };
var namespaceToken = new NamespaceToken() { Key = @namespace.@namespace };
if (!_rootNodes.Usingdirectivetokens.Contains(usingToken)) { _rootNodes.Usingdirectivetokens.Add(usingToken); }
if (!_rootNodes.NamespaceTokens.Contains(namespaceToken)) { _rootNodes.NamespaceTokens.Add(namespaceToken); }
ParseActions(usingToken, @namespace.Actions);
ParseActions(namespaceToken, @namespace.Actions);
}
}
foreach (var @class in @namespace.Classes)
{
if (@class.Actions != null && @class.Actions.Count > 0)
{
if (@class.KeyType == CTA.Rules.Config.Constants.BaseClass || @class.KeyType == CTA.Rules.Config.Constants.ClassName)
{
var token = new ClassDeclarationToken() { Key = @class.FullKey, FullKey = @class.FullKey, Namespace = @namespace.@namespace };
if (!_rootNodes.Classdeclarationtokens.Contains(token)) { _rootNodes.Classdeclarationtokens.Add(token); }
ParseActions(token, @class.Actions);
}
else if (@class.KeyType == CTA.Rules.Config.Constants.Identifier)
{
var token = new IdentifierNameToken() { Key = @class.FullKey, FullKey = @class.FullKey, Namespace = @namespace.@namespace };
if (!_rootNodes.Identifiernametokens.Contains(token)) { _rootNodes.Identifiernametokens.Add(token); }
ParseActions(token, @class.Actions);
}
}
foreach (var attribute in @class.Attributes)
{
if (attribute.Actions != null && attribute.Actions.Count > 0)
{
var token = new AttributeToken() { Key = attribute.Key, Namespace = @namespace.@namespace, FullKey = attribute.FullKey, Type = @class.Key };
if (!_rootNodes.Attributetokens.Contains(token)) { _rootNodes.Attributetokens.Add(token); }
ParseActions(token, attribute.Actions);
}
}
foreach (var method in @class.Methods)
{
if (method.Actions != null && method.Actions.Count > 0)
{
var token = new InvocationExpressionToken() { Key = method.Key, Namespace = @namespace.@namespace, FullKey = method.FullKey, Type = @class.Key };
if (!_rootNodes.Invocationexpressiontokens.Contains(token)) { _rootNodes.Invocationexpressiontokens.Add(token); }
ParseActions(token, method.Actions);
}
}
foreach (var objectCreation in @class.ObjectCreations)
{
if (objectCreation.Actions != null && objectCreation.Actions.Count > 0)
{
var token = new ObjectCreationExpressionToken() { Key = objectCreation.Key, Namespace = @namespace.@namespace, FullKey = objectCreation.FullKey, Type = @class.Key };
if (!_rootNodes.ObjectCreationExpressionTokens.Contains(token)) { _rootNodes.ObjectCreationExpressionTokens.Add(token); }
ParseActions(token, objectCreation.Actions);
}
}
}
foreach (var @interface in @namespace.Interfaces)
{
if (@interface.Actions != null && @interface.Actions.Count > 0)
{
if (@interface.KeyType == CTA.Rules.Config.Constants.BaseClass || @interface.KeyType == CTA.Rules.Config.Constants.InterfaceName)
{
var token = new InterfaceDeclarationToken() { Key = @interface.FullKey, FullKey = @interface.FullKey, Namespace = @namespace.@namespace };
if (!_rootNodes.InterfaceDeclarationTokens.Contains(token)) { _rootNodes.InterfaceDeclarationTokens.Add(token); }
ParseActions(token, @interface.Actions);
}
else if (@interface.KeyType == CTA.Rules.Config.Constants.Identifier)
{
var token = new IdentifierNameToken() { Key = @interface.FullKey, FullKey = @interface.FullKey, Namespace = @namespace.@namespace };
if (!_rootNodes.Identifiernametokens.Contains(token)) { _rootNodes.Identifiernametokens.Add(token); }
ParseActions(token, @interface.Actions);
}
}
foreach (var attribute in @interface.Attributes)
{
if (attribute.Actions != null && attribute.Actions.Count > 0)
{
var token = new AttributeToken() { Key = attribute.Key, Namespace = @namespace.@namespace, FullKey = attribute.FullKey, Type = @interface.Key };
if (!_rootNodes.Attributetokens.Contains(token)) { _rootNodes.Attributetokens.Add(token); }
ParseActions(token, attribute.Actions);
}
}
foreach (var method in @interface.Methods)
{
if (method.Actions != null && method.Actions.Count > 0)
{
var token = new InvocationExpressionToken() { Key = method.Key, Namespace = @namespace.@namespace, FullKey = method.FullKey, Type = @interface.Key };
if (!_rootNodes.Invocationexpressiontokens.Contains(token)) { _rootNodes.Invocationexpressiontokens.Add(token); }
ParseActions(token, method.Actions);
}
}
}
}
}