Beispiel #1
0
        /// <summary>
        /// Get/Set ObjKey by name (group name)
        /// </summary>
        /// <param name="okeyName">ObjKey name</param>
        /// <returns>FWObjKey object</returns>
        /// <remarks>
        /// If no ObjKey with the given name exists, a new ObjKey Object is created.
        /// </remarks>
        public FWObjKey this[string okeyName]
        {
            get
            {
                FWObjKey ret = null;
                string   okeyNameLowerCase = okeyName.ToLower();
                ObjKey[] arr       = Items;
                int      maxOkeyId = -1;
                foreach (ObjKey o in arr)
                {
                    if (o.name.ToLower().Equals(okeyNameLowerCase))
                    {
                        ret = new FWObjKey(o, GetDML(okeyName));
                        break;
                    }
                    maxOkeyId = Math.Max(maxOkeyId, o.id);
                }
                if (ret == null)
                {
                    ObjKey      okey = new ObjKey();
                    DocMaskLine dml  = GetDML(okeyName);
                    if (dml != null)
                    {
                        okey.id   = dml.id;
                        okey.name = dml.key;
                    }
                    else
                    {
                        okey.id   = maxOkeyId + 1;
                        okey.name = "INDEX" + okey.id;
                    }

                    Items = AddObjKey(arr, okey);
                }
                return(ret);
            }
            set
            {
                ObjKey okey = value.okey;
                okey.name = okeyName.ToUpper();
                string okeyNameLowerCase = okeyName.ToLower();

                bool     found = false;
                ObjKey[] arr   = Items;
                for (int i = 0; i < arr.Length; i++)
                {
                    ObjKey o = arr[i];
                    if (o.name.ToLower().Equals(okeyNameLowerCase))
                    {
                        arr[i] = okey;
                        found  = true;
                        break;
                    }
                }
                if (!found)
                {
                    Items = AddObjKey(arr, okey);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Implements the abstract function of FWCompareSord.
        /// </summary>
        /// <param name="o1">First object</param>
        /// <param name="o2">Second object</param>
        /// <returns>0, if o1 equal o2, 1 if o1 is greater than o2, -1 if o1 is less than o2.</returns>
        protected override int internalCompare(T o1, T o2)
        {
            FWObjKey okey1 = o1.ObjKeys[groupName];
            FWObjKey okey2 = o2.ObjKeys[groupName];

            return(CompareString(
                       okey1 != null ? okey1.Data.ToString() : null,
                       okey2 != null ? okey2.Data.ToString() : null));
        }
Beispiel #3
0
        /// <summary>
        /// Get/Set ObjKey by ID
        /// </summary>
        /// <param name="okeyId">ObjKey ID</param>
        /// <returns>FWObjKey object</returns>
        /// <remarks>
        /// If no ObjKey with the given ID exists, a new ObjKey Object is created.
        /// </remarks>
        public FWObjKey this[int okeyId]
        {
            get
            {
                FWObjKey ret = null;
                ObjKey[] arr = Items;
                foreach (ObjKey o in arr)
                {
                    if (o.id == okeyId)
                    {
                        ret = new FWObjKey(o, GetDML(okeyId));
                        break;
                    }
                }
                if (ret == null)
                {
                    ObjKey okey = new ObjKey();
                    okey.id = okeyId;
                    DocMaskLine dml = GetDML(okeyId);
                    okey.name = (dml != null) ?  dml.key : ("INDEX" + okeyId);
                    ret       = new FWObjKey(okey, dml);
                    Items     = AddObjKey(arr, okey);
                }
                return(ret);
            }
            set
            {
                ObjKey okey = value.okey;
                okey.id = okeyId;

                bool     found = false;
                ObjKey[] arr   = Items;
                for (int i = 0; i < arr.Length; i++)
                {
                    ObjKey o = arr[i];
                    if (o.id == okeyId)
                    {
                        arr[i] = okey;
                        found  = true;
                        break;
                    }
                }
                if (!found)
                {
                    Items = AddObjKey(arr, okey);
                }
            }
        }