// Static Constructor static SecurityHub() { CategorizedSettingsElementCollection systemSettings = ConfigurationFile.Current.Settings["systemSettings"]; // Retrieve default NodeID DefaultNodeID = Guid.Parse(systemSettings["NodeID"].Value.ToNonNullString(Guid.NewGuid().ToString())); // Determine whether the node exists in the database and create it if it doesn't using (AdoDataConnection connection = new AdoDataConnection("securityProvider")) { const string NodeCountFormat = "SELECT COUNT(*) FROM Node"; const string NodeInsertFormat = "INSERT INTO Node(Name, Description, Enabled) VALUES('Default', 'Default node', 1)"; const string NodeUpdateFormat = "UPDATE Node SET ID = {0}"; int nodeCount = connection.ExecuteScalar <int?>(NodeCountFormat) ?? 0; if (nodeCount == 0) { connection.ExecuteNonQuery(NodeInsertFormat); connection.ExecuteNonQuery(NodeUpdateFormat, connection.Guid(DefaultNodeID)); } } // Analyze and cache record operations of security hub s_recordOperationsCache = new RecordOperationsCache(typeof(SecurityHub)); }
// Static Constructor static DataHub() { // Analyze and cache record operations of security hub s_recordOperationsCache = new RecordOperationsCache(typeof(DataHub)); }