Exemplo n.º 1
0
        /// <summary>
        /// Returns null if we get an event we're not interested in, or an unparseable event (e.g. for an object type we don't know about).
        /// </summary>
        /// <param name="proxyEvent"></param>
        /// <returns></returns>
        private static ObjectChange ProcessEvent(Proxy_Event proxyEvent)
        {
            switch (proxyEvent.class_.ToLowerInvariant())
            {
            case "session":
            case "event":
            case "vtpm":
            case "user":
            case "secret":
                // We don't track events on these objects
                return(null);

            default:
                Type typ = Marshalling.GetXenAPIType(proxyEvent.class_);

                if (typ == null)
                {
                    log.DebugFormat("Unknown {0} event for class {1}.", proxyEvent.operation, proxyEvent.class_);
                    return(null);
                }

                switch (proxyEvent.operation)
                {
                case "add":
                case "mod":
                    return(new ObjectChange(typ, proxyEvent.opaqueRef, Marshalling.convertStruct(typ, (Hashtable)proxyEvent.snapshot)));

                case "del":
                    return(new ObjectChange(typ, proxyEvent.opaqueRef, null));

                default:
                    log.DebugFormat("Unknown event operation {0} for opaque ref {1}", proxyEvent.operation, proxyEvent.opaqueRef);
                    return(null);
                }
            }
        }