public static TElement Get <TElement>(this CompiledParticle compiled, OpenXmlCompositeElement element)
            where TElement : OpenXmlElement
        {
            if (compiled is null)
            {
                return(null);
            }

            var child = element.FirstChild;

            if (child is null)
            {
                return(null);
            }

            do
            {
                if (child.GetType() == typeof(TElement))
                {
                    return((TElement)child);
                }

                child = child.Next;
            } while (child != element.FirstChild);

            return(null);
        }
Esempio n. 2
0
        public static bool Set <TElement>(this CompiledParticle compiled, OpenXmlCompositeElement parent, TElement value)
            where TElement : OpenXmlElement
        {
            if (compiled is null)
            {
                return(false);
            }

            var collection = GetCollection <TElement>(compiled, parent);

            collection.Clear();
            return(collection.Add(value));
        }
        public static bool Set(this CompiledParticle compiled, OpenXmlCompositeElement parent, OpenXmlElement value, Type type)
        {
            if (type is null)
            {
                return(false);
            }

            if (compiled is null)
            {
                return(false);
            }

            var collection = new ParticleCollection(type, compiled, parent);

            collection.Clear();
            return(collection.Add(value));
        }
 public static bool Set <T>(this CompiledParticle compiled, OpenXmlCompositeElement parent, T value)
     where T : OpenXmlElement
 => Set(compiled, parent, value, typeof(T));
 public static ParticleCollection GetCollection <TElement>(this CompiledParticle compiled, OpenXmlCompositeElement element)
     where TElement : OpenXmlElement
 => new ParticleCollection(typeof(TElement), compiled, element);