Пример #1
0
        public override ResourcePropertyDetails LoadResourcePropertyDetails(ResourceProperty property)
        {
            var propInfo = property.PropertyInfo;

            return(new ResourcePropertyDetails(Filter.ClientPropertyIsExposedAsRepository(propInfo),
                                               NameUtils.ConvertCamelCaseToUri(Filter.GetPropertyMappedName(property.ReflectedType,
                                                                                                            propInfo))));
        }
        public void SetProperty(IDeserializerNode target, PropertySpec property, object propertyValue)
        {
            if (!property.IsWritable)
            {
                throw new InvalidOperationException("Unable to set property.");
            }

            if (typeof(IClientRepository).IsAssignableFrom(property.PropertyType))
            {
                var repoImplementationType = this.clientRepositoryImplementationMap.GetOrAdd(property.PropertyType,
                                                                                             t =>
                                                                                             t.Assembly.GetTypes()
                                                                                             .First(
                                                                                                 x =>
                                                                                                 !x.IsInterface &&
                                                                                                 x.IsClass &&
                                                                                                 t
                                                                                                 .IsAssignableFrom
                                                                                                     (x)));

                var    listProxyValue = propertyValue as LazyCollectionProxy;
                object repo;
                if (listProxyValue != null)
                {
                    repo = Activator.CreateInstance(repoImplementationType,
                                                    this.client,
                                                    listProxyValue.Uri,
                                                    null,
                                                    target.Value);
                }
                else
                {
                    repo = Activator.CreateInstance(repoImplementationType,
                                                    this.client,
                                                    target.Uri + "/" + NameUtils.ConvertCamelCaseToUri(property.Name),
                                                    propertyValue,
                                                    target.Value);
                }
                property.SetValue(target.Value, repo);
                return;
            }

            property.SetValue(target.Value, propertyValue);
        }
Пример #3
0
 public virtual string GetUrlRelativePath(Type type)
 {
     return
         (NameUtils.ConvertCamelCaseToUri(BaseFilter.GetPluralNameForType(BaseFilter.GetUriBaseType(type) ?? type)));
 }