Exemplo n.º 1
0
        public GenDataId GetId(string name, bool createIfMissing = false)
        {
            var id = new GenDataId {
                ClassId = -1, PropertyId = -1, ClassName = "", PropertyName = ""
            };
            var    sa        = name.Split(new[] { '.' }, 2);
            var    className = "";
            string propertyName;

            if (sa.GetUpperBound(0) == 0)
            {
                id.ClassId   = CurrentClassId;
                propertyName = sa[0];
            }
            else
            {
                className    = sa[0];
                id.ClassId   = GetClassId(className);
                propertyName = sa[1];
            }
            if (id.ClassId != -1)
            {
                var c = Classes[id.ClassId];
                id.PropertyId = c.Properties.IndexOf(propertyName);
                if (id.PropertyId == -1)
                {
                    if (createIfMissing)
                    {
                        id.PropertyId = Classes[id.ClassId].Properties.Add(propertyName);
                    }
                    else if (propertyName.Equals("First", StringComparison.InvariantCultureIgnoreCase))
                    {
                        id.PropertyId = c.Properties.Add("First");
                        c.SetPseudo(id.PropertyId);
                    }
                    else if (propertyName.Equals("Reference", StringComparison.InvariantCultureIgnoreCase))
                    {
                        id.PropertyId = c.Properties.Add("Reference");
                        c.SetPseudo(id.PropertyId);
                    }
                }
            }

            if (id.ClassId == -1 || id.PropertyId == -1)
            {
                id.ClassName    = className;
                id.PropertyName = propertyName;
            }
            else
            {
                id.ClassName    = Classes[id.ClassId].Name;
                id.PropertyName = Classes[id.ClassId].Properties[id.PropertyId];
            }
            return(id);
        }
Exemplo n.º 2
0
        public string GetValue(GenDataId id, out bool notFound)
        {
            string value = null;

            if (id.ClassName == ClassName)
            {
                var indexOfClass    = GenDataBase.GenDataDef.GetClassId(id.ClassName);
                var indexOfProperty = GenDataBase.GenDataDef.GetClassProperties(indexOfClass).IndexOf(id.PropertyName);
                if (GenDataBase.GenDataDef.GetClassDef(indexOfClass).IsPseudo(indexOfProperty))
                {
                    if (id.PropertyName.Equals("First", StringComparison.InvariantCultureIgnoreCase))
                    {
                        notFound = false;
                        return(ParentSubClass.IndexOf(this) == 0 ? "True" : "");
                    }
                    if (id.PropertyName.Equals("Reference", StringComparison.InvariantCultureIgnoreCase))
                    {
                        notFound = false;
                        return(ParentSubClass.Reference ?? "");
                    }
                    notFound = true;
                    return("");
                }
                var idx = Definition.Properties.IndexOf(id.PropertyName);
                if (idx == -1)
                {
                    value = "<<<< Invalid Lookup: " + id + " Property not found >>>>";
                }
                else
                {
                    notFound = false;
                    return(idx >= Attributes.Count ? "" : Attributes[idx]);
                }
            }
            if (Parent != null)
            {
                value = Parent.GetValue(id, out notFound);
                if (!notFound)
                {
                    return(value);
                }
            }
            if (RefParent != null)
            {
                value = RefParent.GetValue(id, out notFound);
                if (!notFound)
                {
                    return(value);
                }
            }
            notFound = true;
            return(value ?? "<<<< Invalid Lookup: " + id + " Class not found >>>>");
        }
Exemplo n.º 3
0
        public GenObject SearchFor(GenDataId id, string value)
        {
            var searchObjects = FindSearchObjects(id.ClassName);

            if (searchObjects == null)
            {
                return(null);
            }
            foreach (var searchObject in searchObjects)
            {
                bool notFound;
                var  s = searchObject.GetValue(id, out notFound);
                if (!notFound && s == value)
                {
                    return(searchObject);
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        public string GetValue(GenDataId id)
        {
            bool notFound;

            return(GetValue(id, out notFound));
        }