/** * 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)); }
public IPublisher LookupPublisher(SifContext context, IElementDef objectType) { ContextMatrix handler = LookupContextMatrix(context); if (handler != null) { return(handler.lookupPublisher(objectType)); } return(null); }
public IQueryResults LookupQueryResults(SifContext context, IElementDef objectType) { ContextMatrix handler = LookupContextMatrix(context); if (handler != null) { return(handler.lookupQueryResults(objectType)); } return(null); }
/// <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); } }
///<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); }
private ContextMatrix LookupContextMatrix(SifContext context) { foreach (ContextMatrix handler in fAllContexts) { if (handler.fContext.Equals(context)) { return(handler); } } return(null); }
///<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); }
public ITopic LookupInstance(IElementDef objectType, SifContext context) { ITopic topic; if (GetTopicMap(context).TryGetValue(objectType, out topic)) { return(topic); } else { return(null); } }
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); }
public override IQueryResults GetQueryResults(SifContext context, IElementDef objectType) { return(fLogger); }
public override ISubscriber GetSubscriber(SifContext context, IElementDef objectType) { return(fLogger); }
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; }
///<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; }
///<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; }
public ITopic LookupInstance(IElementDef objectType, SifContext context) { ITopic topic; if (GetTopicMap(context).TryGetValue(objectType, out topic)) { return topic; } else { return null; } }
public ContextMatrix(SifContext context) { fContext = context; }
internal TopicImpl(IElementDef objType, SifContext context) { fObjType = objType; fContext = context; log = LogManager.GetLogger(Agent.LOG_IDENTIFIER + ".Topic$" + objType.Name); }
/** * 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); }
}//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); }