Example #1
0
        /// <summary>
        /// The real constructor
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="name"></param>
        /// <param name="tag"></param>
        /// <param name="sequence"></param>
        /// <param name="localPackage"></param>
        /// <param name="variant"></param>
        /// <param name="flags"></param>
        /// <param name="earliestVersion"></param>
        /// <param name="latestVersion"></param>
        /// <param name="typeConverter"></param>
        public ElementDefImpl(IElementDef parent,
                              string name,
                              string tag,
                              int sequence,
                              string localPackage,
                              string variant,
                              int flags,
                              SifVersion earliestVersion,
                              SifVersion latestVersion,
                              TypeConverter typeConverter)
        {
            fName = name;

            if ((flags & FD_ATTRIBUTE) != 0)
            {
                // If this is an attribute, it is also a simple field
                flags |= FD_FIELD;
            }

            fFlags   = flags;
            fPackage = localPackage;

            fVariant       = variant;
            fParent        = (ElementDefImpl)parent;
            fTypeConverter = typeConverter;

            DefineVersionInfo(earliestVersion, tag == null ? name : tag, sequence, flags);
            fLatestVersion = latestVersion;

            if (fParent != null)
            {
                fParent.addChild(this);
            }
        }
Example #2
0
        /// <summary>
        /// Define an attribute of a SIF Data Object.
        /// </summary>
        /// <param name="parent">The IElementDef constant identifying the parent data object</param>
        /// <param name="name">The tag name of the attribute</param>
        /// <param name="sequence">The zero-based sequence number of the attribute</param>
        /// <param name="earliestVersion">The earliest version of the specification this attribute should
        /// be recognized in</param>
        /// <returns>An IElementDef instance encapsulating metadata for this attribute</returns>
        public IElementDef DefineAttribute( IElementDef parent,
                                            String name,
                                            int sequence,
                                            SifVersion earliestVersion )
        {
            if ( parent == null ) {
                throw new ArgumentException( "Parent cannot be null" );
            }

            IElementDef ed =
                new ElementDefImpl
                    ( parent, name, null, sequence, "custom", ElementDefImpl.FD_ATTRIBUTE,
                      earliestVersion, SifVersion.LATEST );
            SifDtd.sElementDefs.Add( parent.Name + "_" + name, ed );
            return ed;
        }
Example #3
0
        public virtual string GetSQPPath(SifVersion version)
        {
            StringBuilder b = new StringBuilder();

            if (IsAttribute(version))
            {
                b.Append('@');
            }
            b.Append(Tag(version));
            ElementDefImpl p = fParent;

            while (p != null && !p.Object)
            {
                b.Insert(0, p.Tag(version) + "/");
                p = p.fParent;
            }

            return(b.ToString());
        }
        /// <summary>
        /// The real constructor
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="name"></param>
        /// <param name="tag"></param>
        /// <param name="sequence"></param>
        /// <param name="localPackage"></param>
        /// <param name="variant"></param>
        /// <param name="flags"></param>
        /// <param name="earliestVersion"></param>
        /// <param name="latestVersion"></param>
        /// <param name="typeConverter"></param>
        public ElementDefImpl(IElementDef parent,
                              string name,
                              string tag,
                              int sequence,
                              string localPackage,
                              string variant,
                              int flags,
                              SifVersion earliestVersion,
                              SifVersion latestVersion,
                              TypeConverter typeConverter)
        {
            fName = name;

            if ((flags & FD_ATTRIBUTE) != 0)
            {
                // If this is an attribute, it is also a simple field
                flags |= FD_FIELD;
            }

            fFlags = flags;
            fPackage = localPackage;

            fVariant = variant;
            fParent = (ElementDefImpl) parent;
            fTypeConverter = typeConverter;

            DefineVersionInfo(earliestVersion, tag == null ? name : tag, sequence, flags);
            fLatestVersion = latestVersion;

            if (fParent != null)
            {
                fParent.addChild(this);
            }
        }
Example #5
0
        /// <summary>
        /// Define a complex child element of a SIF Data Object.
        /// </summary>
        /// <param name="parent">The IElementDef constant identifying the parent data object or element</param>
        /// <param name="element">The IElementDef constant of an existing element, such as a
        /// Common Element (e.g. <c>SifDtd.NAME</c>)</param>
        /// <param name="sequence">The zero-based sequence number of the element</param>
        /// <param name="flags">Optional flags for this field (e.g. <c>MD_REPEATABLE</c>), or zero
        /// if no flags are applicable</param>
        /// <param name="earliestVersion">The earliest version of the specification this element should
        /// be recognized in</param>
        /// <returns>An IElementDef instance encapsulating metadata for this element</returns>
        public IElementDef DefineChildElement( IElementDef parent,
                                               IElementDef element,
                                               int sequence,
                                               byte flags,
                                               SifVersion earliestVersion )
        {
            if ( parent == null ) {
                throw new ArgumentException( "Parent cannot be null" );
            }
            if ( element == null ) {
                throw new ArgumentException( "Element cannot be null" );
            }

            IElementDef ed =
                new ElementDefImpl
                    ( parent, element.Name, null, sequence, element.Package, flags, earliestVersion, SifVersion.LATEST );
            SifDtd.sElementDefs.Add( parent.Name + "_" + element.Name, ed );
            return ed;
        }
Example #6
0
        /// <summary>Define a field of a SIF Data Object.</summary>
        /// <remarks>
        /// A field is a simple child element that has no attributes or elements of its own and 
        /// is not represented by its own class. For example, the <c>&lt;LocalId&gt;</c> 
        /// common element in SIF 1.5. Internally, the ADK stores fields more efficiently than
        /// complex elements.
        /// </remarks>
        /// <param name="parent">The IElementDef constant identifying the parent data object or element</param>
        /// <param name="name">The tag name of the element</param>
        /// <param name="sequence">The zero-based sequence number of the element</param>
        /// <param name="flags">Optional flags for this field (e.g. <c>MD_REPEATABLE</c>), or zero
        /// if no flags are applicable</param>
        /// <param name="earliestVersion">The earliest version of the specification this element should
        /// be recognized in</param>
        /// <returns></returns>
        public IElementDef DefineField( IElementDef parent,
                                        String name,
                                        int sequence,
                                        byte flags,
                                        SifVersion earliestVersion )
        {
            if ( parent == null ) {
                throw new ArgumentException( "Parent cannot be null" );
            }

            IElementDef ed =
                new ElementDefImpl
                    ( parent, name, null, sequence, "custom",
                      (byte) (ElementDefImpl.FD_FIELD | flags), earliestVersion, SifVersion.LATEST );
            SifDtd.sElementDefs.Add( parent.Name + "_" + name, ed );
            return ed;
        }
Example #7
0
 /// <summary>
 /// Define a top-level SIF Data Object
 /// </summary>
 /// <param name="name">The tag name of the data object</param>
 /// <param name="earliestVersion">The earliest version of the specification this attribute should
 /// be recognized in</param>
 /// <returns>An IElementDef instance encapsulating metadata for this data object</returns>
 public IElementDef DefineDataObject( String name,
                                      SifVersion earliestVersion )
 {
     IElementDef ed =
         new ElementDefImpl
             ( null, name, null, 0, "custom", ElementDefImpl.FD_OBJECT, earliestVersion, SifVersion.LATEST );
     SifDtd.sElementDefs.Add( name, ed );
     return ed;
 }