コード例 #1
0
            public IDisposable Scope(TextWriter writer)
            {
                WriterScope scope = new WriterScope(this, InnerWriter);

                if (writer != this)
                {
                    InnerWriter = writer;
                }

                return(scope);
            }
コード例 #2
0
ファイル: ViewPage.cs プロジェクト: pmq20/mono_forked
            public IDisposable Scope(TextWriter writer)
            {
                WriterScope scope = new WriterScope(this, InnerWriter);

                try {
                    if (writer != this)
                    {
                        InnerWriter = writer;
                    }

                    return(scope);
                }
                catch {
                    scope.Dispose();
                    throw;
                }
            }
コード例 #3
0
        private IOrderedEnumerable <Type> GetWritersForCurrentContext(WriterScope scope,
                                                                      Func <TemplateSchemaWriterAttribute, Int32?> sortingSelector)
        {
            // Get all serializers to run in automated mode, ordered by sortingSelector
            var currentAssembly = this.GetType().Assembly;

            var writers = currentAssembly.GetTypes()
                          // Get all the writers
                          .Where(t => t.GetInterface(typeof(IPnPSchemaWriter).FullName) != null &&
                                 t.BaseType.Name == typeof(PnPBaseSchemaWriter <>).Name)
                          // Order the writers by sequence
                          .OrderBy(s =>
            {
                var a = s.GetCustomAttributes <TemplateSchemaWriterAttribute>(false).FirstOrDefault();
                if (a != null)
                {
                    return(a.WriterSequence);
                }
                return(0);
            }
                                   );

            return(writers);
        }
コード例 #4
0
ファイル: ViewPage.cs プロジェクト: jenrom/Spikes
            public IDisposable Scope(TextWriter writer)
            {
                WriterScope scope = new WriterScope(this, InnerWriter);

                if (writer != this) {
                    InnerWriter = writer;
                }

                return scope;
            }
コード例 #5
0
        private IOrderedEnumerable <IGrouping <string, Type> > GetSerializersForCurrentContext(WriterScope scope,
                                                                                               Func <TemplateSchemaWriterAttribute, Int32?> sortingSelector)
        {
            // Get all serializers to run in automated mode, ordered by sortingSelector
            var currentAssembly = this.GetType().Assembly;

            //PnP.Framework.Provisioning.Providers.Xml.XMLPnPSchemaVersion currentSchemaVersion = GetCurrentSchemaVersion();

            var serializers = currentAssembly.GetTypes()
                              // Get all the serializers
                              .Where(t => t.GetInterface(typeof(IPnPSchemaWriter).FullName) != null &&
                                     t.BaseType.Name == typeof(Xml.PnPBaseSchemaSerializer <>).Name)
                              // Filter out those that are not targeting the current schema version or that are not in scope Template
                              .Where(t =>
            {
                var a = t.GetCustomAttributes <TemplateSchemaWriterAttribute>(false).FirstOrDefault();
                return(a.Scope == scope);
            })
                              // Order the remainings by supported schema version descendant, to get first the newest ones
                              .OrderByDescending(s =>
            {
                var a = s.GetCustomAttributes <TemplateSchemaWriterAttribute>(false).FirstOrDefault();
                return(a.MinimalSupportedSchemaVersion);
            }
                                                 )
                              // Group those with the same target type (which is the first generic Type argument)
                              .GroupBy(t => t.BaseType.GenericTypeArguments.FirstOrDefault()?.FullName)
                              // Order the result by SerializationSequence
                              .OrderBy(g =>
            {
                var maxInGroup = g.OrderByDescending(s =>
                {
                    var a = s.GetCustomAttributes <TemplateSchemaWriterAttribute>(false).FirstOrDefault();
                    return(a.MinimalSupportedSchemaVersion);
                }
                                                     ).FirstOrDefault();
                return(sortingSelector(maxInGroup.GetCustomAttributes <TemplateSchemaWriterAttribute>(false).FirstOrDefault()));
            });

            return(serializers);
        }
コード例 #6
0
ファイル: ViewPage.cs プロジェクト: nobled/mono
            public IDisposable Scope(TextWriter writer) {
                WriterScope scope = new WriterScope(this, InnerWriter);

                try {
                    if (writer != this) {
                        InnerWriter = writer;
                    }

                    return scope;
                }
                catch {
                    scope.Dispose();
                    throw;
                }
            }