本文整理汇总了C#中libsbmlcs.UnitDefinition类的典型用法代码示例。如果您正苦于以下问题:C# UnitDefinition类的具体用法?C# UnitDefinition怎么用?C# UnitDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnitDefinition类属于libsbmlcs命名空间,在下文中一共展示了UnitDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setUp
public void setUp()
{
UD = new UnitDefinition(2,4);
if (UD == null);
{
}
}
示例2: test_UnitDefinition_addUnit2
public void test_UnitDefinition_addUnit2()
{
UnitDefinition m = new UnitDefinition(2,2);
Unit p = new Unit(2,1);
p.setKind(libsbml.UNIT_KIND_MOLE);
int i = m.addUnit(p);
assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH );
assertTrue( m.getNumUnits() == 0 );
p = null;
m = null;
}
示例3: test_UnitDefinition_addUnit1
public void test_UnitDefinition_addUnit1()
{
UnitDefinition m = new UnitDefinition(2,2);
Unit p = new Unit(2,2);
int i = m.addUnit(p);
assertTrue( i == libsbml.LIBSBML_INVALID_OBJECT );
p.setKind(libsbml.UNIT_KIND_MOLE);
i = m.addUnit(p);
assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
assertTrue( m.getNumUnits() == 1 );
p = null;
m = null;
}
示例4: getCPtrAndDisown
internal static HandleRef getCPtrAndDisown(UnitDefinition obj)
{
HandleRef ptr = new HandleRef(null, IntPtr.Zero);
if (obj != null)
{
ptr = obj.swigCPtr;
obj.swigCMemOwn = false;
}
return ptr;
}
示例5: UnitDefinition
/**
* Copy constructor; creates a copy of this UnitDefinition.
*
* @param orig the object to copy.
*
* @throws @if python ValueError @else SBMLConstructorException @endif
* Thrown if the argument @p orig is @c null.
*/
public UnitDefinition(UnitDefinition orig)
: this(libsbmlPINVOKE.new_UnitDefinition__SWIG_2(UnitDefinition.getCPtr(orig)), true)
{
if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
}
示例6: test_UnitDefinition_L1
public void test_UnitDefinition_L1()
{
UnitDefinition ud = new UnitDefinition(1,2);
assertEquals( true, ud.hasRequiredElements() );
ud = null;
}
示例7: test_Unit_ancestor_add
public void test_Unit_ancestor_add()
{
UnitDefinition ud = new UnitDefinition(2,4);
Unit u = new Unit(2,4);
u.setKind(libsbml.UNIT_KIND_MOLE);
ud.addUnit(u);
u = null;
assertTrue( ud.getNumUnits() == 1 );
ListOf lo = ud.getListOfUnits();
Unit obj = ud.getUnit(0);
assertTrue( obj.getAncestorOfType(libsbml.SBML_UNIT_DEFINITION) == ud );
assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
ud = null;
}
示例8: addUnitDefinition
/**
* Adds a copy of the given UnitDefinition object to this Model.
*
* @param ud the UnitDefinition object to add
*
*
* @return integer value indicating success/failure of the
* function. @if clike The value is drawn from the
* enumeration #OperationReturnValues_t. @endif The possible values
* returned by this function are:
* @li @link libsbml#LIBSBML_OPERATION_SUCCESS [email protected]
* @li @link libsbml#LIBSBML_LEVEL_MISMATCH [email protected]
* @li @link libsbml#LIBSBML_VERSION_MISMATCH [email protected]
* @li @link libsbml#LIBSBML_DUPLICATE_OBJECT_ID [email protected]
* @li @link libsbml#LIBSBML_INVALID_OBJECT [email protected]
* @li @link libsbml#LIBSBML_OPERATION_FAILED [email protected]
*
*
* @note This method should be used with some caution. The fact that this
* method @em copies the object passed to it means that the caller will be
* left holding a physically different object instance than the one contained
* inside this object. Changes made to the original object instance (such as
* resetting attribute values) will <em>not affect the instance in this
* object</em>. In addition, the caller should make sure to free the
* original object if it is no longer being used, or else a memory leak will
* result. Please see other methods on this class (particularly a
* corresponding method whose name begins with the word <code>create</code>)
* for alternatives that do not lead to these issues.
*
*
*
* @see createUnitDefinition()
*/
public int addUnitDefinition(UnitDefinition ud)
{
int ret = libsbmlPINVOKE.Model_addUnitDefinition(swigCPtr, UnitDefinition.getCPtr(ud));
return ret;
}
示例9: test_UnitDefinition_printUnits
public void test_UnitDefinition_printUnits()
{
UnitDefinition ud = new UnitDefinition(2,4);
ud.setId( "mmls");
Unit perTime = ud.createUnit();
perTime.setKind(libsbml.UnitKind_forName("second"));
perTime.setExponent(-1);
string ud_str = UnitDefinition.printUnits(ud,false);
assertTrue(( "second (exponent = -1, multiplier = 1, scale = 0)" == ud_str ));
string ud_str1 = UnitDefinition.printUnits(ud,true);
assertTrue(( "(1 second)^-1" == ud_str1 ));
UnitDefinition ud1 = new UnitDefinition(2,4);
ud1.setId( "mmls");
Unit u = ud1.createUnit();
u.setKind(libsbml.UNIT_KIND_KILOGRAM);
u.setExponent(1);
u.setScale(2);
u.setMultiplier(3.0);
string ud_str2 = UnitDefinition.printUnits(ud1,false);
assertTrue(( "kilogram (exponent = 1, multiplier = 3, scale = 2)" == ud_str2 ));
string ud_str3 = UnitDefinition.printUnits(ud1,true);
assertTrue(( "(300 kilogram)^1" == ud_str3 ));
}
示例10: convertToSI
/**
* Convert a given UnitDefinition into a new UnitDefinition object
* that uses SI units.
*
* @param ud the UnitDefinition object to convert to SI
*
* @return a new UnitDefinition object representing the results of the
* conversion.
*
* @if notclike @note Because this is a @em static method, the
* non-C++ language interfaces for libSBML will contain two variants. One
* will be a static method on the class (i.e., UnitDefinition), and the
* other will be a standalone top-level function with the name
* UnitDefinition_convertToSI(). They are functionally identical. @endif
*/
public static UnitDefinition convertToSI(UnitDefinition ud)
{
IntPtr cPtr = libsbmlPINVOKE.UnitDefinition_convertToSI(UnitDefinition.getCPtr(ud));
UnitDefinition ret = (cPtr == IntPtr.Zero) ? null : new UnitDefinition(cPtr, true);
return ret;
}
示例11: test_Unit_parent_create
public void test_Unit_parent_create()
{
UnitDefinition ud = new UnitDefinition(2,4);
Unit u = ud.createUnit();
assertTrue( ud.getNumUnits() == 1 );
ListOf lo = ud.getListOfUnits();
assertTrue( lo == ud.getUnit(0).getParentSBMLObject() );
assertTrue( lo == u.getParentSBMLObject() );
assertTrue( ud == lo.getParentSBMLObject() );
ud = null;
}
示例12: test_UnitDefinition_isVariantOfSubstancePerTime_4
public void test_UnitDefinition_isVariantOfSubstancePerTime_4()
{
UnitDefinition ud = new UnitDefinition(2,2);
Unit dim = ud.createUnit();
dim.setKind(libsbml.UnitKind_forName("dimensionless"));
Unit perTime = ud.createUnit();
perTime.setKind(libsbml.UnitKind_forName("second"));
perTime.setExponent(-1);
Unit u = ud.createUnit();
assertEquals( false, ud.isVariantOfSubstancePerTime() );
u.setKind(libsbml.UNIT_KIND_KILOGRAM);
u.setExponent(1);
assertEquals( true, ud.isVariantOfSubstancePerTime() );
u.setScale(-1);
perTime.setScale(-1);
assertEquals( true, ud.isVariantOfSubstancePerTime() );
u.setMultiplier(2);
assertEquals( true, ud.isVariantOfSubstancePerTime() );
u.setOffset(3);
assertEquals( true, ud.isVariantOfSubstancePerTime() );
u.setExponent(-3);
assertEquals( false, ud.isVariantOfSubstancePerTime() );
u.setExponent(1);
perTime.setExponent(-3);
assertEquals( false, ud.isVariantOfSubstancePerTime() );
perTime.setExponent(-1);
ud.addUnit(dim);
assertEquals( true, ud.isVariantOfSubstancePerTime() );
ud = null;
}
示例13: test_Unit_parent_add
public void test_Unit_parent_add()
{
UnitDefinition ud = new UnitDefinition(2,4);
Unit u = new Unit(2,4);
u.setKind(libsbml.UNIT_KIND_MOLE);
ud.addUnit(u);
u = null;
assertTrue( ud.getNumUnits() == 1 );
ListOf lo = ud.getListOfUnits();
assertTrue( lo == ud.getUnit(0).getParentSBMLObject() );
assertTrue( ud == lo.getParentSBMLObject() );
ud = null;
}
示例14: test_UnitDefinition_parent_add
public void test_UnitDefinition_parent_add()
{
UnitDefinition ia = new UnitDefinition(2,4);
Model m = new Model(2,4);
ia.setId("u");
ia.createUnit();
m.addUnitDefinition(ia);
ia = null;
ListOf lo = m.getListOfUnitDefinitions();
assertTrue( lo == m.getUnitDefinition(0).getParentSBMLObject() );
assertTrue( m == lo.getParentSBMLObject() );
}
示例15: test_Unit_ancestor_create
public void test_Unit_ancestor_create()
{
UnitDefinition ud = new UnitDefinition(2,4);
Unit u = ud.createUnit();
assertTrue( ud.getNumUnits() == 1 );
ListOf lo = ud.getListOfUnits();
assertTrue( u.getAncestorOfType(libsbml.SBML_UNIT_DEFINITION) == ud );
assertTrue( u.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
assertTrue( u.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
assertTrue( u.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
Unit obj = ud.getUnit(0);
assertTrue( obj.getAncestorOfType(libsbml.SBML_UNIT_DEFINITION) == ud );
assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
assertTrue( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == null );
ud = null;
}