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


C# Conversion.ImportContext类代码示例

本文整理汇总了C#中Jayrock.Json.Conversion.ImportContext的典型用法代码示例。如果您正苦于以下问题:C# ImportContext类的具体用法?C# ImportContext怎么用?C# ImportContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ImportFromString

        protected override object ImportFromString(ImportContext context, JsonReader reader)
        {
            Debug.Assert(context != null);
            Debug.Assert(reader != null);

            string s = reader.Text.Trim();

            if (s.Length > 0)
            {
                char ch = s[0];

                if (Char.IsDigit(ch) || ch == '+' || ch == '-')
                    throw Error(s, null);
            }

            try
            {
                return ReadReturning(reader, Enum.Parse(OutputType, s, true));
            }
            catch (ArgumentException e)
            {
                //
                // Value is either an empty string ("") or only contains
                // white space. Value is a name, but not one of the named
                // constants defined for the enumeration.
                //

                throw Error(s, e);
            }
        }
开发者ID:GroupXTech,项目名称:Yatse2,代码行数:30,代码来源:EnumImporter.cs

示例2: Registration

 public void Registration()
 {
     ImportContext context = new ImportContext();
     ThingImporter importer = new ThingImporter();
     context.Register(importer);
     Assert.AreSame(importer, context.FindImporter(typeof(Thing)));
 }
开发者ID:bubbafat,项目名称:Hebo,代码行数:7,代码来源:TestImportContext.cs

示例3: AssertInStock

 private static void AssertInStock(Type expected, Type type)
 {
     ImportContext context = new ImportContext();
     IImporter importer = context.FindImporter(type);
     Assert.IsNotNull(importer, "No importer found for {0}", type.FullName);
     Assert.IsInstanceOfType(expected, importer, type.FullName);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:7,代码来源:TestImportContext.cs

示例4: CreateObject

        public ObjectConstructionResult CreateObject(ImportContext context, JsonReader reader)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (reader == null) throw new ArgumentNullException("reader");

            return CreateObject(context, JsonBuffer.From(reader).GetMembersArray());
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:7,代码来源:ObjectConstructor.cs

示例5: RegistrationIsPerContext

 public void RegistrationIsPerContext()
 {
     ImportContext context = new ImportContext();
     ThingImporter exporter = new ThingImporter();
     context.Register(exporter);
     context = new ImportContext();
     Assert.AreNotSame(exporter, context.FindImporter(typeof(Thing)));
 }
开发者ID:bubbafat,项目名称:Hebo,代码行数:8,代码来源:TestImportContext.cs

示例6: TransportComponent

        private TransportComponent()
        {
            JsonExportContext = JsonConvert.CreateExportContext();
              JsonExportContext.Register(new TransportMessageExporter());

              JsonImportContext = JsonConvert.CreateImportContext();
              JsonImportContext.Register(new TransportMessageImporter());

              TransportListeners.Add(this);
        }
开发者ID:hcilab-um,项目名称:tPad,代码行数:10,代码来源:TransportComponent.cs

示例7: Import

 public object Import(ImportContext context, Jayrock.Json.JsonReader reader)
 {
     ActiveReaderMessage arMessage = null;
       Dispatcher.Invoke(DispatcherPriority.Background,
     (Action)delegate()
     {
       arMessage = (ActiveReaderMessage)context.Import<ActiveReaderMessage>(reader); ;
     });
       return arMessage;
 }
开发者ID:hcilab-um,项目名称:tPad,代码行数:10,代码来源:ActiveReaderMessageImporter.cs

示例8: CreateObject

        public virtual ObjectConstructionResult CreateObject(ImportContext context, JsonReader reader)
        {
            if (context == null) 
                throw new ArgumentNullException("context");
            if (reader == null) 
                throw new ArgumentNullException("reader");

            IObjectSurrogateConstructor ctor = (IObjectSurrogateConstructor) context.Import(_surrogateType, reader);
            return ctor.CreateObject(context);
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:10,代码来源:ObjectSurrogateConstructor.cs

示例9: ReflectImport

        private object ReflectImport(ImportContext context, JsonReader reader)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            if (reader == null)
                throw new ArgumentNullException("reader");

            IJsonImportable o = CreateObject();
            o.Import(context, reader);
            return o;
        }
开发者ID:GroupXTech,项目名称:Yatse2,代码行数:12,代码来源:ImportAwareImporter.cs

示例10: CreateObject

        public virtual ObjectConstructionResult CreateObject(ImportContext context)
        {
            if (context == null) throw new ArgumentNullException("context");

            JsonBufferWriter tailw = _tailw;
            _tailw = null;
            if (tailw != null)
                tailw.WriteEndObject();
            JsonBuffer tail = (tailw != null ? tailw.GetBuffer() : StockJsonBuffers.EmptyObject);
            object obj = OnCreateObject(context);
            return new ObjectConstructionResult(obj, tail.CreateReader());
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:12,代码来源:ObjectSurrogateConstructorBase.cs

示例11: Import

        /// <summary>
        /// The import.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="reader">
        /// The reader.
        /// </param>
        /// <returns>
        /// The import.
        /// </returns>
        public object Import(ImportContext context, JsonReader reader)
        {
            // var properties = new EvolutionaryProperties();
            // reader.StepOut();
            // JsonToken token = reader.Token;
            this.properties = new EvolutionaryProperties();

            PropertyValue[] o = context.Import<PropertyValue[]>(reader);
            this.SetProperties(o);

            return this.properties;
        }
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:24,代码来源:PropertiesImporter.cs

示例12: ImportFromArray

        protected override object ImportFromArray(ImportContext context, JsonReader reader)
        {
            Debug.Assert(context != null);
            Debug.Assert(reader != null);

            reader.Read();

            ArrayList list = new ArrayList();
            Type elementType = OutputType.GetElementType();

            while (reader.TokenClass != JsonTokenClass.EndArray)
                list.Add(context.Import(elementType, reader));

            return ReadReturning(reader, list.ToArray(elementType));
        }
开发者ID:RyanWangTHU,项目名称:ccv2,代码行数:15,代码来源:ArrayImporter.cs

示例13: Import

        public virtual bool Import(ImportContext context, string name, JsonReader reader)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (reader == null) throw new ArgumentNullException("reader");

            JsonBufferWriter tailw = _tailw;
            if (tailw == null)
            {
                tailw = _tailw = new JsonBufferWriter();
                tailw.WriteStartObject();
            }
            tailw.WriteMember(name);
            tailw.WriteFromReader(reader);
            return true;
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:15,代码来源:ObjectSurrogateConstructorBase.cs

示例14: ImportElements

        protected override void ImportElements(object collection, ImportContext context, JsonReader reader)
        {
            if (collection == null) throw new ArgumentNullException("collection");
            if (context == null) throw new ArgumentNullException("context");
            if (reader == null) throw new ArgumentNullException("reader");

            object[] args = null;
            while (reader.TokenClass != JsonTokenClass.EndArray)
            {
                if (args == null)           // on-demand
                    args = new object[1];

                args[0] = context.Import(ElementType, reader);
                InvokeAdd(collection, args);
            }
        }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:16,代码来源:DuckCollectionImporterBase.cs

示例15: ImportFromArray

        protected override object ImportFromArray(ImportContext context, JsonReader reader)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (reader == null) throw new ArgumentNullException("reader");

            object collection = CreateCollection();

            reader.ReadToken(JsonTokenClass.Array);

            ImportElements(collection, context, reader);

            if (reader.TokenClass != JsonTokenClass.EndArray)
                throw new Exception("Implementation error.");

            reader.Read();
            return collection;
        }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:17,代码来源:CollectionImporterBase.cs


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