GetValue() public abstract method

public abstract GetValue ( DocumentObject dom, GV flags ) : object
dom DocumentObject
flags GV
return object
Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether the member of dom specified by name is null.
        /// If a member with the specified name does not exist an ArgumentException will be thrown.
        /// </summary>
        public virtual bool IsNull(DocumentObject dom, string name)
        {
            //bool isNull = false;
            int dot = name.IndexOf('.');

            if (dot == 0)
            {
                throw new ArgumentException(DomSR.InvalidValueName(name));
            }
            string trail = null;

            if (dot > 0)
            {
                trail = name.Substring(dot + 1);
                name  = name.Substring(0, dot);
            }
            ValueDescriptor vd = this.vds[name];

            if (vd == null)
            {
                throw new ArgumentException(DomSR.InvalidValueName(name));
            }

            if (vd is NullableDescriptor || vd is ValueTypeDescriptor)
            {
                if (trail != null)
                {
                    throw new ArgumentException(DomSR.InvalidValueName(name));
                }
                return(vd.IsNull(dom));
            }
            DocumentObject docObj = (DocumentObject)vd.GetValue(dom, GV.ReadOnly);

            if (docObj == null)
            {
                return(true);
            }
            if (trail != null)
            {
                return(docObj.IsNull(trail));
            }
            else
            {
                return(docObj.IsNull());
            }

            //      DomValueDescriptor vd = vds[name];
            //      if (vd == null)
            //        throw new ArgumentException(DomSR.InvalidValueName(name));
            //
            //      return vd.IsNull(dom);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the object specified by name from dom.
        /// </summary>
        public object GetValue(DocumentObject dom, string name, GV flags)
        {
            int dot = name.IndexOf('.');

            if (dot == 0)
            {
                throw new ArgumentException(DomSR.InvalidValueName(name));
            }
            string trail = null;

            if (dot > 0)
            {
                trail = name.Substring(dot + 1);
                name  = name.Substring(0, dot);
            }
            ValueDescriptor vd = _vds[name];

            if (vd == null)
            {
                throw new ArgumentException(DomSR.InvalidValueName(name));
            }

            object value = vd.GetValue(dom, flags);

            if (value == null && flags == GV.GetNull)  //??? also for GV.ReadOnly?
            {
                return(null);
            }

            //REVIEW DaSt: Create object in case of GV.ReadWrite?
            if (trail != null)
            {
                if (value == null || trail == "")
                {
                    throw new ArgumentException(DomSR.InvalidValueName(name));
                }
                DocumentObject doc = value as DocumentObject;
                if (doc == null)
                {
                    throw new ArgumentException(DomSR.InvalidValueName(name));
                }
                value = doc.GetValue(trail, flags);
            }
            return(value);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the object specified by name from dom.
        /// </summary>
        public object GetValue(DocumentObject dom, string name, GV flags)
        {
            int dot = name.IndexOf('.');

            if (dot == 0)
            {
                throw new ArgumentException(DomSR.InvalidValueName(name));
            }
            string trail = null;

            if (dot > 0)
            {
                trail = name.Substring(dot + 1);
                name  = name.Substring(0, dot);
            }
            ValueDescriptor vd = this.vds[name];

            if (vd == null)
            {
                throw new ArgumentException(DomSR.InvalidValueName(name));
            }

            object value = vd.GetValue(dom, flags);

            if (value == null && flags == GV.GetNull) //??? oder auch GV.ReadOnly?
            {
                return(null);
            }

            //REVIEW DaSt: Sollte beim GV.ReadWrite das Objekt angelegt werden?
            if (trail != null)
            {
                if (value == null || trail == "")
                {
                    throw new ArgumentException(DomSR.InvalidValueName(name));
                }
                DocumentObject doc = value as DocumentObject;
                if (doc == null)
                {
                    throw new ArgumentException(DomSR.InvalidValueName(name));
                }
                value = doc.GetValue(trail, flags);
            }
            return(value);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Parses the assignment to a Color l-value.
 /// </summary>
 private void ParseColorAssignment(DocumentObject dom, ValueDescriptor vd)
 {
     object val = vd.GetValue(dom, GV.ReadWrite);
     Color color = ParseColor();
     dom.SetValue(vd.ValueName, color);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Parses the assignment to a DocumentObject l-value.
        /// </summary>
        private void ParseDocumentObjectAssignment(DocumentObject dom, ValueDescriptor vd)
        {
            // Create value if it does not exist
            object val = vd.GetValue(dom, GV.ReadWrite);
            //DocumentObject docObj = (DocumentObject)val;

            try
            {
                if (Symbol == Symbol.Null)
                {
                    //string name = vd.ValueName;
                    Type type = vd.ValueType;
                    if (typeof(Border) == type)
                        ((Border)val).Clear();
                    else if (typeof(Borders) == type)
                        ((Borders)val).ClearAll();
                    else if (typeof(Shading) == type)
                        ((Shading)val).Clear();
                    else if (typeof(TabStops) == type)
                    {
                        TabStops tabStops = (TabStops)vd.GetValue(dom, GV.ReadWrite);
                        tabStops.ClearAll();
                    }
                    else
                        ThrowParserException(DomMsgID.NullAssignmentNotSupported, vd.ValueName);

                    ReadCode();
                }
                else
                {
                    throw new Exception("Case: TopPosition");
                    //dom.SetValue(vd.ValueName, docObj);
                }
            }
            catch (Exception ex)
            {
                ReportParserException(ex, DomMsgID.InvalidAssignment, vd.ValueName);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Parses the assignment to a struct (i.e. LeftPosition) l-value.
 /// </summary>
 private void ParseValueTypeAssignment(DocumentObject dom, ValueDescriptor vd)
 {
     object val = vd.GetValue(dom, GV.ReadWrite);
     try
     {
         INullableValue ival = (INullableValue)val;
         ival.SetValue(Token);
         dom.SetValue(vd.ValueName, val);
         ReadCode();
     }
     catch (Exception ex)
     {
         ReportParserException(ex, DomMsgID.InvalidAssignment, vd.ValueName);
     }
 }