public static IEnumerable <Indexer> ForCollection(OdcmEntityClass odcmClass) { return(new Indexer[] { new CollectionGetByIdIndexer(odcmClass) }); }
public static CollectionGetByIdIndexer ForCollectionClass(OdcmEntityClass odcmClass, OdcmProjection projection) { return(new CollectionGetByIdIndexer(odcmClass, projection) { DefiningInterface = NamesService.GetCollectionInterfaceName(odcmClass, projection) }); }
public static IEnumerable <Class> ForUpcastMethods(OdcmEntityClass odcmClass) { return(new[] { Class.ForFetcherUpcastMethods(odcmClass) }); }
public static IEnumerable <Attribute> ForConcrete(OdcmEntityClass odcmClass) { return(new[] { Attribute.ForMicrosoftOdataClientKey(odcmClass) }); }
public static IEnumerable <IndexerSignature> ForCollectionInterface(OdcmEntityClass odcmClass, OdcmProjection projection) { return(new IndexerSignature[] { new CollectionGetByIdIndexer(odcmClass, projection) }); }
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 Feature ForUpcastMethods(OdcmEntityClass odcmClass) { return(new Feature { Classes = global::Vipr.Writer.CSharp.Lite.Classes.ForUpcastMethods(odcmClass), Interfaces = global::Vipr.Writer.CSharp.Lite.Interfaces.ForUpcastMethods(odcmClass) }); }
public static Interface ForFetcherUpcastMethods(OdcmEntityClass odcmClass) { return(new Interface { Identifier = NamesService.GetFetcherInterfaceName(odcmClass), Methods = global::Vipr.Writer.CSharp.Methods.ForFetcherInterfaceUpcasts(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) }); }
internal static IEnumerable <Interface> ForOdcmClassEntity(OdcmEntityClass odcmClass) { return(new[] { Interface.ForConcrete(odcmClass), Interface.ForFetcher(odcmClass), Interface.ForCollection(odcmClass), }); }
public static Class ForFetcherUpcastMethods(OdcmEntityClass odcmClass) { return(new Class { AccessModifier = "internal ", Identifier = NamesService.GetFetcherTypeName(odcmClass), Methods = global::Vipr.Writer.CSharp.Lite.Methods.ForFetcherUpcasts(odcmClass), }); }
public static IEnumerable <Class> ForOdcmClassEntity(OdcmEntityClass odcmClass) { return(new[] { Class.ForConcrete(odcmClass), Class.ForFetcher(odcmClass), Class.ForCollection(odcmClass), }); }
public static Class ForConcreteIFetcherUpcastMethods(OdcmEntityClass odcmClass) { return(new Class { AccessModifier = "public ", Identifier = NamesService.GetConcreteTypeName(odcmClass), Methods = global::Vipr.Writer.CSharp.Methods.ForConcreteUpcasts(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"); var identifier = NamesService.GetFetcherInterfaceName(Class); FetcherInterface = Proxy.GetInterface(Class.Namespace, identifier.Name); CollectionType = Proxy.GetClass(Class.Namespace, Class.Name + "Collection"); identifier = NamesService.GetCollectionInterfaceName(Class); CollectionInterface = Proxy.GetInterface(Class.Namespace, identifier.Name); 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 CollectionGetByIdIndexer(OdcmEntityClass odcmClass, OdcmProjection projection) { ParameterToPropertyMap = odcmClass.Key.ToDictionary(Parameter.FromProperty, p => p); Parameters = global::Vipr.Writer.CSharp.Lite.Parameters.GetKeyParameters(odcmClass); ReturnType = new Type(NamesService.GetFetcherInterfaceName(odcmClass, projection)); OdcmClass = odcmClass; IsSettable = false; IsGettable = true; }
private static EntityArtifacts GetEntityArtifactsFromNewNamespace(OdcmEntityClass @class, OdcmNamespace newNamespace, Assembly proxy, OdcmNamespace oldNamespace) { @class.Namespace = newNamespace; var entityArtifacts = @class.GetArtifactsFrom(proxy); @class.Namespace = oldNamespace; return(entityArtifacts); }
public static IEnumerable <Indexer> ForCollection(OdcmEntityClass odcmClass) { var retVal = new List <Indexer>(); foreach (var projection in odcmClass.DistinctProjections()) { retVal.Add(CollectionGetByIdIndexer.ForCollectionClass(odcmClass, projection)); } return(retVal); }
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))) } }); }
public static Feature ForCountableCollection(OdcmEntityClass odcmClass) { return(new Feature { Classes = new[] { Class.ForCountableCollection(odcmClass) }, Interfaces = new[] { Interface.ForCountableCollection(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.Lite.Constructors.ForCollection(odcmClass), Interfaces = global::Vipr.Writer.CSharp.Lite.ImplementedInterfaces.ForCollectionClass(odcmClass), Identifier = NamesService.GetCollectionTypeName(odcmClass), Methods = global::Vipr.Writer.CSharp.Lite.Methods.ForCollectionClass(odcmClass), Indexers = global::Vipr.Writer.CSharp.Lite.Indexers.ForCollection(odcmClass) }); }
public static EntityArtifacts GetArtifactsFrom(this OdcmEntityClass Class, Assembly Proxy) { var retVal = new EntityArtifacts { Class = Class, 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") }; return(retVal); }
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); }
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()); }
public static Class ForConcrete(OdcmEntityClass odcmClass) { return(new Class { AbstractModifier = odcmClass.IsAbstract ? "abstract " : string.Empty, AccessModifier = "public ", Attributes = global::Vipr.Writer.CSharp.Lite.Attributes.ForConcrete(odcmClass), BaseClass = new Type(odcmClass.Base == null ? NamesService.GetExtensionTypeName("EntityBase") : NamesService.GetConcreteTypeName(odcmClass.Base)), Constructors = global::Vipr.Writer.CSharp.Lite.Constructors.ForConcrete(odcmClass), Description = odcmClass.Description, Fields = global::Vipr.Writer.CSharp.Lite.Fields.ForConcrete(odcmClass), Identifier = NamesService.GetConcreteTypeName(odcmClass), Interfaces = global::Vipr.Writer.CSharp.Lite.ImplementedInterfaces.ForConcrete(odcmClass), Properties = global::Vipr.Writer.CSharp.Lite.Properties.ForConcrete(odcmClass) }); }
public static JObject GetSampleJObject(this OdcmEntityClass entityClass, IEnumerable <Tuple <string, object> > keyArguments, bool dontSalt = false) { var retVal = new JObject(); foreach (var keyArgument in keyArguments) { retVal.Add(keyArgument.Item1, new JValue(keyArgument.Item2)); } foreach (var collectionProperty in entityClass.Properties.Where(p => p.IsCollection)) { retVal.Add(collectionProperty.Name, new JArray()); } if (!dontSalt) { retVal.Add(Any.Word(), new JValue(Any.Int())); } return(retVal); }
public static IEnumerable <Interface> ForCollection(OdcmEntityClass odcmClass) { var interfaces = new List <Interface>(); foreach (var projection in odcmClass.DistinctProjections()) { var @interface = new Interface { Attributes = global::Vipr.Writer.CSharp.Lite.Attributes.ForCollectionInterface, Identifier = NamesService.GetCollectionInterfaceName(odcmClass, projection), Namespace = NamesService.GetNamespaceName(odcmClass.Namespace), Methods = global::Vipr.Writer.CSharp.Lite.Methods.ForCollectionInterface(odcmClass, projection), Indexers = IndexerSignature.ForCollectionInterface(odcmClass, projection), Interfaces = new[] { new Type(NamesService.GetExtensionTypeName("IReadOnlyQueryableSetBase"), new Type(NamesService.GetConcreteInterfaceName(odcmClass))) } }; interfaces.Add(@interface); } return(interfaces); }
public static string ToEdmx(this OdcmEntityClass odcmClass) { if (odcmClass is OdcmMediaClass) { return(((OdcmMediaClass)odcmClass).ToEdmx()); } var sb = new StringBuilder(); var tagName = GetTagName(odcmClass); sb.AppendFormat("<{0} Name=\"{1}\">", tagName, odcmClass.Name); sb.Append(GetKeyNode(odcmClass)); if (odcmClass.Properties.Any()) { sb.Append(odcmClass.Properties.Select(ToEdmx).Aggregate((c, n) => c + "\n" + n)); } sb.AppendFormat("</{0}>", tagName); return(sb.ToString()); }
internal static IEnumerable <Interface> ForUpcastMethods(OdcmEntityClass odcmClass) { return(new[] { Interface.ForFetcherUpcastMethods(odcmClass) }); }
internal static IEnumerable <Interface> ForOdcmClassEntity(OdcmEntityClass odcmClass) { return(Interface.ForConcrete(odcmClass) .Concat(Interface.ForFetcher(odcmClass)) .Concat(Interface.ForCollection(odcmClass))); }