Esempio n. 1
0
        /// <summary>
        /// Parses the settings we know about
        /// </summary>
        /// <param name="SettingsValues">A setting array that has been run through MDReplicator.ParseParameters</param>
        protected void ParseSettings(MDReplicatedSetting[] SettingsValues)
        {
            foreach (MDReplicatedSetting setting in SettingsValues)
            {
                switch ((Settings)setting.Key)
                {
                case Settings.OnValueChangedEvent:
                    Node Node = NodeRef.GetRef() as Node;
                    OnValueChangedMethodCallback = Node.GetType().GetMethodRecursive(setting.Value.ToString());
                    if (OnValueChangedMethodCallback == null)
                    {
                        OnValueChangedEventCallback = Node.GetType().GetEvent(setting.Value.ToString());
                    }
                    MDLog.CError(OnValueChangedMethodCallback == null && OnValueChangedEventCallback == null, LOG_CAT, $"Failed to find method or event with name {setting.Value.ToString()} on Node {Node.GetPath()}");
                    break;

                case Settings.Converter:
                    Type DataConverterType = Type.GetType(setting.Value.ToString());
                    DataConverter = MDStatics.CreateConverterOfType(DataConverterType);
                    break;

                case Settings.CallOnValueChangedEventLocally:
                    ShouldCallOnValueChangedCallbackLocally = setting.Value as bool? ?? false;
                    break;
                }
            }

            // We got no data converter, get default one
            if (DataConverter == null)
            {
                DataConverter = MDStatics.GetConverterForType(Member.GetUnderlyingType());
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Add a new id/key pair to our map
 /// </summary>
 /// <param name="id">The ID to add</param>
 /// <param name="key">The key to add</param>
 public void AddNetworkKeyIdPair(uint id, string key)
 {
     if (NetworkIDToKeyMap.ContainsKey(id) == false)
     {
         NetworkIDToKeyMap.Add(id, key);
         KeyToNetworkIdMap.Add(key, id);
     }
     else
     {
         MDLog.CError(!NetworkIDToKeyMap[id].Equals(key), LOG_CAT, $"Tried to add key {key} for id {id} but it already has key {NetworkIDToKeyMap[id]}");
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Get the uint id for a string key
 /// </summary>
 /// <param name="key">The key</param>
 /// <returns>The uint id</returns>
 public uint GetValue(string key)
 {
     MDLog.CError(KeyToNetworkIdMap.ContainsKey(key) == false, LOG_CAT, $"KeyToNetworkIdMap does not contain key {key}");
     return(KeyToNetworkIdMap.ContainsKey(key) ? KeyToNetworkIdMap[key] : 0);
 }
Esempio n. 4
0
 /// <summary>
 /// Get the string value for the uint id
 /// </summary>
 /// <param name="id">The uint id</param>
 /// <returns>The string key</returns>
 public string GetValue(uint id)
 {
     MDLog.CError(NetworkIDToKeyMap.ContainsKey(id) == false, LOG_CAT, $"NetworkIDToKeyMap does not contain id {id}");
     return(NetworkIDToKeyMap.ContainsKey(id) ? NetworkIDToKeyMap[id] : null);
 }