예제 #1
0
        public override bool IsEqual(TunableStore o)
        {
            NestedStore store = o as NestedStore;

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

            if (!mChild.IsEqual(store.mChild))
            {
                return(false);
            }

            return(base.IsEqual(o));
        }
예제 #2
0
 public NestedStore(NestedStore store)
     : base(store)
 {
     mChild = store.mChild.Clone();
 }
예제 #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);
        }
예제 #4
0
 public NestedStore(NestedStore store)
     : base(store)
 {
     mChild = store.mChild.Clone();
 }
예제 #5
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));
        }