• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ImportContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ImportFromNumber

 protected override object ImportFromNumber(ImportContext context, JsonReader reader)
 {
     object obj2;
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     string text = reader.Text;
     try
     {
         obj2 = ImporterBase.ReadReturning(reader, this.ConvertFromString(text));
     }
     catch (FormatException exception)
     {
         throw this.NumberError(exception, text);
     }
     catch (OverflowException exception2)
     {
         throw this.NumberError(exception2, text);
     }
     return obj2;
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:26,代码来源:NumberImporterBase.cs


示例2: ImportFromObject

 protected override object ImportFromObject(ImportContext context, JsonReader reader)
 {
     reader.Read();
     object target = Activator.CreateInstance(base.OutputType);
     INonObjectMemberImporter importer = target as INonObjectMemberImporter;
     while (reader.TokenClass != JsonTokenClass.EndObject)
     {
         string name = reader.ReadMember();
         PropertyDescriptor descriptor = this._properties.Find(name, true);
         if ((descriptor == null) || descriptor.IsReadOnly)
         {
             if ((importer == null) || !importer.Import(context, name, reader))
             {
                 reader.Skip();
             }
         }
         else
         {
             if (this._importers != null)
             {
                 int index = this._properties.IndexOf(descriptor);
                 IObjectMemberImporter importer2 = this._importers[index];
                 if (importer2 != null)
                 {
                     importer2.Import(context, reader, target);
                     continue;
                 }
             }
             descriptor.SetValue(target, context.Import(descriptor.PropertyType, reader));
         }
     }
     return ImporterBase.ReadReturning(reader, target);
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:33,代码来源:ComponentImporter.cs


示例3: ImportFromNumber

 protected override object ImportFromNumber(ImportContext context, JsonReader reader)
 {
     double num;
     object obj2;
     string text = reader.Text;
     try
     {
         num = Convert.ToDouble(text, CultureInfo.InvariantCulture);
     }
     catch (FormatException exception)
     {
         throw NumberError(exception, text);
     }
     catch (OverflowException exception2)
     {
         throw NumberError(exception2, text);
     }
     try
     {
         obj2 = ImporterBase.ReadReturning(reader, UnixTime.ToDateTime(num));
     }
     catch (ArgumentException exception3)
     {
         throw NumberError(exception3, text);
     }
     return obj2;
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:27,代码来源:DateTimeImporter.cs


示例4: ImportFromString

 protected override object ImportFromString(ImportContext context, JsonReader reader)
 {
     object obj2;
     try
     {
         Match match = Regex.Match(reader.Text, @"\A \/ Date \( ([0-9]+) \) \/ \z", RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
         if (match.Success)
         {
             DateTime time;
             try
             {
                 time = UnixTime.ToDateTime((double) (((double) long.Parse(match.Groups[1].Value, NumberStyles.None, CultureInfo.InvariantCulture)) / 1000.0));
             }
             catch (OverflowException exception)
             {
                 throw StringError(exception);
             }
             return ImporterBase.ReadReturning(reader, time);
         }
         obj2 = ImporterBase.ReadReturning(reader, XmlConvert.ToDateTime(reader.Text, XmlDateTimeSerializationMode.Local));
     }
     catch (FormatException exception2)
     {
         throw StringError(exception2);
     }
     return obj2;
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:27,代码来源:DateTimeImporter.cs


示例5: ImportScalarAsArray

 private object ImportScalarAsArray(ImportContext context, JsonReader reader)
 {
     Type elementType = base.OutputType.GetElementType();
     Array array = Array.CreateInstance(elementType, 1);
     array.SetValue(context.Import(elementType, reader), 0);
     return array;
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:7,代码来源:ArrayImporter.cs


示例6: ImportValue

 protected override object ImportValue(ImportContext context, JsonReader reader)
 {
     if (reader == null)
         throw new ArgumentNullException("reader");
     
     bool value;
     
     if (reader.TokenClass == JsonTokenClass.Number)
     {
         try
         {
             value = Convert.ToInt64(reader.Text, CultureInfo.InvariantCulture) != 0;
         }
         catch (FormatException e)
         {
             throw new JsonException(string.Format("The JSON Number {0} must be an integer to be convertible to System.Boolean.", reader.Text), e);
         }
     }
     else if (reader.TokenClass == JsonTokenClass.Boolean)
     {
         value = reader.Text == JsonBoolean.TrueText;
     }
     else
     {
         throw new JsonException(string.Format("Found {0} where expecting a JSON Boolean.", reader.TokenClass));
     }
     
     return value ? BooleanObject.True : BooleanObject.False;
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:29,代码来源:BooleanImporter.cs


示例7: ImportFromNumber

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

            string text = reader.Text;

            double time;

            try
            {
                time = Convert.ToDouble(text, CultureInfo.InvariantCulture);
            }
            catch (FormatException e)
            {
                throw NumberError(e, text);
            }
            catch (OverflowException e)
            {
                throw NumberError(e, text);
            }

            try
            {
                return ReadReturning(reader, UnixTime.ToDateTime(time));
            }
            catch (ArgumentException e)
            {
                throw NumberError(e, text);
            }
        }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:31,代码来源:DateTimeImporter.cs


示例8: ImportFromBoolean

 protected override object ImportFromBoolean(ImportContext context, JsonReader reader)
 {
     Debug.Assert(context != null);
     Debug.Assert(reader != null);
     
     return BooleanObject.Box(reader.ReadBoolean());
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:7,代码来源:BooleanImporter.cs


示例9: Execute

		public void Execute()
		{
			this.result.CloseWindow = false;
			this.result.DataChanged = true;

			ImportContext context = new ImportContext(this);

			if (this.EnsureFileLoaded())
			{
				this.actionIndex = 0;
				foreach (var action in this.actions)
				{
					try
					{
						action.DoImport(this.objectSet, context);
					}
					catch (Exception ex)
					{
						this.log.AppendFormat("发生错误:{0} 已终止了操作,堆栈:\r\n{1}\r\n", ex.Message, ex.StackTrace);
						break;
					}

					this.actionIndex++;
				}
			}

			this.log.AppendLine("导入操作结束");
			this.status.CurrentStep = this.status.MaxStep;
			this.status.StatusText = "结束";
			this.status.Response();
			this.result.ProcessLog = this.log.ToString();
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:32,代码来源:ImportExecutor.cs


示例10: ImportValue

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

            if (reader == null)
                throw new ArgumentNullException("reader");
            
            if (reader.TokenClass != JsonTokenClass.Number && reader.TokenClass != JsonTokenClass.String)
                throw new JsonException(string.Format("Found {0} where expecting a number.", reader.TokenClass));

            string text = reader.Text;
            
            try
            {
                return ConvertFromString(text);
            }
            catch (FormatException e)
            {
                throw NumberError(e, text);
            }
            catch (OverflowException e)
            {
                throw NumberError(e, text);
            }
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:26,代码来源:NumberImporter.cs


示例11: ImportFromString

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

            return ReadReturning(reader, reader.Text);
        }
开发者ID:liuxing7954,项目名称:cangku_1,代码行数:7,代码来源:StringImporter.cs


示例12: ImportFromObject

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

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

            //
            // Reader must be sitting on an object.
            //

            if (reader.TokenClass != JsonTokenClass.Object)
                throw new JsonException("Expecting object.");

            reader.Read();

            //
            // Create the NameValueCollection object being deserialized.
            // If a hint was supplied, then that's what we will create
            // here because it could be that the caller wants to
            // return a subtype of NameValueCollection.
            //

            NameValueCollection collection = CreateCollection();

            //
            // Loop through all members of the object.
            //

            while (reader.TokenClass != JsonTokenClass.EndObject)
            {
                string name = reader.ReadMember();

                //
                // If the value is an array, then it's a multi-value
                // entry otherwise a single-value one.
                //

                if (reader.TokenClass == JsonTokenClass.Array)
                {
                    reader.Read();

                    while (reader.TokenClass != JsonTokenClass.EndArray)
                    {
                        collection.Add(name, GetValueAsString(reader));
                        reader.Read();
                    }
                }
                else
                {
                    collection.Add(name, GetValueAsString(reader));
                }

                reader.Read(); // EndArray/String
            }

            return ReadReturning(reader, collection);
        }
开发者ID:GroupXTech,项目名称:Yatse2,代码行数:59,代码来源:NameValueCollectionImporter.cs


示例13: CreateObject

 public void CreateObject()
 {
     ObjectSurrogateConstructor ctor = new ObjectSurrogateConstructor(typeof(Surrogate));
     ImportContext context = new ImportContext();
     ObjectConstructionResult result = ctor.CreateObject(context, JsonText.CreateReader("{y:2000,m:12,d:4}"));
     Assert.IsNotNull(result);
     Assert.AreEqual(new DateTime(2000, 12, 4), result.Object);
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:8,代码来源:TestObjectSurrogateConstructor.cs


示例14: ImportFromObject

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

            reader.Read();
            
            object obj = Activator.CreateInstance(OutputType);
            INonObjectMemberImporter otherImporter = obj as INonObjectMemberImporter;
            
            while (reader.TokenClass != JsonTokenClass.EndObject)
            {
                string memberName = reader.ReadMember();
               
                PropertyDescriptor property = _properties.Find(memberName, true);
                
                //
                // Skip over the member value and continue with reading if
                // the property was not found or if the property found cannot
                // be set.
                //
                
                if (property == null || property.IsReadOnly)
                {
                    if (otherImporter == null || !otherImporter.Import(context, memberName, reader))
                        reader.Skip();
                    continue;
                }
                
                //
                // Check if the property defines a custom import scheme.
                // If yes, ask it to import the value into the property 
                // and then continue with the next.
                //
                
                if (_importers != null)
                {
                    int index = _properties.IndexOf(property);
                    
                    IObjectMemberImporter importer = _importers[index];
                    
                    if (importer != null)
                    {
                        importer.Import(context, reader, obj);
                        continue;
                    }
                }
                    
                //
                // Import from reader based on the property type and 
                // then set the value of the property.
                //
                
                property.SetValue(obj, context.Import(property.PropertyType, reader));
            }
         
            return ReadReturning(reader, obj);
        }
开发者ID:Ghawken,项目名称:FrontView,代码行数:58,代码来源:ComponentImporter.cs


示例15: Import

 public virtual object Import(ImportContext context, JsonReader reader)
 {
     if (context == null) 
         throw new ArgumentNullException("context");
     if (reader == null) 
         throw new ArgumentNullException("reader");
     
     return JsonBuffer.From(reader);
 }
开发者ID:db48x,项目名称:KeeFox,代码行数:9,代码来源:JsonBufferImporter.cs


示例16: ImportData

		protected override void ImportData(System.Xml.XmlNode fieldNode, ImportContext context)
		{
			if (String.IsNullOrEmpty(fieldNode.InnerXml))
			{
				this.SetData(null);
				return;
			}
			this.SetData(ConvertTo(new object[] { fieldNode.InnerXml }));
		}
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:9,代码来源:HyperLinkField.cs


示例17: AssertImport

 private static void AssertImport(object expected, string input)
 {
     JsonTextReader reader = new JsonTextReader(new StringReader(input));
     Type expectedType = expected.GetType();
     ImportContext context = new ImportContext();
     object o = context.Import(expectedType, reader);
     Assert.IsInstanceOfType(expectedType, o);
     Assert.AreEqual(expected, o);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:9,代码来源:TestNumberImporter.cs


示例18: ImportFromArray

        protected override object ImportFromArray(ImportContext context, JsonReader reader)
        {
            if (_single)
                return _importer(context, reader);

            reader.Read();
            var result = _importer(context, reader);
            reader.ReadToken(JsonTokenClass.EndArray);
            return result;
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:10,代码来源:TupleImporter.cs


示例19: ImportData

		protected override void ImportData(System.Xml.XmlNode fieldNode, ImportContext context)
		{
			if (String.IsNullOrEmpty(fieldNode.InnerXml))
			{
				this.SetData(ActiveSchema.DateTimeMinValue);
				return;
			}
			DateTime value = Convert.ToDateTime(fieldNode.InnerXml);
			this.SetData(value < ActiveSchema.DateTimeMinValue ? ActiveSchema.DateTimeMinValue : value);
		}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:10,代码来源:DateTimeField.cs


示例20: ImportFromArray

 protected override object ImportFromArray(ImportContext context, JsonReader reader)
 {
     reader.Read();
     MemoryStream stream = new MemoryStream();
     Type type = typeof(byte);
     while (reader.TokenClass != JsonTokenClass.EndArray)
     {
         stream.WriteByte((byte) context.Import(type, reader));
     }
     return ImporterBase.ReadReturning(reader, stream.ToArray());
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:11,代码来源:ByteArrayImporter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Importer类代码示例发布时间:2022-05-24
下一篇:
C# Import类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap