예제 #1
0
 public static FetcherExpandMethod ForFetcherClass(OdcmClass odcmClass, OdcmProjection projection)
 {
     return(new FetcherExpandMethod(odcmClass, projection)
     {
         DefiningInterface = NamesService.GetFetcherInterfaceName(odcmClass, projection)
     });
 }
예제 #2
0
        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);
        }
예제 #3
0
 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;
 }
예제 #4
0
        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;
        }
예제 #5
0
        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)));
        }
예제 #6
0
        private string GetProjectionEncoding(OdcmProjection projection)
        {
            var suffix = projection.GetProjectionShortForm();

            if (!string.IsNullOrEmpty(suffix))
            {
                suffix = "_" + suffix;
            }

            return(suffix);
        }
예제 #7
0
        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)));
        }
예제 #8
0
        private static string GetProjectionSuffix(OdcmProjection projection)
        {
            string suffix = String.Empty;

            if (projection != null)
            {
                suffix = projection.GetProjectionShortForm();
                if (!string.IsNullOrEmpty(suffix))
                {
                    suffix = "_" + suffix;
                }
            }
            return(suffix);
        }
예제 #9
0
 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;
 }
예제 #10
0
        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('_'));
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
 public static string GetShortName(this OdcmCapability capability)
 {
     return(_wellKnownCapabilityNames[OdcmProjection.ToInternal(capability.TermName)]);
 }
예제 #17
0
 public static IEnumerable <IndexerSignature> ForCollectionInterface(OdcmEntityClass odcmClass, OdcmProjection projection)
 {
     return(new IndexerSignature[]
     {
         new CollectionGetByIdIndexer(odcmClass, projection)
     });
 }
 internal Features(OdcmProjection projection)
 {
     _projection = projection;
 }
예제 #19
0
 public static CollectionGetByIdMethod ForCollectionClass(OdcmClass odcmClass, OdcmProjection projection = null)
 {
     return(new CollectionGetByIdMethod(odcmClass, projection)
     {
         DefiningInterface = NamesService.GetCollectionInterfaceName(odcmClass, projection)
     });
 }
예제 #20
0
 public static CollectionGetByIdIndexer ForCollectionClass(OdcmEntityClass odcmClass, OdcmProjection projection)
 {
     return(new CollectionGetByIdIndexer(odcmClass, projection)
     {
         DefiningInterface = NamesService.GetCollectionInterfaceName(odcmClass, projection)
     });
 }
예제 #21
0
 public static FetcherExpandMethod ForFetcherInterface(OdcmClass odcmClass, OdcmProjection projection)
 {
     return(new FetcherExpandMethod(odcmClass, projection));
 }