コード例 #1
0
        public override void setUp()
        {
            try
            {
                base.setUp();
            }
            catch (Exception)
            {
                //
            }
            JDFDoc  d = new JDFDoc("JDF");
            JDFNode n = d.getJDFRoot();

            n.setType("Interpreting", false);
            cp = (JDFColorPool)n.addResource("ColorPool", null, EnumUsage.Input, null, null, null, null);
            cp.appendColorWithName("Cyan", "true");
            cp.appendColorWithName("Grün", "Grün");
            ((JDFColor)cp.appendElement("jdf:Color", JDFElement.getSchemaURL())).setName("foo");
        }
コード例 #2
0
        public virtual void testJobPhase()
        {
            JDFDoc    doc = new JDFDoc(ElementName.JMF);
            JDFJMF    jmf = doc.getJMFRoot();
            JDFSignal s   = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal, null);

            s.setType("Status");
            JDFStatusQuParams sqp = s.appendStatusQuParams();

            sqp.setDeviceDetails(EnumDeviceDetails.Brief);
            JDFDeviceInfo di = s.appendDeviceInfo();
            JDFJobPhase   jp = di.appendJobPhase();

            Assert.AreEqual(di.getJobPhase(0), jp);
            jp = (JDFJobPhase)di.appendElement("jdf:JobPhase", JDFElement.getSchemaURL());
            Assert.AreEqual(di.getJobPhase(1), jp);
            Assert.IsNull(di.getJobPhase(2));
            jp.appendNode();
            Assert.IsTrue(jp.isValid(EnumValidationLevel.Incomplete));
        }
コード例 #3
0
ファイル: JDFAbstractState.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * set the default values specified in this in element
        ///	 *  </summary>
        ///	 * <param name="element">
        ///	 *            the element to set the defaults on </param>
        ///	 * <returns> true if successful </returns>
        ///
        public virtual bool setDefaultsFromCaps(KElement element, bool bAll)
        {
            string def = getAttribute(AttributeName.DEFAULTVALUE, null, null);

            if (!bAll && def == null)
            {
                return(false);
            }
            if (def == null)
            {
                def = getAttribute(AttributeName.CURRENTVALUE, null, null);
            }

            if (def == null)
            {
                def = getAttribute(AttributeName.ALLOWEDVALUELIST, null, null);
                if (def != null && (def.IndexOf("~") >= 0 || def.IndexOf(" ") >= 0)) // allowedvaluelist
                // is
                // a
                // list
                // or
                // range
                {
                    string lt = getListType().getName();
                    if (!lt.EndsWith("List") && def.IndexOf(" ") >= 0)
                    {
                        def = StringUtil.token(def, 0, " ");
                    }
                    else if (lt.IndexOf("Range") < 0 && def.IndexOf("~") >= 0)
                    {
                        def = null;
                    }
                }
                if (def == null)
                {
                    def = getXPathAttribute("Value/@AllowedValue", null);
                }
            }
            if (def == null)
            {
                if ((this is JDFIntegerState) || (this is JDFNumberState))
                {
                    def = "1";
                }
                else if (this is JDFXYPairState)
                {
                    def = "1 1";
                }
                else if (this is JDFBooleanState)
                {
                    def = "true";
                }
                else if (this is JDFMatrixState)
                {
                    def = JDFMatrix.unitMatrix.ToString();
                }
                else if (this is JDFShapeState)
                {
                    def = "1 2 3";
                }
                else if (this is JDFDateTimeState)
                {
                    def = new JDFDate().DateTimeISO;
                }
                else if (this is JDFDurationState)
                {
                    def = new JDFDuration(42).getDurationISO();
                }
                else
                {
                    def = "some_value"; // TODO add better type dependent value
                    // generator
                }
            }
            object theValue = getMatchingObjectInNode(element);

            if (theValue != null)
            {
                return(false);
            }

            string nam   = getName();
            string nsURI = getDevNS();

            if (nsURI.Equals(JDFElement.getSchemaURL()))
            {
                nsURI = null;
            }
            if (nsURI != null)
            {
                string prefix = KElement.xmlnsPrefix(nam);
                if (prefix == null)
                {
                    nam = StringUtil.token(nsURI, -1, "/") + ":" + nam;
                }
            }

            if (getListType().Equals(EnumListType.Span))
            {
                JDFIntentResource ir   = (JDFIntentResource)element;
                JDFSpanBase       span = ir.appendSpan(nam, null);
                span.setAttribute(AttributeName.PREFERRED, def);
            }
            else
            // some attribute...
            {
                element.setAttribute(nam, def, nsURI);
            }
            return(true);
        }
コード例 #4
0
ファイル: JDFAbstractState.cs プロジェクト: cip4/JDFLibNet
 ///
 ///	 <summary> * Gets URI attribute DevNS
 ///	 *  </summary>
 ///	 * <returns> String: the attribute value </returns>
 ///
 public virtual string getDevNS()
 {
     return(getAttribute(AttributeName.DEVNS, null, JDFElement.getSchemaURL()));
 }