private static void WriteUnifiedElement(
				UnifiedElement elem, StringBuilder buffer, int depth) {
			WriteTypeWithoutContent(elem, buffer, depth);
			// write items of enumerable
			var seq = elem as IEnumerable;
			if (seq != null) {
				foreach (var item in seq) {
					ToStringRecursively(item, buffer, depth + 1);
				}
				Debug.Assert(
						elem.GetType().GetProperties()
								.Where(
										prop =>
										prop.Name.StartsWith("Unified")
										|| prop.Name.StartsWith("IUnified"))
								.Where(
										prop =>
										!IgnorePropertyNames.Contains(prop.Name))
								.Where(
										prop =>
										prop.GetIndexParameters().Length == 0)
								.Select(prop => prop.GetValue(elem, null)).Count
								() == 0);
				return;
			}

			// write properties without indexer
			var values = elem.GetType().GetProperties()
					.Where(prop => !IgnorePropertyNames.Contains(prop.Name))
					.Where(prop => prop.GetIndexParameters().Length == 0)
					.Select(prop => prop.GetValue(elem, null));
			foreach (var value in values) {
				ToStringRecursively(value, buffer, depth + 1);
			}
		}
예제 #2
0
        private static void XmlWriteUnifiedElement(
            UnifiedElement elem, StringBuilder buffer, int depth)
        {
            // write items of enumerable
            var seq = elem as IEnumerable;

            if (seq != null)
            {
                foreach (var item in seq)
                {
                    ToXmlRecursively(item, buffer, depth + 1);
                }
            }

            // write properties without indexer
            var values = elem.GetType().GetProperties()
                         .Where(prop => !XmlIgnorePropertyNames.Contains(prop.Name))
                         .Where(prop => prop.GetIndexParameters().Length == 0)
                         .Select(prop => prop.GetValue(elem, null));

            foreach (var value in values)
            {
                ToXmlRecursively(value, buffer, depth + 1);
            }
        }
예제 #3
0
        private static void WriteUnifiedElement(
            UnifiedElement elem, StringBuilder buffer, int depth)
        {
            WriteTypeWithoutContent(elem, buffer, depth);
            // write items of enumerable
            var seq = elem as IEnumerable;

            if (seq != null)
            {
                foreach (var item in seq)
                {
                    ToStringRecursively(item, buffer, depth + 1);
                }
                Debug.Assert(
                    elem.GetType().GetProperties()
                    .Where(
                        prop =>
                        prop.Name.StartsWith("Unified") ||
                        prop.Name.StartsWith("IUnified"))
                    .Where(
                        prop =>
                        !IgnorePropertyNames.Contains(prop.Name))
                    .Where(
                        prop =>
                        prop.GetIndexParameters().Length == 0)
                    .Select(prop => prop.GetValue(elem, null)).Count
                        () == 0);
                return;
            }

            // write properties without indexer
            var values = elem.GetType().GetProperties()
                         .Where(prop => !IgnorePropertyNames.Contains(prop.Name))
                         .Where(prop => prop.GetIndexParameters().Length == 0)
                         .Select(prop => prop.GetValue(elem, null));

            foreach (var value in values)
            {
                ToStringRecursively(value, buffer, depth + 1);
            }
        }
예제 #4
0
        private static IEnumerable<UnifiedElement> GetProperties(
				UnifiedElement element)
        {
            var elements = element as IEnumerable<UnifiedElement>;
            if (elements != null) {
                foreach (var e in elements) {
                    yield return e;
                }
            }
            var props = element.GetType().GetProperties()
                    .Where(prop => prop.Name != "Parent")
                    .Where(prop => prop.GetIndexParameters().Length == 0)
                    .Where(
                            prop =>
                            typeof(UnifiedElement).IsAssignableFrom(
                                    prop.PropertyType));
            if (element is UnifiedWrapType) {
                props = props.Where(prop => prop.Name != "BasicTypeName");
            }
            foreach (var prop in props) {
                yield return (UnifiedElement)prop.GetValue(element, null);
            }
        }
		private static void XmlWriteUnifiedElement(
				UnifiedElement elem, StringBuilder buffer, int depth) {
			// write items of enumerable
			var seq = elem as IEnumerable;
			if (seq != null) {
				foreach (var item in seq) {
					ToXmlRecursively(item, buffer, depth + 1);
				}
			}

			// write properties without indexer
			var values = elem.GetType().GetProperties()
					.Where(prop => !XmlIgnorePropertyNames.Contains(prop.Name))
					.Where(prop => prop.GetIndexParameters().Length == 0)
					.Select(prop => prop.GetValue(elem, null));
			foreach (var value in values) {
				ToXmlRecursively(value, buffer, depth + 1);
			}
		}