Esempio n. 1
0
 public static Attribute ForLowerCaseProperty()
 {
     return(new Attribute
     {
         Type = new Type(NamesService.GetExtensionTypeName("LowerCasePropertyAttribute"))
     });
 }
Esempio n. 2
0
 public CollectionExecuteAsyncMethod(OdcmClass odcmClass)
 {
     Name       = "ExecuteAsync";
     Parameters = Parameter.Empty;
     ReturnType = new Type(new Identifier("global::System.Threading.Tasks", "Task"),
                           new Type(NamesService.GetExtensionTypeName("IPagedCollection"),
                                    new Type(NamesService.GetConcreteInterfaceName(odcmClass))));
 }
Esempio n. 3
0
 private ConcreteNavigationCollectionProperty(OdcmProperty odcmProperty) : base(odcmProperty)
 {
     FieldName  = NamesService.GetConcreteFieldName(odcmProperty);
     OdcmType   = odcmProperty.Type;
     PrivateSet = true;
     Type       = new Type(NamesService.GetExtensionTypeName("IPagedCollection"),
                           new Type(NamesService.GetConcreteInterfaceName(odcmProperty.Type)));
 }
Esempio n. 4
0
 public EnsureQueryMethod(OdcmClass odcmClass)
 {
     Visibility           = Visibility.Private;
     Name                 = "EnsureQuery";
     FetchedType          = new Type(NamesService.GetConcreteTypeName(odcmClass));
     FetchedTypeInterface = new Type(NamesService.GetConcreteInterfaceName(odcmClass));
     ReturnType           = new Type(NamesService.GetExtensionTypeName("IReadOnlyQueryableSet"), new Type(NamesService.GetConcreteInterfaceName(odcmClass)));
 }
Esempio n. 5
0
 public static Field ForConcreteNavigationCollectionProperty(OdcmProperty property)
 {
     return(new Field
     {
         Name = NamesService.GetConcreteFieldName(property),
         Type = new Type(NamesService.GetExtensionTypeName("EntityCollectionImpl"), new Type(NamesService.GetConcreteTypeName((OdcmClass)property.Type)))
     });
 }
Esempio n. 6
0
 public static IEnumerable <Property> ForEntityContainer(OdcmClass odcmContainer)
 {
     return(Properties.ForEntityContainerInterface(odcmContainer)
            .Concat(new Property[]
     {
         new AutoProperty("Context", new Type(NamesService.GetExtensionTypeName("DataServiceContextWrapper")),
                          privateSet: true)
     }));
 }
Esempio n. 7
0
 public static Field ForStructuralProperty(OdcmProperty property)
 {
     return(new Field
     {
         Name = NamesService.GetPropertyFieldName(property),
         Type = property.IsCollection
             ? new Type(NamesService.GetExtensionTypeName("NonEntityTypeCollectionImpl"), new Type(NamesService.GetConcreteTypeName(property.Type)))
             : TypeService.GetPropertyType(property)
     });
 }
Esempio n. 8
0
 public static Interface ForCollection(OdcmEntityClass odcmClass)
 {
     return(new Interface
     {
         Attributes = global::Vipr.Writer.CSharp.Attributes.ForCollectionInterface,
         Identifier = NamesService.GetCollectionInterfaceName(odcmClass),
         Namespace = NamesService.GetNamespaceName(odcmClass.Namespace),
         Methods = global::Vipr.Writer.CSharp.Methods.ForCollectionInterface(odcmClass),
         Indexers = IndexerSignature.ForCollectionInterface(odcmClass),
         Interfaces = new[] { new Type(NamesService.GetExtensionTypeName("IReadOnlyQueryableSetBase"), new Type(NamesService.GetConcreteInterfaceName(odcmClass))) }
     });
 }
Esempio n. 9
0
 public static Class ForCollection(OdcmEntityClass odcmClass)
 {
     return(new Class
     {
         AccessModifier = "internal ",
         BaseClass = new Type(NamesService.GetExtensionTypeName("QueryableSet"),
                              new Type(NamesService.GetConcreteInterfaceName(odcmClass))),
         Constructors = global::Vipr.Writer.CSharp.Constructors.ForCollection(odcmClass),
         Interfaces = global::Vipr.Writer.CSharp.ImplementedInterfaces.ForCollection(odcmClass),
         Identifier = NamesService.GetCollectionTypeName(odcmClass),
         Methods = global::Vipr.Writer.CSharp.Methods.ForCollection(odcmClass),
         Indexers = global::Vipr.Writer.CSharp.Indexers.ForCollection(odcmClass)
     });
 }
Esempio n. 10
0
        public static IEnumerable <Type> ForConcreteInterface(OdcmClass odcmClass)
        {
            var retVal = new List <Type>();

            var baseClass = odcmClass.Base;

            var interfaceIdentifier = baseClass == null?
                                      NamesService.GetExtensionTypeName("IEntityBase") :
                                          NamesService.GetConcreteInterfaceName(baseClass);

            retVal.Add(new Type(interfaceIdentifier));

            return(retVal);
        }
Esempio n. 11
0
        private void Write(CollectionConstructor collectionConstructor)
        {
            _("internal {0}(global::Microsoft.OData.Client.DataServiceQuery inner," +
              "{1} context," +
              "object entity," +
              "string path)" +
              ": base(inner, context, entity as {2}, path)",
              NamesService.GetCollectionTypeName(collectionConstructor.OdcmClass).Name,
              NamesService.GetExtensionTypeName("DataServiceContextWrapper"),
              NamesService.GetExtensionTypeName("EntityBase"));
            _("{");

            _("}");
        }
Esempio n. 12
0
 public static Class ForFetcher(OdcmClass odcmClass)
 {
     return(new Class
     {
         AccessModifier = "internal ",
         BaseClass =
             new Type(odcmClass.Base == null
                 ? NamesService.GetExtensionTypeName("RestShallowObjectFetcher")
                 : NamesService.GetFetcherTypeName(odcmClass.Base)),
         Constructors = global::Vipr.Writer.CSharp.Constructors.ForFetcher(odcmClass),
         Fields = global::Vipr.Writer.CSharp.Fields.ForFetcher(odcmClass),
         Identifier = NamesService.GetFetcherTypeName(odcmClass),
         Interfaces = global::Vipr.Writer.CSharp.ImplementedInterfaces.ForFetcher(odcmClass),
         Methods = global::Vipr.Writer.CSharp.Methods.ForFetcher(odcmClass),
         Properties = global::Vipr.Writer.CSharp.Properties.ForFetcher(odcmClass),
     });
 }
Esempio n. 13
0
 public static Class ForComplex(OdcmClass odcmClass)
 {
     return(new Class
     {
         AbstractModifier = odcmClass.IsAbstract ? "abstract " : string.Empty,
         AccessModifier = "public ",
         Constructors = global::Vipr.Writer.CSharp.Constructors.ForComplex(odcmClass),
         BaseClass =
             new Type(odcmClass.Base == null
                 ? NamesService.GetExtensionTypeName("ComplexTypeBase")
                 : NamesService.GetPublicTypeName(odcmClass.Base)),
         Description = odcmClass.Description,
         Fields = global::Vipr.Writer.CSharp.Fields.ForComplex(odcmClass),
         Identifier = NamesService.GetConcreteTypeName(odcmClass),
         Properties = global::Vipr.Writer.CSharp.Properties.ForComplex(odcmClass),
     });
 }
Esempio n. 14
0
        private void Write(ConcreteNavigationCollectionProperty property)
        {
            WriteDeclaration(property);

            using (_builder.IndentBraced)
            {
                _("get");

                using (_builder.IndentBraced)
                {
                    _("return new {0}<{1}, {2}>(Context, ({3}<{2}>) {4});",
                      NamesService.GetExtensionTypeName("PagedCollection"),
                      NamesService.GetConcreteInterfaceName(property.OdcmType),
                      NamesService.GetConcreteTypeName(property.OdcmType),
                      "DataServiceCollection",
                      property.Name);
                }
            }
        }
Esempio n. 15
0
 public static Class ForConcrete(OdcmEntityClass odcmClass)
 {
     return(new Class
     {
         AbstractModifier = odcmClass.IsAbstract ? "abstract " : string.Empty,
         AccessModifier = "public ",
         Attributes = global::Vipr.Writer.CSharp.Attributes.ForConcrete(odcmClass),
         BaseClass =
             new Type(odcmClass.Base == null
                 ? NamesService.GetExtensionTypeName("EntityBase")
                 : NamesService.GetConcreteTypeName(odcmClass.Base)),
         Constructors = global::Vipr.Writer.CSharp.Constructors.ForConcrete(odcmClass),
         Description = odcmClass.Description,
         Fields = global::Vipr.Writer.CSharp.Fields.ForConcrete(odcmClass),
         Identifier = NamesService.GetConcreteTypeName(odcmClass),
         Interfaces = global::Vipr.Writer.CSharp.ImplementedInterfaces.ForConcrete(odcmClass),
         Methods = global::Vipr.Writer.CSharp.Methods.ForConcrete(odcmClass),
         Properties = global::Vipr.Writer.CSharp.Properties.ForConcrete(odcmClass)
     });
 }
Esempio n. 16
0
        private void Write(ConcreteNavigationCollectionAccessorProperty property)
        {
            WriteDeclaration(property);

            using (_builder.IndentBraced)
            {
                _("get");

                using (_builder.IndentBraced)
                {
                    _("if (this.{0} == null)", property.FieldName);
                    using (_builder.IndentBraced)
                    {
                        _("this.{0} = new {1}<{2}>();", property.FieldName, NamesService.GetExtensionTypeName("EntityCollectionImpl"), property.InstanceType);
                        _("this.{0}.SetContainer(() => GetContainingEntity(\"{1}\"));", property.FieldName, property.ModelName);
                    }
                    _("");
                    _("return ({0})this.{1};", property.Type, property.FieldName);
                }

                _("set");

                using (_builder.IndentBraced)
                {
                    WriteInitializationEnforcer();

                    _("{0}.Clear();", property.Name);
                    _("if (value != null)");
                    using (_builder.IndentBraced)
                    {
                        _("foreach (var i in value)");
                        using (_builder.IndentBraced)
                        {
                            _("{0}.Add(i);", property.Name);
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        private void Write(StructuralCollectionProperty property)
        {
            WriteDeclaration(property);

            using (_builder.IndentBraced)
            {
                _("get");

                using (_builder.IndentBraced)
                {
                    _("if (this.{0} == default({1}))", property.FieldName, property.Type);

                    using (_builder.IndentBraced)
                    {
                        _("this.{0} = new {1}<{2}>();", property.FieldName,
                          NamesService.GetExtensionTypeName("NonEntityTypeCollectionImpl"), property.InstanceType);
                        _("this.{0}.SetContainer(() => GetContainingEntity(\"{1}\"));", property.FieldName, property.ModelName);
                    }

                    _("return this.{0};", property.FieldName);
                }
                _("set");
                using (_builder.IndentBraced)
                {
                    _("{0}.Clear();", property.Name);
                    _("if (value != null)");

                    using (_builder.IndentBraced)
                    {
                        _("foreach (var i in value)");

                        using (_builder.IndentBraced)
                        {
                            _("{0}.Add(i);", property.Name);
                        }
                    }
                }
            }
        }
Esempio n. 18
0
 private void Write(EntityContainerConstructor entityContainerConstructor)
 {
     _("public {0}(global::System.Uri serviceRoot, global::System.Func<global::System.Threading.Tasks.Task<string>> accessTokenGetter)",
       entityContainerConstructor.Name);
     using (_builder.IndentBraced)
     {
         _("Context = new {0}(serviceRoot, global::Microsoft.OData.Client.ODataProtocolVersion.V4, accessTokenGetter);", NamesService.GetExtensionTypeName("DataServiceContextWrapper"));
         _("Context.MergeOption = global::Microsoft.OData.Client.MergeOption.OverwriteChanges;");
         _("Context.ResolveName = new global::System.Func<global::System.Type, string>(this.ResolveNameFromType);");
         _("Context.ResolveType = new global::System.Func<string, global::System.Type>(this.ResolveTypeFromName);");
         _("this.OnContextCreated();");
         _("Context.Format.LoadServiceModel = GeneratedEdmModel.GetInstance;");
         _("Context.Format.UseJson();");
     }
     _("partial void OnContextCreated();");
 }