コード例 #1
0
        private string ValueAsString(object value, Relationship relationship)
        {
            string type = relationship.Type;

            if (type == null)
            {
                throw new MarshallingException("Relationship " + relationship.Name + " has no type information");
            }
            else
            {
                if ("CS".Equals(type))
                {
                    if (CodedTypeR2Helper.IsCodedTypeR2(value))
                    {
                        return(CodedTypeR2Helper.GetCodeValue(value));
                    }
                    else
                    {
                        if (value is Code)
                        {
                            return(((Code)value).CodeValue);
                        }
                        else
                        {
                            throw new MarshallingException("Encountered value \"" + value + "\" of type " + value.GetType().FullName + " when Code was expected ("
                                                           + relationship.Name + ")");
                        }
                    }
                }
                else
                {
                    if ("BL".Equals(type))
                    {
                        return(true.Equals(value) ? "true" : "false");
                    }
                    else
                    {
                        if ("ST".Equals(type))
                        {
                            return((string)value);
                        }
                        else
                        {
                            throw new MarshallingException("Cannot handle structural attribute string of type " + type + " (" + relationship.Name + ")"
                                                           );
                        }
                    }
                }
            }
        }
コード例 #2
0
 public virtual void TestIsCodedTypeR2True()
 {
     Assert.IsTrue(CodedTypeR2Helper.IsCodedTypeR2(new CodedTypeR2 <Code>()));
     Assert.IsTrue(CodedTypeR2Helper.IsCodedTypeR2(new CodedTypeR2 <UnitsOfMeasureCaseSensitive>()));
 }
コード例 #3
0
 public virtual void TestIsCodedTypeR2NotTrue()
 {
     Assert.IsFalse(CodedTypeR2Helper.IsCodedTypeR2(null));
     Assert.IsFalse(CodedTypeR2Helper.IsCodedTypeR2(new CDImpl()));
     Assert.IsFalse(CodedTypeR2Helper.IsCodedTypeR2(new CD_R2Impl <Code>()));
 }