public static FetcherExpandMethod ForFetcherClass(OdcmClass odcmClass, OdcmProjection projection) { return(new FetcherExpandMethod(odcmClass, projection) { DefiningInterface = NamesService.GetFetcherInterfaceName(odcmClass, projection) }); }
private void Init(bool isCollection) { base.Init(m => { var @namespace = m.Namespaces[0]; NavTargetClass = Any.OdcmEntityClass(@namespace); @namespace.Types.Add(NavTargetClass); m_NavTargetProjection = NavTargetClass.AnyOdcmProjection(); NavTargetClass.AddProjection(m_NavTargetProjection.Capabilities); var @class = @namespace.Classes.First(); NavigationProperty = Any.OdcmProperty(p => { p.Class = @class; p.Projection = m_NavTargetProjection; p.IsCollection = isCollection; }); m.Namespaces[0].Classes.First().Properties.Add(NavigationProperty); }); var identifier = NamesService.GetFetcherInterfaceName(NavTargetClass, m_NavTargetProjection); m_NavTargetFetcherInterface = Proxy.GetInterface(NavTargetClass.Namespace, identifier.Name); identifier = NamesService.GetCollectionInterfaceName(NavTargetClass, m_NavTargetProjection); m_NavTargetCollectionInterface = Proxy.GetInterface(NavTargetClass.Namespace, identifier.Name); }
public CollectionGetByIdMethod(OdcmClass odcmClass, OdcmProjection projection = null) { Name = "GetById"; ParameterToPropertyMap = ((OdcmEntityClass)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; }
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; }
public static Identifier GetCollectionInterfaceName(OdcmType odcmType, OdcmProjection projection = null) { if (projection == null) { projection = odcmType.DefaultProjection; } Identifier collectionTypeName = GetCollectionTypeName(odcmType); return(new Identifier(collectionTypeName.Namespace, "I" + collectionTypeName.Name + GetProjectionSuffix(projection))); }
private string GetProjectionEncoding(OdcmProjection projection) { var suffix = projection.GetProjectionShortForm(); if (!string.IsNullOrEmpty(suffix)) { suffix = "_" + suffix; } return(suffix); }
public static Identifier GetFetcherInterfaceName(OdcmType odcmType, OdcmProjection projection = null) { if (projection == null) { projection = odcmType.DefaultProjection; } var fetcherTypeName = GetFetcherTypeName(odcmType); return(new Identifier(fetcherTypeName.Namespace, "I" + fetcherTypeName.Name + GetProjectionSuffix(projection))); }
private static string GetProjectionSuffix(OdcmProjection projection) { string suffix = String.Empty; if (projection != null) { suffix = projection.GetProjectionShortForm(); if (!string.IsNullOrEmpty(suffix)) { suffix = "_" + suffix; } } return(suffix); }
private FetcherExpandMethod(OdcmClass odcmClass, OdcmProjection projection = null) { Visibility = Visibility.Public; Name = "Expand"; GenericParameters = new[] { "TTarget" }; Parameters = new[] { new Parameter(new Type(new Identifier("System.Linq.Expressions", "Expression"), new Type(new Identifier("System", "Func"), new Type(NamesService.GetConcreteInterfaceName(odcmClass)), new Type(new Identifier(null, "TTarget")))), "navigationPropertyAccessor"), }; ReturnType = new Type(NamesService.GetFetcherInterfaceName(odcmClass, projection)); OdcmClass = odcmClass; }
public static string GetProjectionShortForm(this OdcmProjection projection) { var result = string.Empty; var capabilities = projection.WellKnownCapabilities .OrderBy(c => c.GetShortName()); foreach (OdcmBooleanCapability capability in capabilities) { if (capability.Value == true) { result = result + "_" + capability.GetShortName(); } } return(result.Trim('_')); }
public static OdcmProjection AnyOdcmProjection(this OdcmType odcmType) { var projection = new OdcmProjection { Type = odcmType, Capabilities = new List <OdcmCapability>() }; var capabilityTerms = OdcmProjection .WellKnowCapabilityTerms .Distinct(); foreach (var term in capabilityTerms) { projection.Capabilities.Add(new OdcmBooleanCapability(Any.Bool(), term)); } return(projection); }
public static OdcmBooleanCapability SetBooleanCapability(this OdcmProjection projection, string term, bool value) { var capability = projection.Capabilities .SingleOrDefault(c => c.TermName == term) as OdcmBooleanCapability; if (capability != null) { capability.Value = value; return(capability); } capability = new OdcmBooleanCapability(value, term); if (!value) { projection.Capabilities.Add(capability); } return(capability); }
private void Init(OdcmProjection projection) { base.Init( m => { m_TargetClass = m.Namespaces[0].Classes.First(); m_TargetClass.Properties.Add(Any.PrimitiveOdcmProperty(p => p.Class = Class)); projection.Type = m_TargetClass; m_TargetClass.AddProjection(projection.Capabilities); }); var identifier = NamesService.GetFetcherInterfaceName(m_TargetClass, projection); m_FetcherInterface = Proxy.GetInterface(m_TargetClass.Namespace, identifier.Name); identifier = NamesService.GetCollectionInterfaceName(m_TargetClass, projection); m_CollectionInterface = Proxy.GetInterface(m_TargetClass.Namespace, identifier.Name); }
public static IEnumerable <Method> ForFetcherInterface(OdcmClass odcmClass, OdcmProjection projection) { var retVal = new List <Method>(); retVal.AddRange(Methods.ForEntityType(odcmClass)); if (!odcmClass.IsAbstract) { retVal.Add(new FetcherExecuteAsyncMethod(odcmClass)); if (projection.SupportsExpand()) { retVal.Add(FetcherExpandMethod.ForFetcherInterface(odcmClass, projection)); } if (projection.SupportsUpdate()) { retVal.Add(FetcherUpdateMethod.ForFetcher(odcmClass)); retVal.Add(FetcherSetMethod.ForFetcher(odcmClass)); } if (projection.SupportsUpdateLink()) { retVal.Add(FetcherUpdateLinkMethod.ForFetcher(odcmClass)); } if (projection.SupportsDelete()) { retVal.Add(FetcherDeleteMethod.ForFetcher(odcmClass)); } if (projection.SupportsDeleteLink()) { retVal.Add(FetcherDeleteLinkMethod.ForFetcher(odcmClass)); } retVal.Add(FetcherSaveChangesAsyncMethod.ForFetcher(odcmClass)); } return(retVal); }
public static IEnumerable <Method> ForCollectionInterface(OdcmClass odcmClass, OdcmProjection projection) { var odcmMediaClass = odcmClass as OdcmMediaClass; if (odcmMediaClass != null) { return(ForMediaCollectionInterface(odcmMediaClass)); } var retVal = new List <Method>(); retVal.AddRange(Methods.GetMethodsBoundToCollection(odcmClass)); retVal.Add(new CollectionGetByIdMethod(odcmClass, projection)); retVal.Add(new CollectionExecuteAsyncMethod(odcmClass)); if (projection.SupportsUpdateLink()) { retVal.Add(new CollectionAddLinkAsyncMethod(odcmClass)); } if (projection.SupportsDeleteLink()) { retVal.Add(new CollectionRemoveLinkAsyncMethod(odcmClass)); } if (projection.SupportsInsert()) { retVal.Add(new CollectionAddAsyncMethod(odcmClass)); } if (projection.SupportsUpdate()) { retVal.Add(new CollectionUpdateAsyncMethod(odcmClass)); } if (projection.SupportsDelete()) { retVal.Add(new CollectionDeleteAsyncMethod(odcmClass)); } return(retVal); }
public static string GetShortName(this OdcmCapability capability) { return(_wellKnownCapabilityNames[OdcmProjection.ToInternal(capability.TermName)]); }
public static IEnumerable <IndexerSignature> ForCollectionInterface(OdcmEntityClass odcmClass, OdcmProjection projection) { return(new IndexerSignature[] { new CollectionGetByIdIndexer(odcmClass, projection) }); }
internal Features(OdcmProjection projection) { _projection = projection; }
public static CollectionGetByIdMethod ForCollectionClass(OdcmClass odcmClass, OdcmProjection projection = null) { return(new CollectionGetByIdMethod(odcmClass, projection) { DefiningInterface = NamesService.GetCollectionInterfaceName(odcmClass, projection) }); }
public static CollectionGetByIdIndexer ForCollectionClass(OdcmEntityClass odcmClass, OdcmProjection projection) { return(new CollectionGetByIdIndexer(odcmClass, projection) { DefiningInterface = NamesService.GetCollectionInterfaceName(odcmClass, projection) }); }
public static FetcherExpandMethod ForFetcherInterface(OdcmClass odcmClass, OdcmProjection projection) { return(new FetcherExpandMethod(odcmClass, projection)); }