Пример #1
0
        // Disable Presharp warning about Dispose() not being called on the disposable FileMapping object.
        // This is by design, because lifetime of m extends this function - the pointer is passed to ElementCacher ctor.
#pragma warning disable 6518

        private static ElementCacher OpenServerCache(string serverSectionName)
        {
            // Disable Presharp warning about empty catch body.
            // This is by design, as we should continue even in case of server connection failures.
#pragma warning disable 6502
            try
            {
                // open cache
                FileMapping m = new FileMapping();
                m.OpenSection(serverSectionName);
                ElementCacher c = new ElementCacher(m, false, true);

                if (c.VersionUpToDate())
                {
                    _serverCache = c;
                    return(c);
                }
            }
            // This can be thrown when for some reason we cannot connect to the server.
            catch (IOException)
            {
            }
            return(null);

#pragma warning restore 6502
        }