コード例 #1
0
ファイル: Persister.cs プロジェクト: epowers/pubsub
            private void WriteCharArray(StreamWriter eventStream, WspBuffer serializedEvent, PersistEventInfo eventInfo)
            {
                char[] charArray;
                bool   first = true;

                if (serializedEvent.Read(out charArray) == false)
                {
                    throw new EventDeserializationException("Error reading List length from buffer");
                }

                eventStream.Write(eventInfo.BeginArraySeparator);

                for (int i = 0; i < charArray.Length; i++)
                {
                    if (first == true)
                    {
                        first = false;
                    }
                    else
                    {
                        eventStream.Write(eventInfo.FieldTerminator);
                    }

                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                    eventStream.Write(CleanseString(charArray[i].ToString(), eventInfo));
                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                }

                eventStream.Write(eventInfo.EndArraySeparator);
            }
コード例 #2
0
ファイル: Program.cs プロジェクト: epowers/pubsub
 public override void GetObjectData(WspBuffer buffer)
 {
     buffer.AddElement("BooleanProp", BooleanProp);
     buffer.AddElement("ByteProp", ByteProp);
     buffer.AddElement("ByteArrayProp", ByteArrayProp);
     buffer.AddElement("CharProp", CharProp);
     buffer.AddElement("CharArrayProp", CharArrayProp);
     buffer.AddElement("StringListProp", StringListProp);
     buffer.AddElement("ObjectListProp", ObjectListProp);
     buffer.AddElement("DecimalProp", DecimalProp);
     buffer.AddElement("DoubleProp", DoubleProp);
     buffer.AddElement("Int16Prop", Int16Prop);
     buffer.AddElement("Int32Prop", Int32Prop);
     buffer.AddElement("Int64Prop", Int64Prop);
     buffer.AddElement("SByteProp", SByteProp);
     buffer.AddElement("SingleProp", SingleProp);
     buffer.AddElement("StringProp", StringProp);
     buffer.AddElement("StringDictionaryProp", StringDictionaryProp);
     buffer.AddElement("UInt16Prop", UInt16Prop);
     buffer.AddElement("UInt32Prop", UInt32Prop);
     buffer.AddElement("UInt64Prop", UInt64Prop);
     buffer.AddElement("ObjectDictionaryProp", ObjectDictionaryProp);
     buffer.AddElement("VersionProp", VersionProp);
     buffer.AddElement("DateTimeProp", DateTimeProp);
     buffer.AddElement("GuidProp", GuidProp);
     buffer.AddElement("UriProp", UriProp);
     buffer.AddElement("IPAddressProp", IPAddressProp);
 }
コード例 #3
0
ファイル: Command.cs プロジェクト: epowers/pubsub
 /// <summary>
 /// Used for event serialization.
 /// </summary>
 /// <param name="buffer">SerializationData object passed to store serialized object</param>
 public override void GetObjectData(WspBuffer buffer)
 {
     buffer.AddElement(@"EventIdForResponse", EventIdForResponse);
     buffer.AddElement(@"CorrelationID", CorrelationID);
     buffer.AddElement(@"TargetMachineFilter", TargetMachineFilter);
     buffer.AddElement(@"TargetRoleFilter", TargetRoleFilter);
     buffer.AddElement(@"Command", Command);
     buffer.AddElement(@"Arguments", Arguments);
     buffer.AddElement(@"TimeToLive", TimeToLive);
 }
コード例 #4
0
        /// <summary>
        /// Used for event serialization.
        /// </summary>
        /// <param name="buffer">SerializationData object passed to store serialized object</param>
        public override void GetObjectData(WspBuffer buffer)
        {
            buffer.AddElement(@"ActiveXControls", activeXControls);
            buffer.AddElement(@"AnonymousId", anonymousId);
            buffer.AddElement(@"Aol", aol);
            buffer.AddElement(@"BackgroundSounds", backgroundSounds);
            buffer.AddElement(@"Beta", beta);
            buffer.AddElement(@"Browser", browser);
            buffer.AddElement(@"Cdf", cdf);
            buffer.AddElement(@"ClrVersion", clrVersion);
            buffer.AddElement(@"Cookies", cookies);
            buffer.AddElement(@"Crawler", crawler);
            buffer.AddElement(@"EcmaScriptVersion", ecmaScriptVersion);
            buffer.AddElement(@"Ext", ext);
            buffer.AddElement(@"Frames", frames);
            buffer.AddElement(@"HostDomain", hostDomain);
            buffer.AddElement(@"JavaApplets", javaApplets);
            buffer.AddElement(@"LogicalUri", logicalUri);
            buffer.AddElement(@"MajorVersion", majorVersion);
            buffer.AddElement(@"MinorVersion", minorVersion);
            buffer.AddElement(@"MSDomVersion", mSDomVersion);
            buffer.AddElement(@"Platform", platform);
            buffer.AddElement(@"RequestType", requestType);
            buffer.AddElement(@"Source", source);
            buffer.AddElement(@"SourceServer", sourceServer);
            buffer.AddElement(@"StatusCode", statusCode);
            buffer.AddElement(@"SubDirectory", subDirectory);
            buffer.AddElement(@"Tables", tables);
            buffer.AddElement(@"Type", type);

            if (uriHash != null && uriHash.InputBlockSize > 1)
            {
                buffer.AddElement(@"UriHash", uriHash.Hash);
            }
            else
            {
                buffer.AddElement(@"UriHash", new byte[] { });
            }

            buffer.AddElement(@"UriQuery", uriQuery);
            buffer.AddElement(@"UriStem", uriStem);
            buffer.AddElement(@"UrlReferrer", urlReferrer);
            buffer.AddElement(@"UrlReferrerDomain", urlReferrerDomain);
            buffer.AddElement(@"UserAgent", userAgent);
            buffer.AddElement(@"UserHostAddress", userHostAddress);
            buffer.AddElement(@"VBScript", vBScript);
            buffer.AddElement(@"Version", version);
            buffer.AddElement(@"VirtualRoot", virtualRoot);
            buffer.AddElement(@"W3CDomVersion", w3CDomVersion);
            buffer.AddElement(@"Win16", win16);
            buffer.AddElement(@"Win32", win32);
        }
コード例 #5
0
        public void ToBytes(WspBuffer buffer)
        {
            buffer.Add(count);

            buffer.Add(isPresent);

            if (isPresent == 0x01)
            {
                buffer.AlignWrite(4);

                Restriction.ToBytes(buffer);
            }
        }
コード例 #6
0
ファイル: Persister.cs プロジェクト: epowers/pubsub
            private void WriteDateTime(StreamWriter eventStream, WspBuffer serializedEvent, PersistEventInfo eventInfo)
            {
                DateTime dateTime;

                if (serializedEvent.Read(out dateTime) == false)
                {
                    throw new EventDeserializationException("Error reading List length from buffer");
                }

                eventStream.Write(eventInfo.StringDelimiter.ToString());
                eventStream.Write(CleanseString(dateTime.ToString("o"), eventInfo));
                eventStream.Write(eventInfo.StringDelimiter.ToString());
            }
コード例 #7
0
        /// <summary>
        /// Serializes the event and puts it in the SerializedEvent property
        /// </summary>
        /// <returns>Serialized version of the event</returns>
        public byte[] Serialize()
        {
            if (serializedBody == null)
            {
                serializedBody = new WspBuffer();
            }

            serializedBody.Reset();

            GetObjectData(serializedBody);

            return(serializedBody.ToByteArray());
        }
コード例 #8
0
ファイル: Persister.cs プロジェクト: epowers/pubsub
            private void WriteStringDictionary(StreamWriter eventStream, WspBuffer serializedEvent, PersistEventInfo eventInfo)
            {
                int    dictCount;
                string stringKey;
                string stringValue;
                bool   first = true;

                if (serializedEvent.Read(out dictCount) == false)
                {
                    throw new EventDeserializationException("Error reading StringDictionary length from buffer");
                }

                eventStream.Write(eventInfo.BeginObjectSeparator);

                for (int i = 0; i < dictCount; i++)
                {
                    if (first == true)
                    {
                        first = false;
                    }
                    else
                    {
                        eventStream.Write(eventInfo.FieldTerminator);
                    }

                    if (serializedEvent.Read(out stringKey) == false)
                    {
                        throw new EventDeserializationException("Error reading StringDictionary key from buffer");
                    }

                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                    eventStream.Write(CleanseString(stringKey, eventInfo));
                    eventStream.Write(eventInfo.StringDelimiter.ToString());

                    eventStream.Write(eventInfo.KeyValueSeparator);

                    if (serializedEvent.Read(out stringValue) == false)
                    {
                        throw new EventDeserializationException("Error reading StringDictionary value from buffer");
                    }

                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                    eventStream.Write(CleanseString(stringValue, eventInfo));
                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                }

                eventStream.Write(eventInfo.EndObjectSeparator);
            }
コード例 #9
0
        public void ToBytes(WspBuffer buffer)
        {
            buffer.Add(_cBookmarks);

            foreach (var bookmark in _aBookmarks)
            {
                buffer.Add(bookmark);
            }

            buffer.Add(_maxRet);

            foreach (var ret in _ascRet)
            {
                buffer.Add(ret);
            }
        }
コード例 #10
0
        public void FromBytes(WspBuffer buffer)
        {
            _cBookmarks = buffer.ToStruct <uint>();
            _aBookmarks = new uint[_cBookmarks];
            for (int i = 0; i < _cBookmarks; i++)
            {
                _aBookmarks[i] = buffer.ToStruct <uint>();
            }

            _maxRet = buffer.ToStruct <uint>();
            _ascRet = new uint[_maxRet];
            for (int i = 0; i < _maxRet; i++)
            {
                _ascRet[i] = buffer.ToStruct <uint>();
            }
        }
コード例 #11
0
ファイル: Command.cs プロジェクト: epowers/pubsub
        /// <summary>
        /// Used for event serialization.
        /// </summary>
        /// <param name="buffer">SerializationData object passed to store serialized object</param>
        public override void GetObjectData(WspBuffer buffer)
        {
            buffer.AddElement(@"CorrelationID", CorrelationID);
            buffer.AddElement(@"Results", Results);
            buffer.AddElement(@"ReturnCode", ReturnCode);
            buffer.AddElement(@"Message", Message);

            if (ResponseException != null)
            {
                byte[] responseExceptionSerialized = SerializeException(ResponseException);

                if (responseExceptionSerialized != null)
                {
                    buffer.AddElement(@"ResponseExceptionSerialized", responseExceptionSerialized);
                }
            }
        }
コード例 #12
0
ファイル: PersistFileEvent.cs プロジェクト: epowers/pubsub
 /// <summary>
 /// Used for event serialization.
 /// </summary>
 /// <param name="buffer">SerializationData object passed to store serialized object</param>
 public override void GetObjectData(WspBuffer buffer)
 {
     buffer.AddElement(@"FileState", (byte)fileState);
     buffer.AddElement(@"FileNameBase", fileNameBase);
     buffer.AddElement(@"FileName", fileName);
     buffer.AddElement(@"PersistEventType", persistEventType);
     buffer.AddElement(@"FileSize", fileSize);
     buffer.AddElement(@"SettingMaxFileSize", settingMaxFileSize);
     buffer.AddElement(@"SettingMaxCopyInterval", settingMaxCopyInterval);
     buffer.AddElement(@"SettingLocalOnly", settingLocalOnly);
     buffer.AddElement(@"SettingFieldTerminator", settingFieldTerminator);
     buffer.AddElement(@"SettingRowTerminator", settingRowTerminator);
     buffer.AddElement(@"SettingBeginObjectSeparator", settingBeginArraySeparator);
     buffer.AddElement(@"SettingEndObjectSeparator", settingEndArraySeparator);
     buffer.AddElement(@"SettingKeyValueSeparator", settingKeyValueSeparator);
     buffer.AddElement(@"SettingEscapeCharacter", settingEscapeCharacter);
 }
コード例 #13
0
        /// <summary>
        /// Method called when serializing the object
        /// </summary>
        /// <param name="buffer"></param>
        public override void GetObjectData(WspBuffer buffer)
        {
            if (MethodBody == null)
            {
                MethodBody = string.Empty;
            }

            if (UsingLibraries == null)
            {
                UsingLibraries = new List <string>();
            }

            if (ReferencedAssemblies == null)
            {
                ReferencedAssemblies = new List <string>();
            }

            buffer.AddElement(@"1", SubscriptionEventType);
            buffer.AddElement(@"2", MethodBody);
            buffer.AddElement(@"3", UsingLibraries);
            buffer.AddElement(@"4", ReferencedAssemblies);
            buffer.AddElement(@"5", Subscribe);
            buffer.AddElement(@"6", LocalOnly);
        }
コード例 #14
0
ファイル: Persister.cs プロジェクト: epowers/pubsub
            private void WriteStringList(StreamWriter eventStream, WspBuffer serializedEvent, PersistEventInfo eventInfo)
            {
                int    listCount;
                string stringValue;
                bool   first = true;

                if (serializedEvent.Read(out listCount) == false)
                {
                    throw new EventDeserializationException("Error reading List length from buffer");
                }

                eventStream.Write(eventInfo.BeginArraySeparator);

                for (int i = 0; i < listCount; i++)
                {
                    if (first == true)
                    {
                        first = false;
                    }
                    else
                    {
                        eventStream.Write(eventInfo.FieldTerminator);
                    }

                    if (serializedEvent.Read(out stringValue) == false)
                    {
                        throw new EventDeserializationException("Error reading List value from buffer");
                    }

                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                    eventStream.Write(CleanseString(stringValue, eventInfo));
                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                }

                eventStream.Write(eventInfo.EndArraySeparator);
            }
コード例 #15
0
 /// <summary>
 /// Used for event serialization.
 /// </summary>
 /// <param name="buffer">SerializationData object passed to store serialized object</param>
 public override void GetObjectData(WspBuffer buffer)
 {
     buffer.AddElement(@"EventNum", EventNum);
     buffer.AddElement(@"InstanceId", InstanceId);
 }
コード例 #16
0
ファイル: Persister.cs プロジェクト: epowers/pubsub
            public override void Start()
            {
                bool             elementRetrieved;
                WspBuffer        serializedEvent;
                long             currentTick;
                long             configFileTick;
                long             localConfigFileTick;
                PersistEventInfo eventInfo;
                string           eventFieldTerminator = @",";
                StreamWriter     eventStream;

                PubSubManager.ReturnCode rc;

                string propName;
                byte   propType;
                object propValue;

                try
                {
                    Manager.ThreadInitialize.Release();
                }
                catch
                {
                    // If the thread is restarted, this could throw an exception but just ignore
                }

                try
                {
                    eventPush = new WspEventPublish();

                    while (true)
                    {
                        currentTick = DateTime.UtcNow.Ticks;

                        if (currentTick > nextConfigFileCheckTick)
                        {
                            nextConfigFileCheckTick = currentTick + 300000000;

                            configFileTick      = Configurator.GetConfigFileTick();
                            localConfigFileTick = Configurator.GetLocalConfigFileTick();

                            if (configFileTick != lastConfigFileTick || localConfigFileTick != lastLocalConfigFileTick)
                            {
                                nextCopyTick = 0;

                                foreach (PersistEventInfo eInfo in persistEvents.Values)
                                {
                                    eInfo.Loaded = false;
                                }

                                lock (configFileLock)
                                {
                                    Configurator.LoadLogSettings();
                                    Configurator.LoadLocalLogSettings();
                                }

                                foreach (PersistEventInfo eInfo in persistEvents.Values)
                                {
                                    if (eInfo.Loaded == false)
                                    {
                                        eInfo.InUse        = false;
                                        eInfo.NextCopyTick = currentTick - 1;

                                        eInfo.subscription.Subscribe = false;

                                        WspEvent wspEvent = new WspEvent(Subscription.SubscriptionEvent, null, eInfo.subscription.Serialize());
                                        eventPush.OnNext(wspEvent, out rc);
                                    }
                                }

                                lastConfigFileTick      = configFileTick;
                                lastLocalConfigFileTick = localConfigFileTick;
                            }

                            foreach (PersistEventInfo eInfo in persistEvents.Values)
                            {
                                if (eInfo.InUse == true)
                                {
                                    eInfo.subscription.Subscribe = true;

                                    WspEvent wspEvent = new WspEvent(Subscription.SubscriptionEvent, null, eInfo.subscription.Serialize());
                                    eventPush.OnNext(wspEvent, out rc);
                                }
                            }
                        }

                        try
                        {
                            element = persisterQueue.Dequeue();

                            if (element == default(QueueElement))
                            {
                                elementRetrieved = false;
                            }
                            else
                            {
                                elementRetrieved = true;
                            }
                        }
                        catch (InvalidOperationException)
                        {
                            elementRetrieved = false;
                        }

                        currentTick = DateTime.UtcNow.Ticks;

                        if (currentTick > nextCopyTick)
                        {
                            nextCopyTick = long.MaxValue;

                            foreach (PersistEventInfo persistEventInfo in persistEvents.Values)
                            {
                                if (currentTick > persistEventInfo.NextCopyTick)
                                {
                                    persistEventInfo.NextCopyTick = currentTick + persistEventInfo.CopyIntervalTicks;

                                    if (persistEventInfo.OutStream != null)
                                    {
                                        persistEventInfo.OutStream.Close();

                                        SendPersistEvent(PersistFileState.Close, persistEventInfo, persistEventInfo.OutFileName);

                                        persistEventInfo.OutStream = null;
                                    }

                                    if (persistEventInfo.InUse == true)
                                    {
                                        persistEventInfo.OutFileName = persistEventInfo.TempFileDirectory + fileNameBase + DateTime.UtcNow.ToString("u").Replace(":", "-") + fileNameSuffix;

                                        if (File.Exists(persistEventInfo.OutFileName) == true)
                                        {
                                            persistEventInfo.OutStream = new StreamWriter(File.Open(persistEventInfo.OutFileName, FileMode.Append, FileAccess.Write, FileShare.None), Encoding.Unicode);
                                        }
                                        else
                                        {
                                            persistEventInfo.OutStream = new StreamWriter(File.Open(persistEventInfo.OutFileName, FileMode.Create, FileAccess.Write, FileShare.None), Encoding.Unicode);
                                        }

                                        SendPersistEvent(PersistFileState.Open, persistEventInfo, persistEventInfo.OutFileName);
                                    }
                                }

                                if (persistEventInfo.NextCopyTick < nextCopyTick)
                                {
                                    nextCopyTick = persistEventInfo.NextCopyTick;
                                }
                            }

                            if (copyInProcess == false)
                            {
                                Thread copyThread = new Thread(new ThreadStart(CopyFile));

                                copyInProcess = true;

                                copyThread.Start();
                            }
                        }

                        if (elementRetrieved == true)
                        {
                            eventInfo = persistEvents[element.WspEvent.EventType];

                            if (eventInfo.InUse == true)
                            {
                                eventFieldTerminator = eventInfo.FieldTerminator.ToString();

                                eventStream = eventInfo.OutStream;

                                if (eventStream == null)
                                {
                                    eventInfo.NextCopyTick = DateTime.UtcNow.Ticks + eventInfo.CopyIntervalTicks;

                                    eventInfo.OutFileName = eventInfo.TempFileDirectory + fileNameBase + DateTime.UtcNow.ToString("u").Replace(":", "-") + fileNameSuffix;

                                    if (File.Exists(eventInfo.OutFileName) == true)
                                    {
                                        eventInfo.OutStream = new StreamWriter(File.Open(eventInfo.OutFileName, FileMode.Append, FileAccess.Write, FileShare.None), Encoding.Unicode);
                                    }
                                    else
                                    {
                                        eventInfo.OutStream = new StreamWriter(File.Open(eventInfo.OutFileName, FileMode.Create, FileAccess.Write, FileShare.None), Encoding.Unicode);
                                    }

                                    eventStream = eventInfo.OutStream;

                                    if (eventInfo.NextCopyTick < nextCopyTick)
                                    {
                                        nextCopyTick = eventInfo.NextCopyTick;
                                    }

                                    SendPersistEvent(PersistFileState.Open, eventInfo, eventInfo.OutFileName);
                                }

                                eventStream.Write(eventInfo.BeginObjectSeparator);

                                eventStream.Write(eventInfo.StringDelimiter.ToString());
                                eventStream.Write("OriginatingRouterName");
                                eventStream.Write(eventInfo.StringDelimiter.ToString());
                                eventStream.Write(eventInfo.KeyValueSeparator.ToString());
                                eventStream.Write(eventInfo.StringDelimiter.ToString());
                                eventStream.Write(CleanseString(element.WspEvent.OriginatingRouterName, eventInfo));
                                eventStream.Write(eventInfo.StringDelimiter.ToString());
                                eventStream.Write(eventInfo.FieldTerminator.ToString());

                                eventStream.Write(eventInfo.StringDelimiter.ToString());
                                eventStream.Write("InRouterName");
                                eventStream.Write(eventInfo.StringDelimiter.ToString());
                                eventStream.Write(eventInfo.KeyValueSeparator.ToString());
                                eventStream.Write(eventInfo.StringDelimiter.ToString());
                                eventStream.Write(CleanseString(element.WspEvent.InRouterName, eventInfo));
                                eventStream.Write(eventInfo.StringDelimiter.ToString());

                                serializedEvent = new WspBuffer(element.WspEvent.Body);

                                while (serializedEvent.Position < serializedEvent.Size)
                                {
                                    if (serializedEvent.Read(out propName) == false)
                                    {
                                        throw new EventDeserializationException("Error reading PropertyName from buffer");
                                    }

                                    eventStream.Write(eventInfo.FieldTerminator.ToString());
                                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                                    eventStream.Write(CleanseString(propName, eventInfo));
                                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                                    eventStream.Write(eventInfo.KeyValueSeparator.ToString());

                                    if (serializedEvent.Read(out propType) == false)
                                    {
                                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                                    }

                                    switch (propType)
                                    {
                                    case (byte)PropertyType.StringDictionary:

                                        WriteStringDictionary(eventStream, serializedEvent, eventInfo);
                                        break;

                                    case (byte)PropertyType.ObjectDictionary:

                                        WriteObjectDictionary(eventStream, serializedEvent, eventInfo);
                                        break;

                                    case (byte)PropertyType.StringList:
                                        WriteStringList(eventStream, serializedEvent, eventInfo);
                                        break;

                                    case (byte)PropertyType.ObjectList:
                                        WriteObjectList(eventStream, serializedEvent, eventInfo);
                                        break;

                                    case (byte)PropertyType.ByteArray:
                                        WriteByteArray(eventStream, serializedEvent, eventInfo);
                                        break;

                                    case (byte)PropertyType.CharArray:
                                        WriteCharArray(eventStream, serializedEvent, eventInfo);
                                        break;

                                    case (byte)PropertyType.DateTime:
                                        WriteDateTime(eventStream, serializedEvent, eventInfo);
                                        break;

                                    case (byte)PropertyType.Int64:
                                        if (string.Compare(propName, "EventTime", true) == 0)
                                        {
                                            WriteDateTime(eventStream, serializedEvent, eventInfo);
                                        }
                                        else
                                        {
                                            if (serializedEvent.Read((PropertyType)propType, out propValue) == false)
                                            {
                                                throw new EventDeserializationException("Error reading PropertyValue from buffer");
                                            }

                                            eventStream.Write(eventInfo.StringDelimiter.ToString());
                                            eventStream.Write(CleanseString(propValue.ToString(), eventInfo));
                                            eventStream.Write(eventInfo.StringDelimiter.ToString());
                                        }
                                        break;

                                    default:
                                        if (serializedEvent.Read((PropertyType)propType, out propValue) == false)
                                        {
                                            throw new EventDeserializationException("Error reading PropertyValue from buffer");
                                        }

                                        eventStream.Write(eventInfo.StringDelimiter.ToString());
                                        eventStream.Write(CleanseString(propValue.ToString(), eventInfo));
                                        eventStream.Write(eventInfo.StringDelimiter.ToString());
                                        break;
                                    }
                                }

                                eventStream.Write(eventInfo.EndObjectSeparator);

                                eventStream.Write(eventInfo.RowTerminator);

                                if (eventStream.BaseStream.Length >= eventInfo.MaxFileSize)
                                {
                                    eventInfo.NextCopyTick = currentTick - 1;
                                    nextCopyTick           = eventInfo.NextCopyTick;
                                }
                            }
                        }
                    }
                }

                catch (IOException e)
                {
                    EventLog.WriteEntry("WspEventRouter", e.ToString(), EventLogEntryType.Error);
                    Thread.Sleep(60000);
                }

                catch (ThreadAbortException)
                {
                    // Another thread has signalled that this worker
                    // thread must terminate.  Typically, this occurs when
                    // the main service thread receives a service stop
                    // command.
                }

                catch (Exception e)
                {
                    EventLog.WriteEntry("WspEventRouter", e.ToString(), EventLogEntryType.Error);
                    throw e;
                }
            }
コード例 #17
0
 public void FromBytes(WspBuffer buffer)
 {
     _ulNumerator   = buffer.ToStruct <uint>();
     _ulDenominator = buffer.ToStruct <uint>();
     _hRegion       = buffer.ToStruct <uint>();
 }
コード例 #18
0
 public void ToBytes(WspBuffer buffer)
 {
     _vDocument.ToBytes(buffer);
 }
コード例 #19
0
 public void FromBytes(WspBuffer buffer)
 {
     _cskip = buffer.ToStruct <uint>();
 }
コード例 #20
0
ファイル: Persister.cs プロジェクト: epowers/pubsub
            private void WriteObjectList(StreamWriter eventStream, WspBuffer serializedEvent, PersistEventInfo eventInfo)
            {
                int    listCount;
                byte   propType;
                object propValue;
                bool   first = true;

                if (serializedEvent.Read(out listCount) == false)
                {
                    throw new EventDeserializationException("Error reading List length from buffer");
                }

                eventStream.Write(eventInfo.BeginArraySeparator);

                for (int i = 0; i < listCount; i++)
                {
                    if (first == true)
                    {
                        first = false;
                    }
                    else
                    {
                        eventStream.Write(eventInfo.FieldTerminator);
                    }

                    if (serializedEvent.Read(out propType) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    if ((PropertyType)propType == PropertyType.StringDictionary)
                    {
                        WriteStringDictionary(eventStream, serializedEvent, eventInfo);
                    }
                    else
                    {
                        if ((PropertyType)propType == PropertyType.ObjectDictionary)
                        {
                            WriteObjectDictionary(eventStream, serializedEvent, eventInfo);
                        }
                        else
                        {
                            if ((PropertyType)propType == PropertyType.StringList)
                            {
                                WriteStringList(eventStream, serializedEvent, eventInfo);
                            }
                            else
                            {
                                if ((PropertyType)propType == PropertyType.ObjectList)
                                {
                                    WriteObjectList(eventStream, serializedEvent, eventInfo);
                                }
                                else
                                {
                                    if (serializedEvent.Read((PropertyType)propType, out propValue) == false)
                                    {
                                        throw new EventDeserializationException("Error reading PropertyValue from buffer");
                                    }

                                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                                    eventStream.Write(CleanseString(propValue.ToString(), eventInfo));
                                    eventStream.Write(eventInfo.StringDelimiter.ToString());
                                }
                            }
                        }
                    }
                }

                eventStream.Write(eventInfo.EndArraySeparator);
            }
コード例 #21
0
 public void FromBytes(WspBuffer buffer)
 {
     throw new System.NotImplementedException();
 }
コード例 #22
0
 public void FromBytes(WspBuffer buffer)
 {
     this = buffer.ToStruct <WspMessageHeader>();
 }
コード例 #23
0
 /// <summary>
 /// Used for event serialization.
 /// </summary>
 /// <param name="buffer">SerializationData object passed to store serialized object</param>
 abstract public void GetObjectData(WspBuffer buffer);
コード例 #24
0
        /// <summary>
        /// Deserializes the event
        /// </summary>
        public virtual void Deserialize(byte[] serializationData)
        {
            string propName;
            byte   propType;

            string stringValue = string.Empty;
            byte   byteValue   = 0;
            SByte  sbyteValue  = 0;

            byte[] byteArrayValue = null;
            char   charValue      = Char.MinValue;

            char[]    charArrayValue = null;
            bool      boolValue      = false;
            Int16     int16Value     = 0;
            Int32     int32Value     = 0;
            Int64     int64Value     = 0;
            UInt16    uint16Value    = 0;
            UInt32    uint32Value    = 0;
            UInt64    uint64Value    = 0;
            Single    singleValue    = 0;
            Double    doubleValue    = 0;
            Decimal   decimalValue   = 0;
            Version   versionValue   = null;
            DateTime  dateTimeValue  = DateTime.MinValue;
            Guid      guidValue      = Guid.Empty;
            IPAddress ipAddressValue = null;
            Uri       uriValue       = null;
            Dictionary <string, string> stringDictionaryValue = null;
            Dictionary <string, object> objectDictionaryValue = null;
            List <string> stringListValue = null;
            List <object> objectListValue = null;

            serializedBody = new WspBuffer(serializationData);

            while (serializedBody.Position < serializedBody.Size)
            {
                if (serializedBody.Read(out propName) == false)
                {
                    throw new EventDeserializationException("Error reading PropertyName from buffer");
                }

                if (serializedBody.Read(out propType) == false)
                {
                    throw new EventDeserializationException("Error reading PropertyType from buffer");
                }

                switch (propType)
                {
                case (byte)PropertyType.String:
                    if (serializedBody.Read(out stringValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, stringValue);

                    continue;

                case (byte)PropertyType.Boolean:
                    if (serializedBody.Read(out boolValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, boolValue);

                    continue;

                case (byte)PropertyType.Int32:
                    if (serializedBody.Read(out int32Value) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, int32Value);

                    continue;

                case (byte)PropertyType.Int64:
                    if (serializedBody.Read(out int64Value) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, int64Value);

                    continue;

                case (byte)PropertyType.SByte:
                    if (serializedBody.Read(out sbyteValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, sbyteValue);

                    continue;

                case (byte)PropertyType.Double:
                    if (serializedBody.Read(out doubleValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, doubleValue);

                    continue;

                case (byte)PropertyType.Decimal:
                    if (serializedBody.Read(out decimalValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, decimalValue);

                    continue;

                case (byte)PropertyType.Byte:
                    if (serializedBody.Read(out byteValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, byteValue);

                    continue;

                case (byte)PropertyType.Char:
                    if (serializedBody.Read(out charValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, charValue);

                    continue;

                case (byte)PropertyType.Version:
                    if (serializedBody.Read(out versionValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, versionValue);

                    continue;

                case (byte)PropertyType.DateTime:
                    if (serializedBody.Read(out dateTimeValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, dateTimeValue);

                    continue;

                case (byte)PropertyType.Guid:
                    if (serializedBody.Read(out guidValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, guidValue);

                    continue;

                case (byte)PropertyType.Uri:
                    if (serializedBody.Read(out uriValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, uriValue);

                    continue;

                case (byte)PropertyType.Int16:
                    if (serializedBody.Read(out int16Value) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, int16Value);

                    continue;

                case (byte)PropertyType.Single:
                    if (serializedBody.Read(out singleValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, singleValue);

                    continue;

                case (byte)PropertyType.UInt16:
                    if (serializedBody.Read(out uint16Value) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, uint16Value);

                    continue;

                case (byte)PropertyType.UInt32:
                    if (serializedBody.Read(out uint32Value) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, uint32Value);

                    continue;

                case (byte)PropertyType.UInt64:
                    if (serializedBody.Read(out uint64Value) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, uint64Value);

                    continue;

                case (byte)PropertyType.IPAddress:
                    if (serializedBody.Read(out ipAddressValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, ipAddressValue);

                    continue;

                case (byte)PropertyType.ByteArray:
                    if (serializedBody.Read(out byteArrayValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, byteArrayValue);

                    continue;

                case (byte)PropertyType.CharArray:
                    if (serializedBody.Read(out charArrayValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, charArrayValue);

                    continue;

                case (byte)PropertyType.StringDictionary:
                    if (serializedBody.Read(out stringDictionaryValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, stringDictionaryValue);

                    continue;

                case (byte)PropertyType.ObjectDictionary:
                    if (serializedBody.Read(out objectDictionaryValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, objectDictionaryValue);

                    continue;

                case (byte)PropertyType.StringList:
                    if (serializedBody.Read(out stringListValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, stringListValue);

                    continue;

                case (byte)PropertyType.ObjectList:
                    if (serializedBody.Read(out objectListValue) == false)
                    {
                        throw new EventDeserializationException("Error reading PropertyType from buffer");
                    }

                    SetElement(propName, objectListValue);

                    continue;

                default:
                    throw new EventTypeNotSupportedException("Cannot deserialize type of Value object");
                }
            }
        }
コード例 #25
0
 public void ToBytes(WspBuffer buffer)
 {
     buffer.Add(this);
 }
コード例 #26
0
 public void FromBytes(WspBuffer buffer)
 {
     _bmkOffset = buffer.ToStruct <uint>();
     _cskip     = buffer.ToStruct <uint>();
     _hRegion   = buffer.ToStruct <uint>();
 }