Esempio n. 1
0
 private void OnEnable()
 {
     _Path = (PathB)target;
     if (_Path.Points.Count == 0)
     {
         _Path.Create();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Apply this property mapping to transfer data
        /// between object b and object a
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        public void ApplyBtoA(object a, object b)
        {
            //Tokenise property path
            string[] pathATokens = PathA.Split('.');
            string[] pathBTokens = PathB.Split('.');

            //Find resolved source and target objects
            object source = GetPathEnd(b, pathBTokens);
            object target = GetPathEnd(a, pathATokens);

            if (source != null && target != null)
            {
                string sourceProp = pathBTokens.Last();
                string targetProp = pathATokens.Last();
                CopyPropertyData(source, target, sourceProp, targetProp);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            StreamReader Reader = new StreamReader(@"/Work/AoC/Day 3/day3.in");
            StreamWriter Writer = new StreamWriter(@"/Work/AoC/Day 3/day3.out");

            String[] FirstLine  = Reader.ReadLine().Split(",");
            String[] SecondLine = Reader.ReadLine().Split(",");

            GetPath(out PathA, FirstLine);
            GetPath(out PathB, SecondLine);
            List <KeyValuePair <(int, int), int> > Intersect = PathA.Where(d => PathB.ContainsKey(d.Key)).ToList();
            int minIntersection  = Intersect.Min(e => Math.Abs(e.Key.Item1) + Math.Abs(e.Key.Item2));
            int bestIntersection = Intersect.Min(e => PathA[e.Key] + PathB[e.Key]);

            Console.WriteLine("Minimum intersection: {0}", minIntersection);
            Console.WriteLine("Best intersection: {0}", bestIntersection);
            Writer.WriteLine(minIntersection);
            Writer.WriteLine(bestIntersection);
            Writer.Close();
            Reader.Close();
        }