Пример #1
0
        public bool CheckPorts()
        {
            bool res = true;

            /*
             *     foreach (KeyValuePair<String, IInputPort> kvp in _inputPorts) {
             *         if (kvp.Value is NullConnection) {
             *              Console.WriteLine("Input port specified in metadata, but not connected: " +  Name + "."  +
             *            kvp.Value.Name);
             *         res = false;
             *         }
             *     }
             */
            foreach (KeyValuePair <String, OutputPort> kvp in _outputPorts)
            {
                if (kvp.Value is NullOutputPort)
                {
                    NullOutputPort nop = (NullOutputPort)kvp.Value;
                    if (nop._optional)
                    {
                        continue;
                    }

                    Console.WriteLine("Output port specified in metadata, but not connected: " + Name + "." +
                                      kvp.Value.Name);
                    res = false;
                }
            }
            return(res);
        }
Пример #2
0
 protected internal void ProcOpty(string s, OutPort opt)
 {
     if (opt.arrayPort)
     {
         OutArray oa = new OutArray();
         _outputPorts.Add(s, oa);
         oa._fixedSize = opt.fixedSize;
         oa._optional  = opt.optional;
     }
     else
     {
         OutputPort op = new NullOutputPort();
         op._optional = opt.optional;
         op.SetSender(this);
         _outputPorts.Add(s, op);
         op._name = s;
     }
 }
Пример #3
0
        protected internal OutputPort[] OpenOutputArray(string name, int arraySize)
        {
            if (name.StartsWith("*"))
            {
                FlowError.Complain("Attempt to open * port: " + this + "." + name);
            }

            if (!_outputPorts.ContainsKey(name))
            {
                FlowError.Complain("Port not defined as output array in metadata: " + this._name + "." + name);
            }
            var o = _outputPorts[name];

            if (!(o is OutArray))
            {
                FlowError.Complain("Port not defined as output array in metadata: " + this._name + "." + name);
            }
            var oa = o as OutArray;

            if (!(oa._fixedSize ^ arraySize == 0))
            {
                FlowError.Complain("Array port fixedSize option in metadata doesn't match specified size: " + this._name
                                   + "." + name);
            }
            OutputPort[] array = GetPortArray(_outputPorts, name);

            if (array == null && !oa._optional)
            {
                FlowError.Complain("No elements defined in mandatory output array port: " + this._name + "." + name);
            }

            if (array != null)
            {
                if (arraySize > 0 && array.Length > arraySize)
                {
                    FlowError.Complain("Number of elements specified for array port less than actual number used: "
                                       + this._name + "." + name);
                }

                if (arraySize > 0 && array.Length < arraySize)
                {
                    Array.Resize(ref array, arraySize);
                }

                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] == null)
                    {
                        if (!oa._optional && arraySize > 0)
                        {
                            FlowError.Complain("Mandatory output array port has missing elements: " + this._name + "." + name);
                        }
                        array[i] = new NullOutputPort {
                            _sender = this, Name = Name + "." + name + "[" + i + "]"
                        };
                    }
                }
            }
            _outputPorts.Remove(name);
            return(array);
        }