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

C# XObject类代码示例

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

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



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

示例1: Parse

 public object Parse(Type type, XObject config, bool isAssignableTypeAllowed, XmlLocation childLocation, IContext context)
 {
     var xel = config as XElement;
     if (xel == null)
         throw new TestLibsException($"Couldn't cast following config to XElement:\n{config}");
     return xel;
 }
开发者ID:IIITanbI,项目名称:2,代码行数:7,代码来源:XElementParser.cs


示例2: GetNodeCount

 public int? GetNodeCount(XObject xml, string xpath)
 {
     if(xml == null)
     {
         return null;
     }
     if(xml.Document == null)
     {
         return null;
     }
     if(xml.Document.Root == null)
     {
         return null;
     }
     try
     {
         var namespaceResolver = new SimpleXmlNamespaceResolver(xml.Document);
         var results = (IEnumerable)xml.Document.XPathEvaluate(xpath, namespaceResolver);
         return results.OfType<XObject>().Count();
     }
     catch(Exception)
     {
         return null;
     }
 }
开发者ID:uli-weltersbach,项目名称:XPathInformation,代码行数:25,代码来源:XmlRepository.cs


示例3: Select

        public ISerializer Select(IMemberContext source, XObject target, IAdviceRequester adviceRequester)
        {
            if (target.NodeType != XmlNodeType.Element)
                return null;

            return _serializer;
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:RecursiveSerializerSelector.cs


示例4: AreEqual

        public static void AreEqual(XObject expected, XObject actual)
        {
            if (expected is XDocument)
            {
                expected = ((XDocument)expected).Root;
            }
            if (actual is XDocument)
            {
                actual = ((XDocument)actual).Root;
            }

            if (expected == null && actual == null)
            {
                return;
            }
            if (expected == null)
            {
                RaiseAssertFailure(null, actual);
                return;
            }
            if (actual == null)
            {
                RaiseAssertFailure(expected, null);
                return;
            }
            if (expected.GetType() != actual.GetType())
            {
                RaiseAssertFailure(expected, actual);
                return;
            }

            AssertEqualValues(expected, actual);
        }
开发者ID:bitserf,项目名称:xmapper,代码行数:33,代码来源:XAssert.cs


示例5: ParseDefinitionFileException

 public ParseDefinitionFileException(string message, XObject source) 
     : base(GetMessage(message, source))
 {
     _source = source;
     Line = (source as IXmlLineInfo).LineNumber;
     Position = (source as IXmlLineInfo).LinePosition;
 }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:7,代码来源:ParseDefinitionFileException.cs


示例6: Deserialize

        public void Deserialize(XObject source, IMemberContext target, IAdviceRequester adviceRequester)
        {
            if (source == null)
                return;

            if (source.NodeType != XmlNodeType.Element)
                throw new ArgumentException("Parameter must be an XML element.", "source");

            if (_log.IsDebugEnabled)
                _log.Debug("Deserializing " + source.ToFriendlyName() + " into " + target + ".");

            var elem = (XElement)source;

            Type targetType = _typeConverter.GetActualType(source, target, adviceRequester);
            if (targetType == null)
                throw new ArgumentException("Unable to get target type for target '" + target + "'.");

            IObjectContext targetObject = _objectContextFactory.CreateForDeserialization(target, targetType, adviceRequester);
            if (targetObject == null)
                throw new ArgumentException("Unable to create target object for target '" + target + "'.");

            target.SetValue(targetObject);

            List<IMapping<XObject, IMemberContext>> mappings = _mapper.MapForDeserialization(elem, target, adviceRequester)
                .ToList();
            if (mappings == null)
                throw new ArgumentException("Unable to map source '" + source + "' and target '" + target + "'.");

            DeserializeRecursively(mappings, adviceRequester);

            target.CommitChanges();
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:32,代码来源:RecursiveDeserializer.cs


示例7: EventsHelper

 public EventsHelper(XObject x)
 {
     _root = x;
     _root.Changing += new EventHandler<XObjectChangeEventArgs>(Changing);
     _root.Changed += new EventHandler<XObjectChangeEventArgs>(Changed);
     _events = new Queue<EventItem>();
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:EventsHelper.cs


示例8: AddSubcomponent

        public override void AddSubcomponent(string name, XObject sub)
        {
			if (this.Levels == null)
				this.Levels = new List<XLevelInfo>();
            
			this.Levels.Add((XLevelInfo)sub);
		}
开发者ID:valsavva,项目名称:dynacat,代码行数:7,代码来源:XLevelSeries.cs


示例9: Select

        protected virtual IDeserializer Select(XObject source, IMemberContext target, Type type, IAdviceRequester adviceRequester)
        {
            var typeCode = Type.GetTypeCode(type);

            switch (typeCode)
            {
                case TypeCode.Empty:
                case TypeCode.DBNull:
                    return null;
                case TypeCode.Object:
                    if (target.ContractType == typeof(TimeSpan))
                        break;
                    if (target.ContractType == typeof(string))
                        break;
                    if (target.ContractType.IsNullable())
                        break;

                    return null;
            }

            if (source == null)
                return GetDeserializer(type);

            if (source.NodeType == XmlNodeType.Element && !((XElement)source).HasElements)
                return GetDeserializer(type);

            if (source.NodeType == XmlNodeType.Attribute)
                return GetDeserializer(type);

            return null;
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:31,代码来源:ValueTypeDeserializerSelector.cs


示例10: FindObject

 private XObject FindObject(string id, XObject root)
 {
     var o = root.FindLocal(id);
     if (o == null)
         throw new InvalidOperationException(string.Format("Iterator '{0}' could not find obect id: '{1}'", this.Id, id));
     return o;
 }
开发者ID:valsavva,项目名称:dynacat,代码行数:7,代码来源:XIterator.cs


示例11: Select

 public IDeserializer Select(XObject source, IMemberContext target, IAdviceRequester adviceRequester)
 {
     return Selectors
             .Select(s => s.Select(source, target, adviceRequester))
             .Where(d => d != null)
             .FirstOrDefault();
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:CompositeDeserializerSelector.cs


示例12: Binding

 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="xml"></param>
 /// <param name="context"></param>
 /// <param name="xpath"></param>
 internal Binding(XObject xml, EvaluationContext context, string xpath)
     : this(xml, context, context.CompileXPath(xml, xpath))
 {
     Contract.Requires<ArgumentNullException>(xml != null);
     Contract.Requires<ArgumentNullException>(context != null);
     Contract.Requires<ArgumentNullException>(xpath != null);
 }
开发者ID:nxkit,项目名称:nxkit,代码行数:13,代码来源:Binding.cs


示例13: setRoot

 private void setRoot(XObject root)
 {
     if (root is XDocument)
         _current = ((XDocument)root).Root;
     else
         _current = root;
 }
开发者ID:ranjancse26,项目名称:fhir-net-api,代码行数:7,代码来源:XmlDomFhirReader.cs


示例14: GetActualType

 public Type GetActualType(XObject source, IMemberContext target, IAdviceRequester adviceRequester)
 {
     return Converters
             .Select(c => c.GetActualType(source, target, adviceRequester))
             .Where(t => t != null)
             .FirstOrDefault();
 }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:7,代码来源:CompositeTypeConverter.cs


示例15: CopyAttributes

		public void CopyAttributes(XObject src, XObject dest)
		{
			dest.Id = src.Id;
			//dest.Class = src.Class;
			
			dest.Enabled = src.Enabled;
			
			// Element
			var srcElement = src as XElement;
			if (srcElement != null)
			{
				var destElement = (XElement)dest;
				
				destElement.Bounds = srcElement.Bounds;
				
				if (srcElement.backColor.HasValue)
					destElement.BackColor = srcElement.BackColor;

				if (srcElement.Rotation != 0)
					destElement.Rotation = srcElement.Rotation;
			}
			
			// IHasPoints
			var srcHasPoints = src as IHasPoints;
			if (srcHasPoints != null && srcHasPoints.Points != 0)
			{
				((IHasPoints)dest).Points = srcHasPoints.Points;
			}
			
			var srcEnemy = src as XEnemy;
			if (srcEnemy != null && srcEnemy.DamageSpecified)
			{
				((XEnemy)dest).Damage = srcEnemy.Damage;
			}
		}
开发者ID:valsavva,项目名称:dynacat,代码行数:35,代码来源:XClass.cs


示例16: BindLiteralOrReference

        public static bool BindLiteralOrReference(ParserContext context, XObject xmlObject, string xmlValue, PropertyInfo boundProperty)
        {
            object convertedLiteralValue;

            if (LiteralTypeConverter.TryConvert(boundProperty.PropertyType, xmlValue, out convertedLiteralValue))
            {
                if (BindExpression(context, xmlObject, xmlValue, boundProperty))
                {
                    return true;
                }
             
                BindFinalValue(boundProperty, context.FrameworkItem, convertedLiteralValue, xmlObject, true);
                return true;
            }

            if (xmlObject is XAttribute)
            {
                if (BindExpression(context, xmlObject, xmlValue, boundProperty))
                {
                    return true;
                }

                DelayedBind(context, xmlObject, xmlValue, boundProperty);
                return true;
            }

            return false;
        }
开发者ID:japj,项目名称:vulcan,代码行数:28,代码来源:PropertyBinder.cs


示例17: CreateInstance

		public XObject CreateInstance(XObject placeholder)
		{
			var instance = TemplateObject.Copy();
			CopyAttributes(placeholder, instance);
			
			// move subcomponents from the placeholder to the new instance
			while(placeholder.Subcomponents != null && placeholder.Subcomponents.Count > 0)
			{
				var subcomponent = placeholder.Subcomponents[0];
				placeholder.Subcomponents.RemoveAt(0);
				
				instance.Subcomponents.Add(subcomponent);
			}

			var parent = placeholder.Parent;
			
			// replace the placeholder with the new instance
			int instanceIndex = parent.Subcomponents.IndexOf(placeholder);
			parent.Subcomponents.RemoveAt(instanceIndex);
			parent.Subcomponents.Insert(instanceIndex, instance);
			
			ReplaceParameters(instance, placeholder.ClassParams);
			
			return instance;
		}
开发者ID:valsavva,项目名称:dynacat,代码行数:25,代码来源:XClass.cs


示例18: InstantOrNull

        public static DateTimeOffset? InstantOrNull(XObject elem)
        {
            string value = StringValueOrNull(elem);

            return String.IsNullOrEmpty(value) ? (DateTimeOffset?)null : 
                PrimitiveTypeConverter.ConvertTo<DateTimeOffset>(value);
        }
开发者ID:tiloc,项目名称:fhir-net-api,代码行数:7,代码来源:SerializationUtil.cs


示例19: Serialize

        public bool Serialize(IMemberContext source, XObject target, IAdviceRequester adviceRequester)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (target.NodeType != XmlNodeType.Element)
                throw new ArgumentException("Parameter must be an XML element.", "target");

            var elem = (XElement)target;

            IObjectContext sourceObject = source.GetValue();

            if (sourceObject == null || sourceObject.GetObject() == null)
            {
                if (_isNullableStrategy.IsNullable(source, elem, adviceRequester))
                {
                    elem.Add(Constants.XsiNilAttribute);
                    return true;
                }

                return false;
            }

            List<IMapping<IMemberContext, XObject>> mappings = _mapper.MapForSerialization(source, elem, adviceRequester)
                .ToList();
            if (mappings == null)
                throw new ArgumentException("Unable to map source '" + source + "' and target '" + target + "'.");

            SerializeRecursively(elem, mappings, adviceRequester);

            return true;
        }
开发者ID:kimbirkelund,项目名称:SekhmetSerialization,代码行数:31,代码来源:RecursiveSerializer.cs


示例20: CanExecute

 internal Tuple<bool, bool> CanExecute(
     XObject selectedElement, object docView, object singleViewModelSelection, object propertiesCompartment, bool isSingleSelection)
 {
     return _canExecute == null
                ? new Tuple<bool, bool>(true, true)
                : _canExecute(selectedElement, docView, singleViewModelSelection, propertiesCompartment, isSingleSelection);
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:EntityDesignerCommand.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# XPClassInfo类代码示例发布时间:2022-05-24
下一篇:
C# XNode类代码示例发布时间: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