示例#1
0
        private void Navigate(IFortranObject obj)
        {
            this.DoActions(obj, obj.GetType());

            var asContainer = (obj as IContainer)?.SubObjects;

            if (asContainer == null)
            {
                return;
            }

            for (var i = asContainer.Count - 1; i >= 0; i--)
            {
                this.Navigate(asContainer[i]);
            }
        }
示例#2
0
        private void DoActions(IFortranObject obj, Type type)
        {
            var actionsForType = _actions[type].ToList();

            if (!actionsForType.Any())
            {
                return;
            }

            var errorListener = new ErrorListener <TraverserException>(w => this.ErrorListener.Warning(w), e => this.ErrorListener.Error(e));

            foreach (var act in actionsForType)
            {
                act.Act(obj, errorListener);
            }
        }
示例#3
0
        /// <summary>
        /// Search the ancestors of an instance of <see cref="IContained"/> for an instance of type <typeparamref name="T"/>.
        /// </summary>
        /// <typeparam name="T">The type to search for.</typeparam>
        /// <param name="contained">The instances whose ancestors are to be searched.</param>
        /// <returns>The ancestor of type <typeparamref name="T"/>.</returns>
        public static T AncestorOfType <T>(IContained contained)
            where T : class, IFortranObject
        {
            if (contained == null)
            {
                return(null);
            }

            IFortranObject current  = contained;
            var            currentT = contained as T;

            while (current != null && currentT == null)
            {
                current  = (current as IContained)?.Parent;
                currentT = current as T;
            }

            return(currentT);
        }
示例#4
0
 public XElement CreateForObject(IFortranObject obj) => this.GetXmlValue(new[] { obj }).Single();
示例#5
0
 private IEnumerable <XElement> Navigate(IFortranObject obj)
 => (obj as IContainer)?.SubObjects.GroupBy(this.KeySelector).SelectMany(objsOfType => this.GetValue(objsOfType.Key, objsOfType)) ?? new XElement[]
 {
 };
示例#6
0
        private Type KeySelector(IFortranObject obj)
        {
            var objType = obj.GetType();

            return(objType.GetInterfaces().SingleOrDefault(inter => _toGroupXmlDictionary.ContainsKey(inter)) ?? objType);
        }
示例#7
0
 public XElement ParsedSourcesToXml(IFortranObject source)
 {
     throw new NotImplementedException();
 }