示例#1
0
        /// <summary>
        /// Gets the class name and generates an input parameter for the data type of this element
        /// </summary>
        /// <param name="g"></param>
        /// <param name="entry"></param>
        /// <returns></returns>
        internal static (string, SyntaxNode) Parse(SyntaxGenerator g, DictionaryData entry)
        {
            var readVr = new string(entry.VR.Replace("OR", "").Take(2).ToArray());

            if (readVr != "Se" && !string.IsNullOrEmpty(entry.Keyword))
            {
                var  cName    = GetVRFromAbbreviation(readVr).ToString();
                Type dataType = null;


                var instance = (IDICOMElement)(Activator.CreateInstance(typeof(DICOMObject).Assembly.FullName,
                                                                        $"EvilDICOM.Core.Element.{cName}")
                                               .Unwrap());
                cName    = cName == "DateTime" ? "Element.DateTime" : cName;
                dataType = instance.DatType;

                //Hack to make sure we are in right namespace - EvilDICOM has DateTime VR and so does system
                var dataTypeName = dataType.Name.StartsWith("Nullable") ? "System.DateTime?" : dataType.Name;

                //Initialize strings as empty string instead of null
                var parameter = g.ParameterDeclaration("data", g.IdentifierName($"params {dataTypeName}[]"),
                                                       null, RefKind.None);

                return(cName, parameter);
            }
            return(null, null);
        }
示例#2
0
        internal static SyntaxNode Generate(SyntaxGenerator g, DictionaryData entry)
        {
            //TAGHELPER
            var t = g.FieldDeclaration(entry.Keyword, g.IdentifierName("Tag"), Accessibility.Public,
                                       DeclarationModifiers.Static, g.ObjectCreationExpression(g.IdentifierName("Tag"),
                                                                                               new SyntaxNode[] { g.Argument(RefKind.None, g.LiteralExpression(entry.Id)) }));

            return(t);
        }
示例#3
0
        internal static Type ParseDataType(DictionaryData entry)
        {
            var readVr = new string(entry.VR.Replace("OR", "").Take(2).ToArray());

            if (readVr != "Se" && !string.IsNullOrEmpty(entry.Keyword))
            {
                var  cName    = GetVRFromAbbreviation(readVr).ToString();
                Type dataType = null;


                var instance = (IDICOMElement)(Activator.CreateInstance(typeof(DICOMObject).Assembly.FullName,
                                                                        $"EvilDICOM.Core.Element.{cName}")
                                               .Unwrap());
                cName    = cName == "DateTime" ? "Element.DateTime" : cName;
                dataType = instance.DatType;
                return(dataType);
            }
            return(null);
        }
示例#4
0
        internal static SyntaxNode[] GenerateSequencePropertyStatements(SyntaxGenerator g, string cName, DictionaryData entry)
        {
            var propGetStatements = new SyntaxNode[]
            {
                //get { return _dicom.FindFirst("00000000") as UnsignedLong;
                //}
                //set { _dicom.ReplaceOrAdd(value); }

                g.ReturnStatement(g.CastExpression(g.IdentifierName(cName), g.InvocationExpression(g.IdentifierName($"Items.FindFirst<{cName}>"),
                                                                                                   new SyntaxNode[] { g.Argument(RefKind.None, g.LiteralExpression(entry.Id)) })))
            };

            return(propGetStatements);
        }