コード例 #1
0
ファイル: RegionImpl.cs プロジェクト: vijaydairyf/PrtgAPI
        public Region Serialize(DocumentConfig documentConfig)
        {
            var serializedElements = new List <IElement>();

            foreach (var element in Elements)
            {
                if (element is RegionImpl)
                {
                    serializedElements.Add(((RegionImpl)element).Serialize(documentConfig));
                }
                else if (element is MethodImpl)
                {
                    serializedElements.AddRange(MethodImpl.Serialize((MethodImpl)element, documentConfig));
                }
                else if (element is InlineMethodDef)
                {
                    serializedElements.AddRange(((InlineMethodDef)element).Serialize((InlineMethodDef)element, documentConfig));
                }
                else
                {
                    throw new NotImplementedException($"Don't know how to serialize object of type '{element.GetType()}'.");
                }
            }

            return(new Region(Name, serializedElements.ToReadOnlyList(), GroupOverloads));
        }
コード例 #2
0
ファイル: RegionImpl.cs プロジェクト: runnane/PrtgAPI
        public Region Serialize(DocumentConfig documentConfig)
        {
            var regions = Regions.Select(r => r.Serialize(documentConfig)).ToList();

            var implMethodsAndRegions = MethodImpls.Select(m => MethodImpl.Serialize(m, documentConfig)).ToList();

            regions.AddRange(implMethodsAndRegions.Select(i => i.Item1).Where(v => v != null));

            var implMethods   = implMethodsAndRegions.SelectMany(i => i.Item2).ToList();
            var inlineMethods = InlineMethodDefs.SelectMany(m => m.Serialize(m, documentConfig)).ToList();

            return(new Region(Name, regions.ToReadOnlyList(), implMethods.Union(inlineMethods).ToReadOnlyList(), GroupOverloads));
        }