Beispiel #1
0
        private void FillHypermediaProperties(
            HypermediaClientObject hypermediaObjectInstance,
            IToken rootObject,
            IHypermediaResolver resolver)
        {
            var typeInfo   = hypermediaObjectInstance.GetType().GetTypeInfo();
            var properties = typeInfo.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (var propertyInfo in properties)
            {
                var ignore = propertyInfo.GetCustomAttribute <ClientIgnoreHypermediaPropertyAttribute>() != null;
                if (ignore)
                {
                    continue;
                }

                var hypermediaPropertyType = GetHypermediaPropertyType(propertyInfo);
                switch (hypermediaPropertyType)
                {
                case HypermediaPropertyType.Property:
                    FillProperty(hypermediaObjectInstance, propertyInfo, rootObject);
                    break;

                case HypermediaPropertyType.Link:
                    this.FillLink(hypermediaObjectInstance, propertyInfo, rootObject, resolver);
                    break;

                case HypermediaPropertyType.Entity:
                    this.FillEntity(hypermediaObjectInstance, propertyInfo, rootObject, resolver);
                    break;

                case HypermediaPropertyType.EntityCollection:
                    this.FillEntities(hypermediaObjectInstance, propertyInfo, rootObject, resolver);
                    break;

                case HypermediaPropertyType.Command:
                    this.FillCommand(hypermediaObjectInstance, propertyInfo, rootObject, resolver);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }