Exemplo n.º 1
0
        public override bool IsEqual(TunableStore o)
        {
            ArrayValueStore store = o as ArrayValueStore;

            if (store == null)
            {
                return(false);
            }

            if (mIndex != store.mIndex)
            {
                return(false);
            }

            return(base.IsEqual(o));
        }
Exemplo n.º 2
0
 public ArrayValueStore(ArrayValueStore store)
     : base(store)
 {
     mIndex = store.mIndex;
 }
Exemplo n.º 3
0
        public override bool Parse(XmlDbRow row)
        {
            if (!base.Parse(row))
            {
                return(false);
            }

            List <string> subFieldNames = new List <string>();

            int count = 1;

            while (true)
            {
                string suffix = null;
                if (count > 1)
                {
                    suffix = count.ToString();
                }

                string subFieldName = row.GetString("SubFieldName" + suffix);
                if (string.IsNullOrEmpty(subFieldName))
                {
                    break;
                }

                subFieldNames.Add(subFieldName);
                count++;
            }

            if (subFieldNames.Count == 0)
            {
                BooterLogger.AddError("SubFieldName missing for " + mParentType + "." + mFieldName);
                return(false);
            }

            FieldInfo subField = GetFieldInfo();

            if (subField == null)
            {
                BooterLogger.AddError("Unknown Field for " + mParentType.ToString() + "." + mFieldName);
                return(false);
            }

            NestedStore parentStore = this;

            for (int i = 0; i < subFieldNames.Count - 1; i++)
            {
                FieldInfo newField = subField.FieldType.GetField(subFieldNames[i], BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                if (newField == null)
                {
                    BooterLogger.AddError("Unknown SubField for " + subField.FieldType.ToString() + "." + subFieldNames[i]);
                    return(false);
                }

                NestedStore newStore = new NestedStore(newField, null);

                parentStore.mChild = newStore;

                subField    = newField;
                parentStore = newStore;
            }

            string finalFieldName = subFieldNames[subFieldNames.Count - 1];

            FieldInfo finalField = subField.FieldType.GetField(finalFieldName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);

            if (finalField == null)
            {
                BooterLogger.AddError("Unknown SubField for " + subField.FieldType.ToString() + "." + finalFieldName);
                return(false);
            }

            ValueStore child = null;

            if (row.Exists("Index"))
            {
                int index = row.GetInt("Index", -1);
                if (index < 0)
                {
                    BooterLogger.AddError("Invalid Index for " + mParentType + "." + mFieldName);
                    return(false);
                }

                child = new ArrayValueStore(finalField, index, null);
            }
            else
            {
                child = new ValueStore(finalField, null);
            }

            parentStore.mChild = child;

            return(child.ParseValue(row));
        }
Exemplo n.º 4
0
        public override bool Parse(XmlDbRow row)
        {
            if (!base.Parse(row)) return false;

            List<string> subFieldNames = new List<string>();

            int count = 1;
            while (true)
            {
                string suffix = null;
                if (count > 1)
                {
                    suffix = count.ToString();
                }

                string subFieldName = row.GetString("SubFieldName" + suffix);
                if (string.IsNullOrEmpty(subFieldName))
                {
                    break;
                }

                subFieldNames.Add(subFieldName);
                count++;
            }

            if (subFieldNames.Count == 0)
            {
                BooterLogger.AddError("SubFieldName missing for " + mParentType + "." + mFieldName);
                return false;
            }

            FieldInfo subField = GetFieldInfo();
            if (subField == null)
            {
                BooterLogger.AddError("Unknown Field for " + mParentType.ToString() + "." + mFieldName);
                return false;
            }

            NestedStore parentStore = this;

            for (int i = 0; i < subFieldNames.Count - 1; i++)
            {
                FieldInfo newField = subField.FieldType.GetField(subFieldNames[i], BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                if (newField == null)
                {
                    BooterLogger.AddError("Unknown SubField for " + subField.FieldType.ToString() + "." + subFieldNames[i]);
                    return false;
                }

                NestedStore newStore = new NestedStore(newField, null);

                parentStore.mChild = newStore;

                subField = newField;
                parentStore = newStore;
            }

            string finalFieldName = subFieldNames[subFieldNames.Count - 1];

            FieldInfo finalField = subField.FieldType.GetField(finalFieldName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
            if (finalField == null)
            {
                BooterLogger.AddError("Unknown SubField for " + subField.FieldType.ToString() + "." + finalFieldName);
                return false;
            }            

            ValueStore child = null;
            if (row.Exists("Index"))
            {
                int index = row.GetInt("Index", -1);
                if (index < 0)
                {
                    BooterLogger.AddError("Invalid Index for " + mParentType + "." + mFieldName);
                    return false;
                }

                child = new ArrayValueStore(finalField, index, null);
            }
            else
            {
                child = new ValueStore(finalField, null);
            }

            parentStore.mChild = child;

            return child.ParseValue(row);
        }
Exemplo n.º 5
0
 public ArrayValueStore(ArrayValueStore store)
     : base(store)
 {
     mIndex = store.mIndex;
 }