Ejemplo n.º 1
0
 private MemoryMappedFile GetWritableFile()
 {
     if (this.mappedFile != null)
     {
         return(this.mappedFile);
     }
     this.mappedFile = AgentSubscription.GetMemoryMappedFile(this.name, true);
     return(this.mappedFile);
 }
Ejemplo n.º 2
0
        public static AgentSubscription Load(string name)
        {
            MemoryMappedFile readOnlyFile = AgentSubscription.GetReadOnlyFile(name);

            if (readOnlyFile == null)
            {
                return(null);
            }
            AgentSubscription result;

            try
            {
                int num  = 24;
                int num2 = 50;
                do
                {
                    Thread.Sleep(10);
                    result = null;
                    using (MapFileStream mapFileStream = readOnlyFile.CreateView(0, num))
                    {
                        byte[] array = new byte[24L];
                        int    num3  = mapFileStream.Read(array, 0, num);
                        if (num3 == num)
                        {
                            AgentSubscription.Header header = new AgentSubscription.Header(array);
                            if (header.Magic == 96101745125713L && header.PayloadSize > 0L && header.PayloadSize <= 1048576L)
                            {
                                using (MapFileStream mapFileStream2 = readOnlyFile.CreateView(0, num + (int)header.PayloadSize))
                                {
                                    mapFileStream2.Seek((long)num, SeekOrigin.Begin);
                                    BinaryFormatter binaryFormatter = new BinaryFormatter();
                                    try
                                    {
                                        result = (AgentSubscription)binaryFormatter.Deserialize(mapFileStream2);
                                    }
                                    catch (SerializationException)
                                    {
                                        goto IL_137;
                                    }
                                }
                                mapFileStream.Seek(0L, SeekOrigin.Begin);
                                num3 = mapFileStream.Read(array, 0, num);
                                if (num3 == num)
                                {
                                    AgentSubscription.Header header2 = new AgentSubscription.Header(array);
                                    if (header.Magic == header2.Magic && header.PayloadSize == header2.PayloadSize && header.Ticks == header2.Ticks)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    IL_137 :;
                }while (num2-- > 0);
            }
            finally
            {
                readOnlyFile.Close();
            }
            return(result);
        }
Ejemplo n.º 3
0
 private static MemoryMappedFile GetReadOnlyFile(string name)
 {
     return(AgentSubscription.GetMemoryMappedFile(name, false));
 }