public static IEnumerable<Attribute> ForConcrete(OdcmEntityClass odcmClass) { return new[] { Attribute.ForMicrosoftOdataClientKey(odcmClass) }; }
public static IEnumerable<IndexerSignature> ForCollectionInterface(OdcmEntityClass odcmClass) { return new IndexerSignature[] { new CollectionGetByIdIndexer(odcmClass) }; }
public static IEnumerable<Indexer> ForCollection(OdcmEntityClass odcmClass) { return new Indexer[] { new CollectionGetByIdIndexer(odcmClass) }; }
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) }; }
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), }; }
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) }; }
public static IEnumerable<Class> ForUpcastMethods(OdcmEntityClass odcmClass) { return new[] { Class.ForFetcherUpcastMethods(odcmClass), Class.ForConcreteIFetcherUpcastMethods(odcmClass), }; }
internal static IEnumerable<Interface> ForOdcmClassEntity(OdcmEntityClass odcmClass) { return new[] { Interface.ForConcrete(odcmClass), Interface.ForFetcher(odcmClass), Interface.ForCollection(odcmClass), }; }
public static IEnumerable<Class> ForOdcmClassEntity(OdcmEntityClass odcmClass) { return new[] { Class.ForConcrete(odcmClass), Class.ForFetcher(odcmClass), Class.ForCollection(odcmClass), }; }
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; }
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))) } }; }
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; }
public static Feature ForCountableCollection(OdcmEntityClass odcmClass) { return new Feature { Classes = new[] { Class.ForCountableCollection(odcmClass) }, Interfaces = new[] { Interface.ForCountableCollection(odcmClass) } }; }
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 }; }
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) }; }
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())); }
public static OdcmEntityClass OdcmEntityClass(OdcmNamespace odcmNamespace, string name, Action<OdcmEntityClass> config = null) { var retVal = new OdcmEntityClass(name, odcmNamespace); EntityOrMediaOdcmClass(odcmNamespace, config, retVal); return retVal; }
public static Class ForConcreteIFetcherUpcastMethods(OdcmEntityClass odcmClass) { return new Class { AccessModifier = "public ", Identifier = NamesService.GetConcreteTypeName(odcmClass), Methods = global::Vipr.Writer.CSharp.Methods.ForConcreteUpcasts(odcmClass), }; }
} private static EntityArtifacts GetEntityArtifactsFromNewNamespace(OdcmEntityClass @class, OdcmNamespace newNamespace, Assembly proxy, OdcmNamespace oldNamespace) { @class.Namespace = newNamespace; var entityArtifacts = @class.GetArtifactsFrom(proxy); @class.Namespace = oldNamespace;
internal static IEnumerable<Interface> ForUpcastMethods(OdcmEntityClass odcmClass) { return new[] {Interface.ForFetcherUpcastMethods(odcmClass)}; }
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) }; }
public static Interface ForFetcherUpcastMethods(OdcmEntityClass odcmClass) { return new Interface { Identifier = NamesService.GetFetcherInterfaceName(odcmClass), Methods = global::Vipr.Writer.CSharp.Methods.ForFetcherInterfaceUpcasts(odcmClass), }; }
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(); }