/// <summary> /// Creates and adds a new port. /// </summary> /// <param name="me">component descriptor to host the new port</param> /// <param name="name">name of new port</param> /// <param name="dir">data-flow direction</param> /// <param name="usage">usage hint</param> /// <param name="dataType">type descriptor of exchanged data</param> /// <returns>the descriptor of the newly created port</returns> public static PortBuilder CreatePort(this IComponentDescriptor me, string name, EFlowDirection dir, EPortUsage usage, TypeDescriptor dataType) { Contract.Requires <ArgumentNullException>(me != null); Contract.Requires <ArgumentNullException>(name != null); Contract.Requires <ArgumentNullException>(dataType != null); PortBuilder result = new PortBuilder(dir, usage, null, dataType); me.AddChild(result, name); return(result); }
/// <summary> /// Creates and adds a new field. /// </summary> /// <param name="me">component descriptor to host the new field</param> /// <param name="type">type descriptor of the new field</param> /// <param name="name">name of the new field</param> /// <returns>the descriptor of the new field</returns> public static DOMFieldBuilder CreateField(this IComponentDescriptor me, TypeDescriptor type, string name) { Contract.Requires <ArgumentNullException>(me != null); Contract.Requires <ArgumentNullException>(type != null); Contract.Requires <ArgumentNullException>(name != null); var fb = new DOMFieldBuilder(type); me.AddChild(fb, name); return(fb); }
/// <summary> /// Creates and adds a new signal, including its implementation-level instance. /// </summary> /// <param name="me">component descriptor to host the new signal</param> /// <param name="name">name of new signal</param> /// <param name="initialValue">initial value of new signal</param> /// <returns>the descriptor for the newly created signal</returns> public static SignalDescriptor CreateSignalInstance(this IComponentDescriptor me, string name, object initialValue) { Contract.Requires <ArgumentNullException>(me != null); Contract.Requires <ArgumentNullException>(initialValue != null); Contract.Requires <ArgumentNullException>(name != null); SignalBase sinst = Signals.CreateInstance(initialValue); SignalDescriptor result = sinst.Descriptor; me.AddChild(result, name); return(result); }
/// <summary> /// Creates and adds a new SysDOM-only signal descriptor. /// </summary> /// <param name="me">component descriptor to host the new signal</param> /// <param name="name">name of new signal</param> /// <param name="dataType">type of signal value</param> /// <returns>the descriptor for the newly created signal</returns> public static SignalBuilder CreateSignal(this IComponentDescriptor me, string name, Type dataType) { Contract.Requires <ArgumentNullException>(me != null); Contract.Requires <ArgumentNullException>(name != null); Contract.Requires <ArgumentNullException>(dataType != null); object initialValue = Activator.CreateInstance(dataType); SignalBuilder result = new SignalBuilder(dataType, initialValue); me.AddChild(result, name); return(result); }
/// <summary> /// Creates and adds a new field. /// </summary> /// <param name="me">component descriptor to host the new field</param> /// <param name="type">type descriptor of the new field</param> /// <param name="initialValue">initial field value</param> /// <param name="name">name of the new field</param> /// <returns>the descriptor of the new field</returns> public static DOMFieldBuilder CreateField(this IComponentDescriptor me, TypeDescriptor type, object initialValue, string name) { Contract.Requires <ArgumentNullException>(me != null); Contract.Requires <ArgumentNullException>(type != null); Contract.Requires <ArgumentNullException>(name != null); Contract.Requires <ArgumentException>(initialValue == null || TypeDescriptor.GetTypeOf(initialValue).Equals(type), "Field type must match type of initial value"); var fb = new DOMFieldBuilder(type, initialValue); me.AddChild(fb, name); return(fb); }
/// <summary> /// Creates and adds a new symbolic process (i.e. without specification of behavior). /// </summary> /// <param name="me">component descriptor to host the new process</param> /// <param name="kind">kind of process</param> /// <param name="name">name of the new process</param> /// <param name="sensitivity">sensitivity list of the new process</param> /// <returns>the descriptor of the new process</returns> public static ProcessDescriptor CreateProcess(this IComponentDescriptor me, Process.EProcessKind kind, string name, params ISignalOrPortDescriptor[] sensitivity) { Contract.Requires <ArgumentNullException>(me != null); Contract.Requires <ArgumentNullException>(name != null); Contract.Requires <ArgumentNullException>(sensitivity != null); ProcessDescriptor pd = new ProcessDescriptor(name) { Kind = kind, Sensitivity = sensitivity }; me.AddChild(pd, pd.Name); return(pd); }
public virtual void Nest(IComponentDescriptor owner, MethodInfo method) { owner.AddChild(this); Owner = owner; _implementation = new DescriptorNestingByMethod(owner.Instance, method); }