/// <summary> /// Initializes the cache when the first server is created. /// </summary> public void Initialize() { lock (this) { if (m_disposed) { throw new ObjectDisposedException("Opc.Da.Cache"); } // create the resource manager. m_resourceManager = new ResourceManager("OpcDa.Resources.Strings", Assembly.GetExecutingAssembly()); // initialize status. m_status = new ServerStatus(); m_status.VendorInfo = ((AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute))).Description; m_status.ProductVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); m_status.ServerState = serverState.running; m_status.StatusInfo = serverState.running.ToString(); m_status.StartTime = DateTimeProvider.GetCurrentTime(); m_status.LastUpdateTime = DateTime.MinValue; m_status.CurrentTime = DateTimeProvider.GetCurrentTime(); CommServerComponent _protocolHub = new CommServerComponent(); m_ServerShutdown += c => ToBeDisposedAfterShutdown.GetServerShutdownEventHandler(_protocolHub); _protocolHub.Initialize(CAS.Lib.RTLib.Management.AppConfigManagement.filename); Device _Device = new Device(); m_ServerShutdown += c => ToBeDisposedAfterShutdown.GetServerShutdownEventHandler(_Device); BuildAddressSpace(_Device, ((IDeviceIndexed)_Device).GetIndexedAddressSpace); } }
/// <summary> /// Creates <see cref="ToBeDisposedAfterShutdown"/> and returns the server shutdown event handler to be used to dispose <paramref name="toBeDisposed"/>. /// </summary> /// <param name="toBeDisposed">To be disposed.</param> /// <returns>ServerShutdownEventHandler.</returns> internal static ServerShutdownEventHandler GetServerShutdownEventHandler(IDisposable toBeDisposed) { ToBeDisposedAfterShutdown _this = new ToBeDisposedAfterShutdown((toBeDisposed)); return(_this.ShutdowntEventHandler); }