Exemplo n.º 1
0
 public static void WriteClientLibrary(TypeMapper typeMapper, Stream stream, bool embedPomonaClient = true)
 {
     var clientLibGenerator = new ClientLibGenerator(typeMapper);
     clientLibGenerator.PomonaClientEmbeddingEnabled = embedPomonaClient;
     clientLibGenerator.CreateClientDll(stream);
 }
Exemplo n.º 2
0
            public TypeCodeGenInfo(ClientLibGenerator parent, TransformedType transformedType)
            {
                var resourceType = transformedType as ResourceType;
                if (resourceType != null && resourceType.IsUriBaseType)
                {
                    if ((resourceType.IsRootResource && resourceType.IsExposedAsRepository)
                        || (resourceType.ParentToChildProperty != null
                            && resourceType.ParentToChildProperty.ExposedAsRepository))
                    {
                        this.customRepositoryInterface = new TypeDefinition(parent.assemblyName,
                            string.Format("I{0}Repository", transformedType.Name),
                            TypeAttributes.Interface | TypeAttributes.Public |
                            TypeAttributes.Abstract);
                        parent.module.Types.Add(this.customRepositoryInterface);
                    }
                }

                if (parent == null)
                    throw new ArgumentNullException("parent");
                this.parent = parent;
                this.transformedType = transformedType;

                this.postReturnTypeReference = new System.Lazy<TypeReference>(() =>
                {
                    if (resourceType == null || resourceType.PostReturnType == null)
                        return InterfaceType;
                    return parent.clientTypeInfoDict[resourceType.PostReturnType].InterfaceType;
                });

                this.customRepositoryBaseType = new System.Lazy<Type>(() =>
                {
                    if (resourceType != null)
                    {
                        if (resourceType.IsUriBaseType)
                        {
                            if (resourceType.IsRootResource && resourceType.IsExposedAsRepository)
                                return typeof(ClientRepository<,>);
                            if (resourceType.ParentToChildProperty != null
                                && resourceType.ParentToChildProperty.ExposedAsRepository)
                                return typeof(ChildResourceRepository<,>);
                        }
                    }
                    return null;
                });

                this.customRepositoryBaseTypeDefinition = new System.Lazy<TypeDefinition>(() =>
                {
                    if (this.customRepositoryBaseType.Value == null)
                        return null;

                    var typeRef = parent.Import(this.customRepositoryBaseType.Value);
                    return typeRef as TypeDefinition ?? typeRef.Resolve();
                });

                this.customRepositoryBaseTypeReference = new System.Lazy<TypeReference>(() =>
                {
                    if (this.customRepositoryBaseType.Value == null)
                        return null;

                    return
                        parent.Import(this.customRepositoryBaseType.Value).MakeGenericInstanceType(
                            InterfaceType,
                            PostReturnTypeReference);
                });

                this.interfaceType = new TypeDefinition(
                    parent.assemblyName,
                    "I" + transformedType.Name,
                    TypeAttributes.Interface | TypeAttributes.Public |
                    TypeAttributes.Abstract);
            }
Exemplo n.º 3
0
 public PostFormProxyBuilder(ClientLibGenerator owner, bool isPublic = true)
     : base(owner.module,
         owner.GetProxyType("PostResourceBase"),
         owner.Import(typeof(PropertyWrapper<,>)).Resolve(),
         isPublic)
 {
     this.owner = owner;
     ProxyNameFormat = "{0}Form";
 }