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


C# XObject类代码示例

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


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


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