Inheritance: MemberSpec
Ejemplo n.º 1
0
 public PropertyValueDeserializerNode(IDeserializerNode parent, PropertySpec property)
 {
     Parent = parent;
     Property = property;
     ValueType = property.PropertyType;
     Context = parent.Context;
 }
 public PropertyValueDeserializerNode(IDeserializerNode parent, PropertySpec property)
 {
     this.parent = parent;
     this.property = property;
     this.valueType = property.PropertyType;
     this.context = parent.Context;
 }
 public PropertyValueSerializerNode(
     ISerializerNode parentNode, PropertySpec property)
 {
     if (parentNode == null)
         throw new ArgumentNullException("parentNode");
     if (property == null)
         throw new ArgumentNullException("propertyMapping");
     this.parentNode = parentNode;
     this.property = property;
     context = parentNode.Context;
 }
Ejemplo n.º 4
0
        private static string GetExpandPath(ISerializerNode parentNode, PropertySpec property)
        {
            if (string.IsNullOrEmpty(parentNode.ExpandPath))
            {
                if (property is QueryResultType.ItemsPropertySpec)
                    return string.Empty;
                return property.LowerCaseName;
            }

            return string.Concat(parentNode.ExpandPath, ".", property.LowerCaseName);
        }
Ejemplo n.º 5
0
 public PropertyValueSerializerNode(
     ISerializerNode parentNode,
     PropertySpec property)
     : base(
         property != null ? property.PropertyType : null, GetExpandPath(parentNode, property),
         parentNode != null ? parentNode.Context : null, parentNode)
 {
     if (parentNode == null)
         throw new ArgumentNullException(nameof(parentNode));
     if (property == null)
         throw new ArgumentNullException(nameof(property));
     Property = property;
 }
Ejemplo n.º 6
0
        private void BuildRelativeUri(object entity, PropertySpec property, StringBuilder sb)
        {
            var entityType = entity.GetType();
            var type = this.typeMapper.FromType(entityType) as ResourceType;
            if (type == null)
                throw new InvalidOperationException($"Can't get URI for {entityType}; can only get Uri for a ResourceType.");

            type.AppendUri(entity, sb);

            if (property != null)
            {
                if (sb.Length > 0)
                    sb.Append('/');
                sb.Append(((ResourceProperty)property).UriName);
            }
        }
Ejemplo n.º 7
0
 public string GetUriFor(PropertySpec property, object entity)
 {
     return RelativeToAbsoluteUri(BuildRelativeUri(entity, property));
 }
Ejemplo n.º 8
0
 private string BuildRelativeUri(object entity, PropertySpec property)
 {
     var sb = new StringBuilder();
     BuildRelativeUri(entity, property, sb);
     return sb.ToString();
 }
Ejemplo n.º 9
0
 private bool TryGetPropertyByName(string propertyName, out PropertySpec prop)
 {
     return Type.TryGetPropertyByName(propertyName, StringComparison.InvariantCulture, out prop);
 }
Ejemplo n.º 10
0
 public override PropertySetter LoadSetter(PropertySpec propertySpec)
 {
     return Filter.GetPropertySetter(propertySpec.ReflectedType, propertySpec.PropertyInfo)
            ?? base.LoadSetter(propertySpec);
 }
Ejemplo n.º 11
0
 public override TypeSpec LoadPropertyType(PropertySpec propertySpec)
 {
     var complexProperty = propertySpec as StructuredProperty;
     if (complexProperty != null)
         return FromType(Filter.GetPropertyType(complexProperty.ReflectedType, complexProperty.PropertyInfo));
     return base.LoadPropertyType(propertySpec);
 }
Ejemplo n.º 12
0
 public override PropertyFlags LoadPropertyFlags(PropertySpec propertySpec)
 {
     return Filter.GetPropertyFlags(propertySpec.PropertyInfo) ?? base.LoadPropertyFlags(propertySpec);
 }
Ejemplo n.º 13
0
        private void BuildRelativeUri(object entity, PropertySpec property, StringBuilder sb)
        {
            var type = this.typeMapper.GetClassMapping(entity.GetType()) as ResourceType;
            if (type == null)
                throw new InvalidOperationException("Can only get Uri for a ResourceType.");

            type.AppendUri(entity, sb);

            if (property != null)
            {
                sb.Append('/');
                sb.Append(((PropertyMapping)property).UriName);
            }
        }
Ejemplo n.º 14
0
 public virtual PropertyFlags LoadPropertyFlags(PropertySpec propertySpec)
 {
     if (propertySpec == null) throw new ArgumentNullException("propertySpec");
     return propertySpec.OnLoadPropertyFlags();
 }
Ejemplo n.º 15
0
 public string GetUri(PropertySpec property, object value)
 {
     return "http://todo";
 }
Ejemplo n.º 16
0
 public virtual PropertySetter LoadSetter(PropertySpec propertySpec)
 {
     if (propertySpec == null)
         throw new ArgumentNullException(nameof(propertySpec));
     return propertySpec.OnLoadSetter();
 }
Ejemplo n.º 17
0
 public virtual TypeSpec LoadPropertyType(PropertySpec propertySpec)
 {
     if (propertySpec == null)
         throw new ArgumentNullException(nameof(propertySpec));
     return propertySpec.OnLoadPropertyType();
 }
Ejemplo n.º 18
0
 public virtual PropertySpec LoadBaseDefinition(PropertySpec propertySpec)
 {
     if (propertySpec == null)
         throw new ArgumentNullException(nameof(propertySpec));
     return propertySpec.OnLoadBaseDefinition();
 }
Ejemplo n.º 19
0
 public Action<object, object> LoadSetter(PropertySpec propertySpec)
 {
     if (propertySpec == null) throw new ArgumentNullException("propertySpec");
     return propertySpec.OnLoadSetter();
 }
Ejemplo n.º 20
0
        public virtual TypeSpec LoadReflectedType(PropertySpec propertySpec)
        {
            if (propertySpec == null) throw new ArgumentNullException("propertySpec");

            return propertySpec.OnLoadReflectedType();
        }
Ejemplo n.º 21
0
 public bool PropertyIsSerialized(PropertySpec property)
 {
     return property.IsSerialized;
 }
Ejemplo n.º 22
0
 public override TypeSpec LoadDeclaringType(PropertySpec propertySpec)
 {
     if (propertySpec is StructuredProperty)
         return FromType(GetKnownDeclaringType(propertySpec.ReflectedType, propertySpec.PropertyInfo));
     return base.LoadDeclaringType(propertySpec);
 }
Ejemplo n.º 23
0
 public void SetProperty(PropertySpec property, object propertyValue)
 {
     Context.SetProperty(this, property, propertyValue);
 }
Ejemplo n.º 24
0
        public bool TryGetPropertyByName(string propertyName, bool ignoreCase, out PropertySpec propertySpec)
        {
            var stringComparison = ignoreCase
                ? StringComparison.InvariantCultureIgnoreCase
                : StringComparison.InvariantCulture;

            // TODO: Possible to optimize here by putting property names in a dictionary
            propertySpec = Properties.FirstOrDefault(x => string.Equals(x.Name, propertyName, stringComparison));
            return propertySpec != null;
        }