Пример #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
                                        JsonSerializer serializer)
        {
            var jobject = JObject.Load(reader);

            object resolvedType = null;

            var kind = jobject["kind"]?.Value <string>();

            if (kind != null)
            {
                switch (kind)
                {
                case "ec":
                    resolvedType = new EcElement();
                    break;

                case "em":
                    resolvedType = new EmElement();
                    break;

                case "ph":
                    resolvedType = new PhElement();
                    break;

                case "sc":
                    resolvedType = new ScElement();
                    break;

                case "sm":
                    resolvedType = new SmElement();
                    break;
                }
            }
            else
            {
                resolvedType = new TextElement();
            }


            serializer.Populate(jobject.CreateReader(), resolvedType);

            return(resolvedType);
        }
Пример #2
0
        public void EmElement(XlfEventArgs args)
        {
            object parent = stack.Peek();

            switch (parent)
            {
            case Segment s:
                EmElement emElement = new EmElement();
                emElement.Attributes = args.Attributes;
                if (args.sourceOrTarget.Equals("source"))
                {
                    s.Source.Add(emElement);
                }
                else
                {
                    s.Target.Add(emElement);
                }

                break;

            default:
                break;
            }
        }