Beispiel #1
0
        public string GetConfig(Dictionary <Type, string> identities = null)
        {
            var sb = new StringBuilder();

            if (identities == null)
            {
                identities = new MessageResolver().Identity;
            }

            foreach (var name in FDictionary.Keys)
            {
                try
                {
                    var type = FDictionary[name][0].GetType();
                    sb.Append(", " + identities[type]);
                    sb.Append(" " + name);
                }
                catch (Exception err)
                {
                    // type not defined
                    err.ToString();                     // no warning
                }
            }
            return(sb.ToString().Substring(2));
        }
Beispiel #2
0
        protected void HandleConfigChange(IDiffSpread <string> configSpread)
        {
            Count = 0;
            var invalidPins = Pins.Keys.ToList();

            var config = configSpread[0].Trim().Split(',');

            foreach (string pinConfig in config)
            {
                var pinData = pinConfig.Trim().Split(' ');

                try
                {
                    var type = pinData[0].ToLower();
                    var name = pinData[1];

                    var create = false;
                    if (Pins.ContainsKey(name) && Pins[name] != null)
                    {
                        invalidPins.Remove(name);

                        if (Types.ContainsKey(name))
                        {
                            if (Types[name] != type)
                            {
                                Pins[name].Dispose();
                                Pins[name] = null;
                                create     = true;
                            }
                        }
                        else
                        {
                            // key is in FPins, but no type defined. should never happen
                            create = true;
                        }
                    }
                    else
                    {
                        Pins.Add(name, null);
                        create = true;
                    }

                    if (create)
                    {
                        var ident = new MessageResolver().Identity;

                        switch (type)
                        {
                        case "double": Pins[name] = CreatePin <double>(name); break;

                        case "float": Pins[name] = CreatePin <float>(name); break;

                        case "int": Pins[name] = CreatePin <int>(name); break;

                        case "bool": Pins[name] = CreatePin <bool>(name); break;

                        case "vector2d": Pins[name] = CreatePin <Vector2D>(name); break;

                        case "vector3d": Pins[name] = CreatePin <Vector3D>(name); break;

                        case "vector4d": Pins[name] = CreatePin <Vector3D>(name); break;

                        case "string": Pins[name] = CreatePin <string>(name); break;

                        case "color": Pins[name] = CreatePin <RGBAColor>(name); break;

                        case "transform": Pins[name] = CreatePin <Matrix4x4>(name); break;

                        case "texture2d": Pins[name] = CreatePin <DX11Resource <DX11Texture2D> >(name); break;

                        default:  Logger.Log(LogType.Debug, "Type " + type + " not supported!"); break;
                        }

                        Types.Add(name, type);
                    }

                    Count += 2;
                }
                catch (Exception ex)
                {
                    Logger.Log(LogType.Debug, ex.ToString());

                    Logger.Log(LogType.Debug, "Invalid Descriptor in Config Pin");
                }
            }

            foreach (var name in invalidPins)
            {
                Pins[name].Dispose();
                Pins.Remove(name);
                Types.Remove(name);
            }
        }
Beispiel #3
0
        public string GetConfig(Dictionary<Type, string> identities = null)
        {
            var sb = new StringBuilder();

            if (identities == null) identities = new MessageResolver().Identity;

            foreach (var name in FDictionary.Keys) {
                try
                {
                    var type = FDictionary[name][0].GetType();
                    sb.Append(", " + identities[type]);
                    sb.Append(" " + name);
                }
                catch (Exception err)
                {
                    // type not defined
                    err.ToString(); // no warning
                }
            }
            return sb.ToString().Substring(2);
        }