Пример #1
0
        private static PropertyInfo GetPropertyInfo(
            TimelineBase element,
            string fieldName)
        {
            const BindingFlags flag =
                BindingFlags.Instance |
                BindingFlags.Public |
                BindingFlags.NonPublic |
                BindingFlags.IgnoreCase;

            var info = default(PropertyInfo);

            var type = element.GetType();

            if (type == null)
            {
                return(info);
            }

            // 通常のフィールド名からフィールド情報を取得する
            info = type.GetProperty(fieldName, flag);

            if (info != null)
            {
                return(info);
            }

            // XML属性名からフィールド情報を取得する
            var pis = type.GetProperties(flag);

            foreach (var pi in pis)
            {
                var attr = Attribute.GetCustomAttributes(pi, typeof(XmlAttributeAttribute))
                           .FirstOrDefault() as XmlAttributeAttribute;
                if (attr != null)
                {
                    if (string.Equals(
                            attr.AttributeName,
                            fieldName,
                            StringComparison.OrdinalIgnoreCase))
                    {
                        info = pi;
                        break;
                    }
                }
            }

            return(info);
        }
Пример #2
0
        private string GetRootSubRoutine(
            TimelineBase element)
        {
            var parent = element.Parent;

            if (parent == null)
            {
                return(string.Empty);
            }

            if (parent is TimelineSubroutineModel sub)
            {
                return(sub.Name ?? string.Empty);
            }

            return(this.GetRootSubRoutine(parent));
        }