public static IEventPublisher GetEventPublisher(AbstractConfiguration cfg, bool mustExists) { IEventPublisher eventPublisher = cfg.Get<IEventPublisher>(EventPublisher_SettingsKey); if (eventPublisher == null && mustExists) throw new InvalidOperationException("Missing event publisher for event store."); return eventPublisher; }
public static IObjectContainer GetObjectContainer(AbstractConfiguration cfg) { IObjectContainer container = cfg.Get<IObjectContainer>(ObjectContainer_SettingsKey); if (container == null) throw new InvalidOperationException(string.Format("No object container has been configured for dependency injection.")); return container; }
public static EventStoreDB GetEventStoreDB(AbstractConfiguration cfg) { EventStoreDB eStore = cfg.Get<EventStoreDB>(EventStoreDB_SettingsKey); if (eStore == null) throw new InvalidOperationException("Missing event store. Are you missing a call to Done() in the event store configuration code?"); return eStore; }
private void choseNewConfigurationName() { GUILayout.BeginHorizontal(); GUILayout.Label("Choose a name for the new configuration.", EditorStyles.boldLabel); chosenName = GUILayout.TextField(chosenName); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (!configurator.generalUsedNames().Contains(chosenName)) { if (GUILayout.Button("Ok")) { //configuration = configurator.newConfiguration(chosenName,chosenGO); configuration = null; chosingNewConfigurationName = false; configuringConfiguration = true; tracker.updateDataStructures(chosenGO, null); tracker.configurationName = chosenName; } } else { GUI.enabled = false; GUILayout.Button("Name already used."); GUI.enabled = true; } if (GUILayout.Button("Back")) { chosingNewConfigurationName = false; showingConfigurations = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
public static IDocumentStoreFactory GetDocumentStoreFactory(AbstractConfiguration cfg) { IDocumentStoreFactory docStoreFactory = cfg.Get<IDocumentStoreFactory>(DocumentStoreFactory_SettingsKey); if (docStoreFactory == null) throw new InvalidOperationException("Missing document store factory for event store."); return docStoreFactory; }
public ConfigurationBackedDynamicPropertySupport(AbstractConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } m_Configuration = configuration; }
public static IMessageSink GetMessageSink(AbstractConfiguration cfg) { IMessageSink messageSink = cfg.Get <IMessageSink>(MessageSink_SettingsKey); if (messageSink == null) { throw new InvalidOperationException(string.Format("No message sink has been configured.")); } return(messageSink); }
public static IMessageSource GetMessageSource(AbstractConfiguration cfg) { IMessageSource messageSource = cfg.Get <IMessageSource>(MessageSource_SettingsKey); if (messageSource == null) { throw new InvalidOperationException(string.Format("No message source has been configured for message bus.")); } return(messageSource); }
public static IDocumentStoreFactory GetSubscriptionStore(AbstractConfiguration cfg) { IDocumentStoreFactory store = cfg.Get <IDocumentStoreFactory>(SubscriptionStoreFactory_SettingsKey); if (store == null) { throw new InvalidOperationException(string.Format("No message bus subscription store has been configured.")); } return(store); }
public static IDocumentSerializer GetSubscriptionSerializer(AbstractConfiguration cfg) { IDocumentSerializer serializer = cfg.Get <IDocumentSerializer>(SubscriptionSerializer_SettingsKey); if (serializer == null) { throw new InvalidOperationException(string.Format("No message bus subscription serializer has been configured.")); } return(serializer); }
public static ISerializer GetMessageSerializer(AbstractConfiguration cfg) { ISerializer serializer = cfg.Get <ISerializer>(MessageSerializer_SettingsKey); if (serializer == null) { throw new InvalidOperationException(string.Format("No message serializer has been configured.")); } return(serializer); }
internal void addConfiguration(AbstractConfiguration abstractConfiguration) { deleteConfiguration(abstractConfiguration.configurationName); gOConfigurations.Add(abstractConfiguration); if (!localNames.Contains(abstractConfiguration.configurationName)) { localNames.Add(abstractConfiguration.configurationName); } manager.addConfiguration(abstractConfiguration); }
public static IDocumentStoreFactory GetDocumentStoreFactory(AbstractConfiguration cfg) { IDocumentStoreFactory docStoreFactory = cfg.Get <IDocumentStoreFactory>(DocumentStoreFactory_SettingsKey); if (docStoreFactory == null) { throw new InvalidOperationException("Missing document store factory for event store."); } return(docStoreFactory); }
public static EventStoreDB GetEventStoreDB(AbstractConfiguration cfg) { EventStoreDB eStore = cfg.Get <EventStoreDB>(EventStoreDB_SettingsKey); if (eStore == null) { throw new InvalidOperationException("Missing event store. Are you missing a call to Done() in the event store configuration code?"); } return(eStore); }
public static ISubscriptionService GetSubscriptionService(AbstractConfiguration cfg) { ISubscriptionService service = cfg.Get <ISubscriptionService>(SubscriptionService_SettingsKey); if (service == null) { throw new InvalidOperationException("Missing message bus subscription service configuration. Please make sure both subscription store and subscription serializer has been configured"); } return(service); }
public static IEventPublisher GetEventPublisher(AbstractConfiguration cfg, bool mustExists) { IEventPublisher eventPublisher = cfg.Get <IEventPublisher>(EventPublisher_SettingsKey); if (eventPublisher == null && mustExists) { throw new InvalidOperationException("Missing event publisher for event store."); } return(eventPublisher); }
internal override void onDeleting(AbstractConfiguration c) { EditorUtility.SetDirty((SensorsManager)manager); AssetDatabase.SaveAssets(); SensorConfiguration sensorConf = (SensorConfiguration)c; if (!(AssetDatabase.LoadAssetAtPath("Assets/Resources/Sensors/" + sensorConf.configurationName + ".asset", typeof(SensorConfiguration)) is null)) { AssetDatabase.DeleteAsset("Assets/Resources/Sensors/" + sensorConf.configurationName + ".asset"); } }
public static MessageDispatcher GetDispatcher(AbstractConfiguration cfg) { MessageDispatcher dispatcher; if (!cfg.TryGet <MessageDispatcher>(MessageDispatcher_SettingsKey, out dispatcher)) { IObjectContainer container = Xyperico.Agres.Configuration.ObjectContainerConfigurationExtensions.GetObjectContainer(cfg); dispatcher = new MessageDispatcher(container); cfg.Set(MessageDispatcher_SettingsKey, dispatcher); } return(dispatcher); }
public void addConfiguration(AbstractConfiguration abstractConfiguration) { delete(abstractConfiguration.configurationName); actuatorsConfs.Add(abstractConfiguration); if (!configurationsNames.Contains(abstractConfiguration.configurationName)) { configurationsNames.Add(abstractConfiguration.configurationName); } if (!configuredGameObject.Contains(abstractConfiguration.gOName)) { configuredGameObject.Add(abstractConfiguration.gOName); } }
public void SelectNode() { TestingConfiguration config = new TestingConfiguration(); config.Load("desktop.config", "desktop"); Assert.IsNotNull(config.XmlElement); XmlNode node = AbstractConfiguration.SelectNode(config.XmlElement, "/nohros/common/providers"); Assert.IsNull(node); node = AbstractConfiguration.SelectNode(config.XmlElement, "nohros/common/providers"); Assert.IsNotNull(node); }
public void addConfiguration(AbstractConfiguration abstractConfiguration) { //Debug.Log("checking if to delete " + abstractConfiguration.name); delete(abstractConfiguration.configurationName); sensConfs.Add(abstractConfiguration); if (!configurationsNames.Contains(abstractConfiguration.configurationName)) { configurationsNames.Add(abstractConfiguration.configurationName); } if (!configuredGameObject.Contains(abstractConfiguration.gOName)) { configuredGameObject.Add(abstractConfiguration.gOName); } }
private void deleteGO(AbstractConfiguration abstractConfiguration) { foreach (ActuatorConfiguration c in actuatorsConfs) { if (!c.configurationName.Equals(abstractConfiguration.configurationName)) { if (c.gOName.Equals(abstractConfiguration.gOName)) { return; } } } configuredGameObject.Remove(abstractConfiguration.gOName); }
/// <summary> /// Initialize the factory with an AbstractConfiguration. /// /// The initialization will register a ConfigurationListener with the configuration so that <see cref="DynamicProperty"/> /// will receives a callback and refresh its value when a property is changed in the configuration. /// /// If the factory is already initialized with a default configuration source (see <see cref="GetInstance"/>), it will re-register /// itself with the new configuration source passed to this method. Otherwise, this method will throw IllegalArgumentException /// if it has been initialized with a different and non-default configuration source. This method should be only called once. /// </summary> /// <param name="config">Configuration to be attached with DynamicProperty</param> /// <returns>the instance of DynamicPropertyFactory</returns> public static DynamicPropertyFactory InitWithConfigurationSource(AbstractConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } lock (typeof(ConfigurationManager)) { if (ConfigurationManager.IsConfigurationInstalled && config != ConfigurationManager.GetConfigInstance()) { throw new InvalidOperationException("ConfigurationManager is already initialized with configuration " + ConfigurationManager.GetConfigInstance()); } if (config is IDynamicPropertySupport) { return(InitWithConfigurationSource((IDynamicPropertySupport)config)); } return(InitWithConfigurationSource(new ConfigurationBackedDynamicPropertySupport(config))); } }
/// <summary> /// Initialize the factory with a <see cref="IDynamicPropertySupport"/>. /// /// The initialization will register a {@link PropertyListener} with the DynamicPropertySupport so that DynamicProperty /// will receives a callback and refresh its value when a property is changed. /// /// If the factory is already initialized with a default configuration source (see <see cref="GetInstance"/>), it will re-register /// itself with the new configuration source passed to this method. Otherwise, this method will throw IllegalArgumentException /// if it has been initialized with a non-default configuration source. This method should be only called once. /// </summary> /// <param name="dynamicPropertySupport">DynamicPropertySupport to be associated with the DynamicProperty</param> /// <returns>the instance of DynamicPropertyFactory</returns> internal static DynamicPropertyFactory InitWithConfigurationSource(IDynamicPropertySupport dynamicPropertySupport) { if (dynamicPropertySupport == null) { throw new ArgumentNullException("dynamicPropertySupport"); } lock (typeof(ConfigurationManager)) { AbstractConfiguration configuration = null; if (dynamicPropertySupport is AbstractConfiguration) { configuration = (AbstractConfiguration)dynamicPropertySupport; } else if (dynamicPropertySupport is ConfigurationBackedDynamicPropertySupport) { configuration = ((ConfigurationBackedDynamicPropertySupport)dynamicPropertySupport).Configuration; } if (InitializedWithDefaultConfig) { m_Config = null; } else if (m_Config != null && m_Config != dynamicPropertySupport) { throw new InvalidOperationException("DynamicPropertyFactory is already initialized with a diffrerent configuration source: " + m_Config); } if (ConfigurationManager.IsConfigurationInstalled && (configuration != null && configuration != ConfigurationManager.GetConfigInstance())) { throw new InvalidOperationException("ConfigurationManager is already initialized with configuration " + ConfigurationManager.GetConfigInstance()); } if (configuration != null && configuration != ConfigurationManager.GetConfigInstance()) { ConfigurationManager.SetDirect(configuration); } SetDirect(dynamicPropertySupport); return(m_Instance); } }
protected void updateConfiguredObject(AbstractConfiguration conf) { if (configurator.generalUsedNames().Contains(tracker.configurationName)) { configurator.deleteConfiguration(tracker.configurationName); } /*else * { * configurator.addConfiguredGameObject(chosenGO); * }*/ try { //MyDebugger.MyDebug("before adding"+manager.confs().Count); configurator.addConfiguration(tracker.saveConfiguration(conf, chosenGO)); //MyDebugger.MyDebug("after adding" + manager.confs().Count); } catch (Exception e) { //MyDebugger.MyDebug("error while adding"); //MyDebugger.MyDebug(e.StackTrace); } }
private static MessageBusHost BuildMessageBusHost(AbstractConfiguration cfg) { MessageBusHost busHost = new MessageBusHost(MessageBusConfigurationExtensions.GetMessageSource(cfg), MessageBusConfigurationExtensions.GetDispatcher(cfg)); return busHost; }
private static IMessageBus BuildMessageBus(AbstractConfiguration cfg) { ISubscriptionService subscriptionService = MessageBusConfigurationExtensions.GetSubscriptionService(cfg); IMessageSink messageSink = MessageBusConfigurationExtensions.GetMessageSink(cfg); IObjectContainer container = ObjectContainerConfigurationExtensions.GetObjectContainer(cfg); IRouteManager routeManager = container.Resolve<IRouteManager>(); Xyperico.Agres.MessageBus.Implementation.MessageBus bus = new Agres.MessageBus.Implementation.MessageBus(subscriptionService, routeManager, messageSink); container.RegisterInstance<IMessageBus>(bus); return bus; }
public ObjectContainerConfiguration(AbstractConfiguration cfg) : base(cfg) { }
public AbstractConfiguration saveConfiguration(AbstractConfiguration conf, string chosenGO) { conf.SaveConfiguration(this); //Debug.Log(conf); return(conf); }
internal void updateDataStructures(string chosenGO, AbstractConfiguration s) { if (chosenGO != null) { configurationName = ""; GO = GetGameObject(chosenGO); } else { GO = GetGameObject(s.gOName); configurationName = s.configurationName; } cleanDataStructures(); List <FieldOrProperty> p = GetFieldsAndProperties(GO);; ObjectsProperties.Add(GO, new Dictionary <string, FieldOrProperty>()); ObjectDerivedFromFields.Add(GO, new Dictionary <string, object>()); foreach (FieldOrProperty obj in p) { object gOValueForObj; try { gOValueForObj = obj.GetValue(GO); } catch (Exception e) { gOValueForObj = null; } ObjectsProperties[GO].Add(obj.Name(), obj); if (gOValueForObj != null && !IsMappable(obj)) { if (!ObjectsOwners.ContainsKey(gOValueForObj)) { ObjectsOwners.Add(gOValueForObj, new KeyValuePair <object, string>(GO, obj.Name())); } } ObjectDerivedFromFields[GO].Add(obj.Name(), gOValueForObj); if (!ObjectsToggled.ContainsKey(obj)) { if (s != null && s.properties.Contains(obj.Name())) { //Debug.Log(obj.Name() + " found."); ObjectsToggled.Add(obj, true); if (!IsMappable(obj) && gOValueForObj != null) { // Debug.Log("calling update"); updateDataStructures(gOValueForObj, s, obj.Name()); } else { if (IsMappable(obj) && !IsBaseType(obj)) { foreach (SimpleGameObjectsTracker st in s.advancedConf) { if (st.propertyName.Equals(obj.Name())) { //st.objType = obj.Type().GetElementType().ToString(); basicTypeCollectionsConfigurations.Add(obj, st); //Debug.Log("Adding st for " + obj.Name() + " whit type " + st.objType); break; } } } if (s.GetType() == typeof(SensorConfiguration)) { foreach (StringIntPair pair in ((SensorConfiguration)s).operationPerProperty) { if (pair.Key.Equals(obj.Name())) { operationPerProperty.Add(obj, pair.Value); if (pair.Value == Operation.SPECIFIC) { foreach (StringStringPair pair2 in ((SensorConfiguration)s).specificValuePerProperty) { if (pair2.Key.Equals(obj.Name())) { specificValuePerProperty.Add(obj, pair2.Value); break; } } } break; } } } } } else { ObjectsToggled.Add(obj, false); } } } GOComponents.Add(GO, GetComponents(GO)); foreach (Component c in GOComponents[GO]) { if (s != null && s.properties.Contains(c.GetType().ToString())) { //Debug.Log("component "+c+" name "+c.name+" type "+c.GetType()); ObjectsToggled.Add(c, true); updateDataStructures(c, s, c.GetType().ToString()); } else { ObjectsToggled.Add(c, false); } } }
public void OnBeforeUpdate(ObjectClass oclass, Uid uid, ICollection <ConnectorAttribute> attributes, OperationOptions options, AbstractConfiguration connectorConfiguration) { LOG.Info("OnBeforeUpdate started"); AddOrReplaceDatabase(oclass, uid, attributes, options, connectorConfiguration); LOG.Info("OnBeforeUpdate finished"); }
public static ISerializer GetMessageSerializer(AbstractConfiguration cfg) { return cfg.Get<ISerializer>(MessageSerializer_SettingsKey); }
protected void showConfigurations() { if (configurator.configurationNames().Count > 0) { GUILayout.Label("Some configurations exist for " + chosenGO, EditorStyles.label); } /*EditorGUILayout.BeginHorizontal(); * GUILayout.Label("Do you want to load it?", EditorStyles.label); * bool yes = GUILayout.Button("Yes"); * bool no = GUILayout.Button("No"); * EditorGUILayout.EndHorizontal(); * if (yes) * { * disableProperties = false; * foreach (AbstractConfiguration s in manager.confs()) * { * if (s.gOName.Equals(chosenGO)) * { * tracker.updateDataStructures(null, s); * Repaint(); * return; * } * } * } * if (no) * { * disableProperties = false; * updateDataStructures(); * Repaint(); * } * return;*/ List <string> confToShow = new List <string>(); confToShow.Add("New Configuration"); foreach (string c in configurator.configurationNames()) { confToShow.Add(c); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); chosenConfig = GUILayout.SelectionGrid(chosenConfig, confToShow.ToArray(), 1, new GUIStyle(GUI.skin.toggle), GUILayout.MaxWidth(300));//_------!!!!!!!!!!!!!!!!!!!!!!!!!!1 GUILayout.BeginHorizontal(); if (GUILayout.Button("Configure", GUILayout.MaxWidth(100))) { if (chosenConfig == 0) { showingConfigurations = false; chosingNewConfigurationName = true; } else { configuration = configurator.findConfiguration(confToShow[chosenConfig]); showingConfigurations = false; configuringConfiguration = true; } } if (chosenConfig != 0) { Color contentTemp = GUI.contentColor; Color backTemp = GUI.backgroundColor; GUI.backgroundColor = Color.white; GUI.contentColor = Color.red; if (GUILayout.Button("Delete configuration", GUILayout.MaxWidth(150))) { configurator.deleteConfiguration(confToShow[chosenConfig]); chosenConfig = 0; } GUI.contentColor = contentTemp; GUI.backgroundColor = backTemp; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); /*else * { * List<AbstractConfiguration> relatedConfiguration = new List<AbstractConfiguration>(); * List<string> relatedGO = new List<string>(); * relatedGO.Add("Chose a configuration"); * foreach (AbstractConfiguration s in manager.confs()) * { * if (s.gOType != null) * { * UnityEngine.Object parent = PrefabUtility.GetCorrespondingObjectFromSource(tracker.GetGameObject(chosenGO)); * if (parent != null && s.gOType.Equals(parent.ToString())) * { * relatedConfiguration.Add(s); * relatedGO.Add(s.gOName); * } * } * } * if (relatedConfiguration.Count > 0) * { * GUILayout.Label("Following object of type " + PrefabUtility.GetCorrespondingObjectFromSource(tracker.GetGameObject(chosenGO)).ToString() + " have been configured.", EditorStyles.label); * GUILayout.Label("Chose one to load its configuration or click \"Continue\" to start a new configuration.", EditorStyles.label); * EditorGUILayout.BeginHorizontal(); * chosenConfig = EditorGUILayout.Popup(chosenConfig, relatedGO.ToArray()); * bool cont = GUILayout.Button("Continue"); * EditorGUILayout.EndHorizontal(); * if (cont) * { * disableProperties = false; * updateDataStructures(); * Repaint(); * } * if (chosenConfig > 0) * { * disableProperties = false; * tracker.updateDataStructures(chosenGO, relatedConfiguration[chosenConfig - 1]); * Repaint(); * chosenConfig = 0; * } * return; * } * }*/ }
internal virtual void onDeleting(AbstractConfiguration c) { }
public static ISerializer GetMessageSerializer(AbstractConfiguration cfg) { return(cfg.Get <ISerializer>(MessageSerializer_SettingsKey)); }
public BaseConfiguration(AbstractConfiguration cfg) : base(cfg) { }
internal void updateDataStructures(object obj, AbstractConfiguration s, string parent) { //Debug.Log("updating " + parent); List <FieldOrProperty> p = GetFieldsAndProperties(obj); ObjectsProperties.Add(obj, new Dictionary <string, FieldOrProperty>()); //Debug.Log("Adding derived from fields entry"); ObjectDerivedFromFields.Add(obj, new Dictionary <string, object>()); foreach (FieldOrProperty ob in p) { //Debug.Log("Property " + ob.Name()); object objValueForOb; try { objValueForOb = ob.GetValue(obj); } catch (Exception e) { //Debug.Log("cannot get value for property " + ob.Name()); objValueForOb = null; } ObjectsProperties[obj].Add(ob.Name(), ob); //Debug.Log("complete name " + parent + "^" + ob.Name()); if (objValueForOb != null) { if (!ObjectsOwners.ContainsKey(objValueForOb)) { ObjectsOwners.Add(objValueForOb, new KeyValuePair <object, string>(obj, ob.Name())); } //Debug.Log(ob.Name() + " owner is " + ObjectsOwners[objValueForOb]+"and its value is "+objValueForOb); } if (s != null && s.properties.Contains(parent + "^" + ob.Name())) { //Debug.Log("s contains " + parent + "^" + ob.Name()); ObjectsToggled.Add(ob, true); if (!IsMappable(ob) && objValueForOb != null) { updateDataStructures(objValueForOb, s, parent + "^" + ob.Name()); } else { if (IsMappable(ob) && !IsBaseType(ob)) { foreach (SimpleGameObjectsTracker st in s.advancedConf) { if (st.propertyName.Equals(parent + "^" + ob.Name())) { //st.objType = ob.Type().GetElementType().ToString(); //Debug.Log("Adding st for " + ob.Name() + " whit type " + st.objType); basicTypeCollectionsConfigurations.Add(ob, st); break; } } } if (s.GetType() == typeof(SensorConfiguration)) { foreach (StringIntPair pair in ((SensorConfiguration)s).operationPerProperty) { if (pair.Key.Equals(parent + "^" + ob.Name())) { operationPerProperty.Add(ob, pair.Value); if (pair.Value == Operation.SPECIFIC) { foreach (StringStringPair pair2 in ((SensorConfiguration)s).specificValuePerProperty) { if (pair2.Key.Equals(parent + "^" + ob.Name())) { specificValuePerProperty.Add(ob, pair2.Value); break; } } } break; } } } } } else { ObjectsToggled.Add(ob, false); } ObjectDerivedFromFields[obj].Add(ob.Name(), objValueForOb); } if (obj.GetType() == typeof(GameObject)) { GOComponents[(GameObject)obj] = GetComponents((GameObject)obj); foreach (Component c in GOComponents[(GameObject)obj]) { if (s != null && s.properties.Contains(c.GetType().ToString())) { //Debug.Log(obj.Name() + " found."); ObjectsToggled.Add(c, true); updateDataStructures(c, s, c.GetType().ToString()); } else { ObjectsToggled.Add(c, false); } } } }
public void OnBeforeDelete(ObjectClass objClass, Uid uid, OperationOptions options, AbstractConfiguration connectorConfiguration) { }