예제 #1
0
        private static void AssignOverrideToOverride(IEnumerable <Exposed.Entry> entries, Override ovdBase, Override ovdOverride)
        /// Analog of AssignOverrideToFields, but overrides sub-graph defaults instead of generator fields
        {
            foreach (Exposed.Entry entry in entries)
            {
                if (!ovdBase.TryGetValue(entry.name, out Type origType, out object origVal))
                {
                    continue;
                }
                //do not override values that were not exposed

                if (origType != entry.type)
                {
                    continue;
                }
                //do not override if they are of the same type


                object            val;
                Calculator.Vector vec = entry.calculator.Calculate(ovdOverride);

                if (entry.channel == -1)                 //non-channel
                {
                    val = vec.Convert(entry.type);
                }
                else
                {
                    val = vec.ConvertToChannel(origVal, entry.channel, entry.type);
                }

                ovdBase[entry.name] = val;
            }
        }
예제 #2
0
        public Vector Calculate(Override ovd)
        /// The same but with Override
        {
            if (dataType == DataType.Operator)
            {
                Vector leftVal  = left.Calculate(ovd);
                Vector rightVal = right.Calculate(ovd);
                return(Action(leftVal, rightVal, action));
            }

            else if (dataType == DataType.Reference)
            {
                if (ovd.TryGetValue(reference, out Type type, out object val))
                {
                    return(new Vector(val));
                }

                else
                {
                    return((Vector)0);
                }
            }