当前位置: 首页>>代码示例>>C#>>正文


C# ExportContext.Export方法代码示例

本文整理汇总了C#中ExportContext.Export方法的典型用法代码示例。如果您正苦于以下问题:C# ExportContext.Export方法的具体用法?C# ExportContext.Export怎么用?C# ExportContext.Export使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExportContext的用法示例。


在下文中一共展示了ExportContext.Export方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportValue

        protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(value != null);
            Debug.Assert(writer != null);
            
            if (_properties.Count == 0)
            {
                writer.WriteString(value.ToString());
            }
            else
            {
                writer.WriteStartObject();

                foreach (PropertyDescriptor property in _properties)
                {
                    object propertyValue = property.GetValue(value);
                
                    if (!JsonNull.LogicallyEquals(propertyValue))
                    {
                        writer.WriteMember(property.Name);
                        context.Export(propertyValue, writer);
                    }
                }

                writer.WriteEndObject();
            }
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:28,代码来源:ComponentExporter.cs

示例2: ExportValue

        protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(value != null);
            Debug.Assert(writer != null);

            context.Export(value, writer);
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:8,代码来源:NullableExporter.cs

示例3: TableExportedViaDataView

        public void TableExportedViaDataView()
        {
            DataTable table = new DataTable();

            ExportContext context = new ExportContext();
            TestDataViewExporter exporter = new TestDataViewExporter();
            context.Register(exporter);
            context.Export(table, new JsonRecorder());

            Assert.AreSame(table.DefaultView, exporter.LastExported);
        }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:11,代码来源:TestDataTableExporter.cs

示例4: TableExportedViaItsExporter

        public void TableExportedViaItsExporter()
        {
            DataSet ds = new DataSet();
            ds.Tables.Add(new DataTable("Table1"));

            ExportContext context = new ExportContext();
            TestDataTableExporter exporter = new TestDataTableExporter();
            context.Register(exporter);
            context.Export(ds, new JsonRecorder());

            Assert.AreSame(ds.Tables[0], exporter.LastExported);
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:12,代码来源:TestDataSetExporter.cs

示例5: ExportMembers

        private static void ExportMembers(ExportContext context, IEnumerable<KeyValuePair<string, object>> members, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(members != null);
            Debug.Assert(writer != null);

            foreach (var member in members)
            {
                writer.WriteMember(member.Key);
                context.Export(member.Value, writer);
            }
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:12,代码来源:ExpandoObjectExporter.cs

示例6: ExportView

        internal static void ExportView(ExportContext context, DataView view, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(view != null);
            Debug.Assert(writer != null);

            writer.WriteStartObject();

            writer.WriteMember("columns");

            writer.WriteStartArray();
            foreach (DataColumn column in view.Table.Columns)
                context.Export(column.ColumnName, writer);
            writer.WriteEndArray();

            writer.WriteMember("rows");

            writer.WriteStartArray();
            foreach (DataRowView row in view)
                context.Export(row.Row.ItemArray, writer);
            writer.WriteEndArray();

            writer.WriteEndObject();
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:24,代码来源:DataViewExporter.cs

示例7: ExportValue

        protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(value != null);
            Debug.Assert(writer != null);

            IEnumerable items = (IEnumerable) value;
            
            writer.WriteStartArray();

            foreach (object item in items)
                context.Export(item, writer);

            writer.WriteEndArray();
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:15,代码来源:EnumerableExporter.cs

示例8: ExportCollection

        private static void ExportCollection(ExportContext context, NameValueCollection collection, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(collection != null);
            Debug.Assert(writer != null);

            writer.WriteStartObject();

            for (int i = 0; i < collection.Count; i++)
            {
                writer.WriteMember(collection.GetKey(i));

                string[] values = collection.GetValues(i);

                if (values == null)
                    writer.WriteNull();
                else if (values.Length > 1)
                    context.Export(values, writer);
                else
                    context.Export(values[0], writer);
            }

            writer.WriteEndObject();
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:24,代码来源:NameValueCollectionExporter.cs

示例9: ExportRow

        internal static void ExportRow(ExportContext context, DataRow row, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(row != null);
            Debug.Assert(writer != null);

            writer.WriteStartObject();
    
            foreach (DataColumn column in row.Table.Columns)
            {
                writer.WriteMember(column.ColumnName);
                context.Export(row[column], writer);
            }
    
            writer.WriteEndObject();
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:16,代码来源:DataRowExporter.cs

示例10: ExportRecord

        internal static void ExportRecord(ExportContext context, ICustomTypeDescriptor record, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(record != null);
            Debug.Assert(writer != null);
            
            writer.WriteStartObject();
                        
            foreach (PropertyDescriptor property in record.GetProperties())
            {
                writer.WriteMember(property.Name);
                context.Export(property.GetValue(record), writer);
            }

            writer.WriteEndObject();
        }
开发者ID:RyanWangTHU,项目名称:ccv2,代码行数:16,代码来源:DbDataRecordExporter.cs

示例11: ExportValue

        protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(value != null);
            Debug.Assert(writer != null);

            writer.WriteStartObject();
            
            IDictionary dictionary = (IDictionary) value;
            
            foreach (DictionaryEntry entry in DictionaryHelper.GetEntries(dictionary))
            {
                writer.WriteMember(entry.Key.ToString());
                context.Export(entry.Value, writer);
            }

            writer.WriteEndObject();
        }
开发者ID:RyanWangTHU,项目名称:ccv2,代码行数:18,代码来源:DictionaryExporter.cs

示例12: ExportValue

        protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(value != null);
            Debug.Assert(writer != null);

            writer.WriteStartObject();
            
            IDictionary dictionary = (IDictionary) value;
            
            foreach (DictionaryEntry entry in dictionary)
            {
                writer.WriteMember(entry.Key.ToString());
                context.Export(entry.Value, writer);
            }

            /*
             FIXME: Use IDictionaryEnumerator.Entry instead and enumerate manually (faster and more robust).
             It is faster because unboxing is avoided by going over
             IDictionaryEnumerator.Entry rather than 
             IDictionaryEnumerator.Current. It is more robust because many 
             people may get the implementation of IDictionary.GetEnumerator 
             wrong, especially if they are implementing IDictionary<K, V> in 
             2.0. If they simply return the enumerator from the wrapped
             dictionary then Current will return KeyValuePair<K, V> instead
             of DictionaryEntry and therefore cause a casting exception.
             
            using (IDictionaryEnumerator e = dictionary.GetEnumerator())
            {            
                while (e.MoveNext())
                {
                    writer.WriteMember(e.Entry.Key.ToString());
                    context.Export(e.Entry.Value, writer);
                }
            }
            */

            writer.WriteEndObject();
        }
开发者ID:liuxing7954,项目名称:cangku_1,代码行数:39,代码来源:DictionaryExporter.cs

示例13: ExportValue

        protected override void ExportValue(ExportContext context, object value, JsonWriter writer)
        {
            Debug.Assert(context != null);
            Debug.Assert(value != null);
            Debug.Assert(writer != null);
            
            if (_properties.Count == 0)
            {
                writer.WriteString(value.ToString());
            }
            else
            {
                ObjectReferenceTracker tracker = null;
                
                try
                {
                    writer.WriteStartObject();
                    
                    int index = 0;

                    foreach (PropertyDescriptor property in _properties)
                    {
                        IObjectMemberExporter exporter = _exporters != null && index < _exporters.Length ? 
                            _exporters[index] : null;
                        
                        if (exporter != null)
                        {
                            exporter.Export(context, writer, value);
                        }
                        else
                        {
                            object propertyValue = property.GetValue(value);
                
                            if (!JsonNull.LogicallyEquals(propertyValue))
                            {
                                writer.WriteMember(property.Name);

                                if (tracker == null)
                                {
                                    //
                                    // We are about to enter a deeper scope so 
                                    // start tracking the current object being 
                                    // exported. This will help to detect 
                                    // recursive references that may occur 
                                    // through this exporter deeper in the tree.
                                    //
                                
                                    tracker = TrackObject(context, value);
                                }

                                context.Export(propertyValue, writer);
                            }
                        }
                    }

                    writer.WriteEndObject();
                }
                finally
                {
                    if (tracker != null)
                        tracker.Pop(value);
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:64,代码来源:ComponentExporter.cs

示例14: MemberExportCustomization

        public void MemberExportCustomization()
        {
            ArrayList calls = new ArrayList();

            TestTypeDescriptor logicalType = new TestTypeDescriptor();
            PropertyDescriptorCollection properties = logicalType.GetProperties();

            Hashtable services;

            TestObjectMemberExporter memexp1 = new TestObjectMemberExporter(calls);
            services = new Hashtable();
            services.Add(typeof(IObjectMemberExporter), memexp1);
            properties.Add(new TestPropertyDescriptor("prop1", services));

            TestObjectMemberExporter memexp2 = new TestObjectMemberExporter(calls);
            services = new Hashtable();
            services.Add(typeof(IObjectMemberExporter), memexp2);
            properties.Add(new TestPropertyDescriptor("prop2", services));

            ComponentExporter exporter = new ComponentExporter(typeof(Thing), logicalType);
            ExportContext context = new ExportContext();
            context.Register(exporter);

            JsonRecorder writer = new JsonRecorder();
            Thing thing = new Thing();
            context.Export(thing, writer);

            Assert.AreEqual(2, calls.Count);

            object[] args = { context, writer, thing };

            Assert.AreSame(memexp1, calls[0]);
            Assert.AreEqual(args, ((TestObjectMemberExporter) calls[0]).ExportArgs);

            Assert.AreSame(memexp2, calls[1]);
            Assert.AreEqual(args, ((TestObjectMemberExporter) calls[1]).ExportArgs);
        }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:37,代码来源:TestComponentExporter.cs

示例15: MemberExportCustomization

        public void MemberExportCustomization()
        {
            TestObjectMemberExporter memberExporter = new TestObjectMemberExporter();
            Hashtable services = new Hashtable();
            services.Add(typeof(IObjectMemberExporter), memberExporter);

            TestTypeDescriptor logicalType = new TestTypeDescriptor();
            PropertyDescriptorCollection properties = logicalType.GetProperties();
            properties.Add(new TestPropertyDescriptor("prop", services));
            
            ComponentExporter exporter = new ComponentExporter(typeof(Thing), logicalType);
            ExportContext context = new ExportContext();
            context.Register(exporter);
            
            JsonRecorder writer = new JsonRecorder();
            Thing thing = new Thing();
            context.Export(thing, writer);
            
            Assert.AreSame(context, memberExporter.ExportContext);
            Assert.AreSame(writer, memberExporter.ExportWriter);
            Assert.AreSame(thing, memberExporter.ExportSource);
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:22,代码来源:TestComponentExporter.cs


注:本文中的ExportContext.Export方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。