/// <summary> /// Creates a new instance of a FilterDeclaration. /// </summary> public FilterDeclaration(FilterDeclaration declaration) { EventTypeId = declaration.EventTypeId; Fields = new List <FilterDeclarationField>(declaration.Fields.Count); for (int ii = 0; ii < declaration.Fields.Count; ii++) { Fields.Add(new FilterDeclarationField(declaration.Fields[ii])); } }
/// <summary> /// Creates a new instance of a FilterDeclaration. /// </summary> public FilterDeclaration(TypeDeclaration eventType, FilterDeclaration template) { EventTypeId = eventType.NodeId; Fields = new List <FilterDeclarationField>( ); foreach (InstanceDeclaration instanceDeclaration in eventType.Declarations) { if (instanceDeclaration.NodeClass == NodeClass.Method) { continue; } if (NodeId.IsNull(instanceDeclaration.ModellingRule)) { continue; } FilterDeclarationField element = new FilterDeclarationField(instanceDeclaration); Fields.Add(element); // set reasonable defaults. if (template == null) { if (instanceDeclaration.RootTypeId == Opc.Ua.ObjectTypeIds.BaseEventType && instanceDeclaration.BrowseName != Opc.Ua.BrowseNames.EventId) { element.DisplayInList = true; } } // preserve filter settings. else { foreach (FilterDeclarationField field in template.Fields) { if (field.InstanceDeclaration.BrowsePathDisplayText == element.InstanceDeclaration.BrowsePathDisplayText) { element.DisplayInList = field.DisplayInList; element.FilterEnabled = field.FilterEnabled; element.FilterOperator = field.FilterOperator; element.FilterValue = field.FilterValue; break; } } } } }