Ejemplo n.º 1
0
        public virtual MessageTemplate CreateTemplateFromMessage(Message templateDef, ITemplateRegistry registry)
        {
            //string name = templateDef.GetString("Name");
            //Field[] fields = GroupConverter.ParseFieldInstructions(templateDef, registry, _initialContext);
            //return new MessageTemplate(name, fields);
            string      name          = templateDef.GetString("Name");
            string      tempnamespace = "";
            IFieldValue retNs;

            if (templateDef.TryGetValue("Ns", out retNs) && retNs != null)
            {
                tempnamespace = retNs.ToString();
            }
            Field[]     fields = GroupConverter.ParseFieldInstructions(templateDef, registry, _initialContext);
            var         group  = new MessageTemplate(new QName(name, tempnamespace), fields);
            IFieldValue retTypeRef;

            if (templateDef.TryGetValue("TypeRef", out retTypeRef) && retTypeRef != null)
            {
                var         typeRef     = (GroupValue)retTypeRef;
                string      typeRefName = typeRef.GetString("Name");
                string      typeRefNs   = ""; // context.getNamespace();
                IFieldValue retNs2;
                if (typeRef.TryGetValue("Ns", out retNs2) && retNs2 != null)
                {
                    typeRefNs = retNs2.ToString();
                }
                group.TypeReference = new QName(typeRefName, typeRefNs);
            }
            IFieldValue retAuxId;

            if (templateDef.TryGetValue("AuxId", out retAuxId) && retAuxId != null)
            {
                group.Id = retAuxId.ToString();
            }

            return(group);
        }