Пример #1
0
 public static IEnumerable<Attribute> ForConcrete(OdcmEntityClass odcmClass)
 {
     return new[]
     {
         Attribute.ForMicrosoftOdataClientKey(odcmClass)
     };
 }
Пример #2
0
 public static IEnumerable<IndexerSignature> ForCollectionInterface(OdcmEntityClass odcmClass)
 {
     return new IndexerSignature[]
     {
         new CollectionGetByIdIndexer(odcmClass)
     };
 }
Пример #3
0
 public static IEnumerable<Indexer> ForCollection(OdcmEntityClass odcmClass)
 {
     return new Indexer[]
     {
         new CollectionGetByIdIndexer(odcmClass)
     };
 }
Пример #4
0
 public static Feature ForUpcastMethods(OdcmEntityClass odcmClass)
 {
     return new Feature
     {
         Classes = global::Vipr.Writer.CSharp.Classes.ForUpcastMethods(odcmClass),
         Interfaces = global::Vipr.Writer.CSharp.Interfaces.ForUpcastMethods(odcmClass)
     };
 }
Пример #5
0
 public static Feature ForOdcmClassEntity(OdcmEntityClass odcmClass)
 {
     return new Feature
     {
         Classes = global::Vipr.Writer.CSharp.Classes.ForOdcmClassEntity(odcmClass),
         Interfaces = global::Vipr.Writer.CSharp.Interfaces.ForOdcmClassEntity(odcmClass),
     };
 }
Пример #6
0
 public static Attribute ForMicrosoftOdataClientKey(OdcmEntityClass odcmClass)
 {
     return new Attribute
     {
         Type = new Type(new Identifier("global::Microsoft.OData.Client", "Key")),
         Parameters = odcmClass.Key.ToDictionary<OdcmProperty, string, string>(p => p.Name, p => null)
     };
 }
Пример #7
0
 public static IEnumerable<Class> ForUpcastMethods(OdcmEntityClass odcmClass)
 {
     return new[]
     {
         Class.ForFetcherUpcastMethods(odcmClass),
         Class.ForConcreteIFetcherUpcastMethods(odcmClass),
     };
 }
Пример #8
0
 internal static IEnumerable<Interface> ForOdcmClassEntity(OdcmEntityClass odcmClass)
 {
     return new[]
     {
         Interface.ForConcrete(odcmClass),
         Interface.ForFetcher(odcmClass),
         Interface.ForCollection(odcmClass),
     };
 }
Пример #9
0
 public static IEnumerable<Class> ForOdcmClassEntity(OdcmEntityClass odcmClass)
 {
     return new[]
     {
         Class.ForConcrete(odcmClass),
         Class.ForFetcher(odcmClass),
         Class.ForCollection(odcmClass),
     };
 }
Пример #10
0
        public CollectionGetByIdIndexer(OdcmEntityClass odcmClass)
        {
            ParameterToPropertyMap = odcmClass.Key.ToDictionary(Parameter.FromProperty, p => p);

            Parameters = global::Vipr.Writer.CSharp.Parameters.GetKeyParameters(odcmClass);
            ReturnType = new Type(NamesService.GetFetcherInterfaceName(odcmClass));
            OdcmClass = odcmClass;

            IsSettable = false;
            IsGettable = true;
        }
Пример #11
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))) }
     };
 }
Пример #12
0
        private static IEnumerable<Feature> ForOdcmClassEntity(OdcmEntityClass odcmClass)
        {
            var retVal = new List<Feature>
            {
                Feature.ForOdcmClassEntity(odcmClass),
                Feature.ForCountableCollection(odcmClass),
            };

            if (!ConfigurationService.Settings.OmitUpcastMethods && odcmClass.Base == null)
                retVal.Add(Feature.ForUpcastMethods(odcmClass));

            return retVal;
        }
Пример #13
0
 public static Feature ForCountableCollection(OdcmEntityClass odcmClass)
 {
     return new Feature
     {
         Classes = new[]
         {
             Class.ForCountableCollection(odcmClass)
         },
         Interfaces = new[]
         {
             Interface.ForCountableCollection(odcmClass)
         }
     };
 }
Пример #14
0
        public void Init(Action<OdcmModel> config = null, bool generateMocks = false)
        {
            Model = new OdcmModel(Any.ServiceMetadata());

            Namespace = Any.EmptyOdcmNamespace();

            Model.Namespaces.Add(Namespace);

            Class = Any.OdcmEntityClass(Namespace);

            Model.AddType(Class);

            OdcmContainer = Any.ServiceOdcmClass(Namespace);

            Model.AddType(OdcmContainer);

            if (config != null) config(Model);

            Model.ServiceMetadata["$metadata"] = Model.ToEdmx(true);

            Proxy = GetProxy(Model, ConfigurationProvider, generateMocks ? new[] { "DynamicProxyGenAssembly2" } : null);

            ConcreteType = Proxy.GetClass(Class.Namespace, Class.Name);

            ConcreteInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name);

            FetcherType = Proxy.GetClass(Class.Namespace, Class.Name + "Fetcher");

            FetcherInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Fetcher");

            CollectionType = Proxy.GetClass(Class.Namespace, Class.Name + "Collection");

            CollectionInterface = Proxy.GetInterface(Class.Namespace, "I" + Class.Name + "Collection");

            EntityContainerType = Proxy.GetClass(Model.EntityContainer.Namespace, Model.EntityContainer.Name);

            EntityContainerInterface = Proxy.GetInterface(Model.EntityContainer.Namespace, "I" + Model.EntityContainer.Name);

            TargetEntity = new EntityArtifacts()
            {
                Class = Class,
                ConcreteType = ConcreteType,
                ConcreteInterface = ConcreteInterface,
                FetcherType = FetcherType,
                FetcherInterface = FetcherInterface,
                CollectionType = CollectionType,
                CollectionInterface = CollectionInterface
            };
        }
Пример #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)
     };
 }
Пример #16
0
        private static void EntityOrMediaOdcmClass(OdcmNamespace odcmNamespace, Action<OdcmEntityClass> config, OdcmEntityClass retVal)
        {
            retVal.Properties.AddRange(Any.Sequence(i => Any.PrimitiveOdcmProperty(p => p.Class = retVal)));

            retVal.Key.AddRange(retVal.Properties.RandomSubset(2));

            if (odcmNamespace.Classes.Any(c => c.Kind == OdcmClassKind.Complex))
                retVal.Properties.AddRange(Any.Sequence(i => Any.OdcmProperty(p =>
                {
                    p.Class = retVal;
                    p.Type = odcmNamespace.Classes.Where(c => c.Kind == OdcmClassKind.Complex).RandomElement();
                })));

            retVal.Properties.AddRange(Any.Sequence(i => Any.OdcmEntityProperty(retVal, p => { p.Class = retVal; })));

            retVal.Properties.AddRange(Any.Sequence(i => Any.OdcmEntityProperty(retVal, p =>
            {
                p.Class = retVal;
                p.IsCollection = true;
            })));

            if (config != null) config(retVal);

            retVal.Methods.AddRange(Any.Sequence(s => Any.OdcmMethod()));
        }
Пример #17
0
        public static OdcmEntityClass OdcmEntityClass(OdcmNamespace odcmNamespace, string name, Action<OdcmEntityClass> config = null)
        {
            var retVal = new OdcmEntityClass(name, odcmNamespace);

            EntityOrMediaOdcmClass(odcmNamespace, config, retVal);

            return retVal;
        }
Пример #18
0
 public static Class ForConcreteIFetcherUpcastMethods(OdcmEntityClass odcmClass)
 {
     return new Class
     {
         AccessModifier = "public ",
         Identifier = NamesService.GetConcreteTypeName(odcmClass),
         Methods = global::Vipr.Writer.CSharp.Methods.ForConcreteUpcasts(odcmClass),
     };
 }
Пример #19
0
        }

        private static EntityArtifacts GetEntityArtifactsFromNewNamespace(OdcmEntityClass @class, OdcmNamespace newNamespace,
            Assembly proxy, OdcmNamespace oldNamespace)
        {
            @class.Namespace = newNamespace;

            var entityArtifacts = @class.GetArtifactsFrom(proxy);

            @class.Namespace = oldNamespace;
Пример #20
0
 internal static IEnumerable<Interface> ForUpcastMethods(OdcmEntityClass odcmClass)
 {
     return new[] {Interface.ForFetcherUpcastMethods(odcmClass)};
 }
Пример #21
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)
     };
 }
Пример #22
0
 public static Interface ForFetcherUpcastMethods(OdcmEntityClass odcmClass)
 {
     return new Interface
     {
         Identifier = NamesService.GetFetcherInterfaceName(odcmClass),
         Methods = global::Vipr.Writer.CSharp.Methods.ForFetcherInterfaceUpcasts(odcmClass),
     };
 }
Пример #23
0
        private static string GetKeyNode(OdcmEntityClass odcmClass)
        {
            if (!odcmClass.Key.Any())
                return string.Empty;

            var sb = new StringBuilder();

            sb.Append("<Key>");
            sb.Append(odcmClass.Key.Select(ToPropertyRef).Aggregate((c, n) => c + "\n" + n));
            sb.Append("</Key>");

            return sb.ToString();
        }