Exemplo n.º 1
0
        /**
         *  Sends a SIF_Event
         *  @param zone The zone to send the sifEvent to
         */
        public SIF_Ack SifEvent(IZone zone, Event sifEvent, String destinationId, String sifMsgId)
        {
            if (sifEvent.Data == null || sifEvent.Data.Available == false)
            {
                throw new AdkException("The sifEvent has no SIFDataObjects", zone);
            }

            SIF_ObjectData od = new SIF_ObjectData();

            //  Fill out the SIF_ObjectData
            IDataObjectInputStream inStr = sifEvent.Data;
            SifDataObject          data  = inStr.ReadDataObject();

            SifVersion msgVersion = data.EffectiveSIFVersion;

            SIF_EventObject eo = new SIF_EventObject();

            od.SIF_EventObject = eo;
            eo.Action          = sifEvent.ActionString;
            eo.ObjectName      = data.ElementDef.Tag(msgVersion);

            // Create the SIF_Event object
            SIF_Event msg = new SIF_Event(msgVersion);

            msg.SIF_ObjectData = od;

            SIF_Header msgHdr = msg.Header;

            //	Assign SIF_DestinationId if applicable
            if (destinationId != null)
            {
                msgHdr.SIF_DestinationId = destinationId;
            }

            while (data != null)
            {
                eo.Attach(data);
                data = inStr.ReadDataObject();
            }

            if (sifMsgId != null)
            {
                msgHdr.SIF_MsgId = sifMsgId;
            }

            SifContext[] contexts = sifEvent.Contexts;
            if (contexts == null)
            {
                contexts = new SifContext[] { SifContext.DEFAULT };
            }

            SIF_Contexts msgContexts = new SIF_Contexts();

            foreach (SifContext context in contexts)
            {
                msgContexts.AddSIF_Context(context.Name);
            }
            msgHdr.SIF_Contexts = msgContexts;
            return(((ZoneImpl)zone).Dispatcher.send(msg));
        }
Exemplo n.º 2
0
        public IPublisher LookupPublisher(SifContext context, IElementDef objectType)
        {
            ContextMatrix handler = LookupContextMatrix(context);

            if (handler != null)
            {
                return(handler.lookupPublisher(objectType));
            }
            return(null);
        }
Exemplo n.º 3
0
        public IQueryResults LookupQueryResults(SifContext context, IElementDef objectType)
        {
            ContextMatrix handler = LookupContextMatrix(context);

            if (handler != null)
            {
                return(handler.lookupQueryResults(objectType));
            }

            return(null);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Overriden so that any SIF_Response is logged by the logger
 /// </summary>
 /// <param name="context"></param>
 /// <param name="objectType"></param>
 /// <returns></returns>
 public override IQueryResults GetQueryResults(SifContext context, IElementDef objectType)
 {
     if (objectType == InfraDTD.SIF_ZONESTATUS)
     {
         return(this);
     }
     else
     {
         return(fLogger);
     }
 }
Exemplo n.º 5
0
        ///<summary>Looks up the ContextMatrix for the specified SifContext</summary>
        ///<param name="context"
        private ContextMatrix GetOrCreateContextMatrix(SifContext context)
        {
            ContextMatrix handler = LookupContextMatrix(context);

            if (handler == null)
            {
                handler = new ContextMatrix(context);
                fAllContexts.Add(handler);
            }
            return(handler);
        }
Exemplo n.º 6
0
 private ContextMatrix LookupContextMatrix(SifContext context)
 {
     foreach (ContextMatrix handler in fAllContexts)
     {
         if (handler.fContext.Equals(context))
         {
             return(handler);
         }
     }
     return(null);
 }
Exemplo n.º 7
0
        ///<summary>
        /// Gets the map of topics for the specified context
        /// </summary>
        ///<param name="context"></param>
        private Dictionary <IElementDef, ITopic> GetTopicMap(SifContext context)
        {
            Dictionary <IElementDef, ITopic> contextMap;

            if (!fContexts.TryGetValue(context, out contextMap))
            {
                contextMap         = new Dictionary <IElementDef, ITopic>();
                fContexts[context] = contextMap;
            }
            return(contextMap);
        }
Exemplo n.º 8
0
        public ITopic LookupInstance(IElementDef objectType, SifContext context)
        {
            ITopic topic;

            if (GetTopicMap(context).TryGetValue(objectType, out topic))
            {
                return(topic);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        public ITopic GetInstance(IElementDef objectType, SifContext context)
        {
            if (objectType == null)
            {
                throw new ArgumentNullException("The {objectType} parameter cannot be null");
            }

            if (context == null)
            {
                throw new ArgumentNullException("The {context} parameter cannot be null");
            }


            Dictionary <IElementDef, ITopic> map = GetTopicMap(context);
            ITopic topic = null;

            if (!map.TryGetValue(objectType, out topic))
            {
                topic = new TopicImpl(objectType, context);
                map.Add(objectType, topic);
            }

            return(topic);
        }
Exemplo n.º 10
0
 public override IQueryResults GetQueryResults(SifContext context, IElementDef objectType)
 {
     return(fLogger);
 }
Exemplo n.º 11
0
 public override ISubscriber GetSubscriber(SifContext context, IElementDef objectType)
 {
     return(fLogger);
 }
Exemplo n.º 12
0
        public ITopic GetInstance(IElementDef objectType, SifContext context)
        {
            if (objectType == null)
            {

                throw new ArgumentNullException("The {objectType} parameter cannot be null");
            }

            if (context == null)
            {
                throw new ArgumentNullException("The {context} parameter cannot be null");
            }

            Dictionary<IElementDef, ITopic> map = GetTopicMap(context);
            ITopic topic = null;
            if(!map.TryGetValue( objectType, out topic ))
            {
                topic = new TopicImpl(objectType, context);
                map.Add(objectType, topic);
            }

            return topic;
        }
Exemplo n.º 13
0
 ///<summary>Gets all Topic instances in the factory cache for the specified context</summary>
 ///<param name="context"></param>
 public ICollection<ITopic> GetAllTopics(SifContext context)
 {
     return GetTopicMap(context).Values;
 }
Exemplo n.º 14
0
 ///<summary>
 /// Gets the map of topics for the specified context
 /// </summary>
 ///<param name="context"></param>
 private Dictionary<IElementDef, ITopic> GetTopicMap(SifContext context)
 {
     Dictionary<IElementDef, ITopic> contextMap;
     if (!fContexts.TryGetValue(context, out contextMap))
     {
         contextMap = new Dictionary<IElementDef, ITopic>();
         fContexts[context] = contextMap;
     }
     return contextMap;
 }
Exemplo n.º 15
0
 public ITopic LookupInstance(IElementDef objectType, SifContext context)
 {
     ITopic topic;
     if (GetTopicMap(context).TryGetValue(objectType, out topic))
     {
         return topic;
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 16
0
 public ContextMatrix(SifContext context)
 {
     fContext = context;
 }
Exemplo n.º 17
0
 internal TopicImpl(IElementDef objType, SifContext context)
 {
     fObjType = objType;
     fContext = context;
     log = LogManager.GetLogger(Agent.LOG_IDENTIFIER + ".Topic$" + objType.Name);
 }
Exemplo n.º 18
0
 internal TopicImpl(IElementDef objType, SifContext context)
 {
     fObjType = objType;
     fContext = context;
     log      = LogManager.GetLogger(Agent.LOG_IDENTIFIER + ".Topic$" + objType.Name);
 }
Exemplo n.º 19
0
        /**
         *  Sends a SIF_Event
         *  @param zone The zone to send the sifEvent to
         */
        public SIF_Ack SifEvent(IZone zone, Event sifEvent, String destinationId, String sifMsgId)
        {
            if (sifEvent.Data == null || sifEvent.Data.Available == false)
            {
                throw new AdkException("The sifEvent has no SIFDataObjects", zone);
            }

            SIF_ObjectData od = new SIF_ObjectData();

            //  Fill out the SIF_ObjectData
            IDataObjectInputStream inStr = sifEvent.Data;
            SifDataObject data = inStr.ReadDataObject();

            SifVersion msgVersion = data.EffectiveSIFVersion;

            SIF_EventObject eo = new SIF_EventObject();
            od.SIF_EventObject = eo;
            eo.Action = sifEvent.ActionString;
            eo.ObjectName = data.ElementDef.Tag(msgVersion);

            // Create the SIF_Event object
            SIF_Event msg = new SIF_Event(msgVersion);
            msg.SIF_ObjectData = od;

            SIF_Header msgHdr = msg.Header;

            //	Assign SIF_DestinationId if applicable
            if (destinationId != null)
            {
                msgHdr.SIF_DestinationId = destinationId;
            }

            while (data != null)
            {
                eo.Attach(data);
                data = inStr.ReadDataObject();
            }

            if (sifMsgId != null)
            {
                msgHdr.SIF_MsgId = sifMsgId;
            }

            SifContext[] contexts = sifEvent.Contexts;
            if (contexts == null)
            {
                contexts = new SifContext[] { SifContext.DEFAULT };
            }

            SIF_Contexts msgContexts = new SIF_Contexts();
            foreach (SifContext context in contexts)
            {
                msgContexts.AddSIF_Context(context.Name);
            }
            msgHdr.SIF_Contexts = msgContexts;
            return ((ZoneImpl)zone).Dispatcher.send(msg);
        }
Exemplo n.º 20
0
        }//end property AllSupportedContexts


        ///<summary>Gets all Topic instances in the factory cache for the specified context</summary>
        ///<param name="context"></param>
        public ICollection <ITopic> GetAllTopics(SifContext context)
        {
            return(GetTopicMap(context).Values);
        }