예제 #1
0
파일: Attributes.cs 프로젝트: iambmelt/Vipr
 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
파일: Indexers.cs 프로젝트: iambmelt/Vipr
 public static IEnumerable<Indexer> ForCollection(OdcmEntityClass odcmClass)
 {
     return new Indexer[]
     {
         new CollectionGetByIdIndexer(odcmClass)
     };
 }
예제 #4
0
파일: Feature.cs 프로젝트: iambmelt/Vipr
 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
파일: Feature.cs 프로젝트: iambmelt/Vipr
 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
파일: Attribute.cs 프로젝트: iambmelt/Vipr
 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
파일: Classes.cs 프로젝트: iambmelt/Vipr
 public static IEnumerable<Class> ForUpcastMethods(OdcmEntityClass odcmClass)
 {
     return new[]
     {
         Class.ForFetcherUpcastMethods(odcmClass),
         Class.ForConcreteIFetcherUpcastMethods(odcmClass),
     };
 }
예제 #8
0
파일: Interfaces.cs 프로젝트: iambmelt/Vipr
 internal static IEnumerable<Interface> ForOdcmClassEntity(OdcmEntityClass odcmClass)
 {
     return new[]
     {
         Interface.ForConcrete(odcmClass),
         Interface.ForFetcher(odcmClass),
         Interface.ForCollection(odcmClass),
     };
 }
예제 #9
0
파일: Classes.cs 프로젝트: iambmelt/Vipr
 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
파일: Interface.cs 프로젝트: iambmelt/Vipr
 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
파일: Features.cs 프로젝트: iambmelt/Vipr
        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
파일: Feature.cs 프로젝트: iambmelt/Vipr
 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
파일: Class.cs 프로젝트: iambmelt/Vipr
 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
파일: Any.Odcm.cs 프로젝트: iambmelt/Vipr
        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
파일: Any.Odcm.cs 프로젝트: iambmelt/Vipr
        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
파일: Class.cs 프로젝트: iambmelt/Vipr
 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
파일: Interfaces.cs 프로젝트: iambmelt/Vipr
 internal static IEnumerable<Interface> ForUpcastMethods(OdcmEntityClass odcmClass)
 {
     return new[] {Interface.ForFetcherUpcastMethods(odcmClass)};
 }
예제 #21
0
파일: Class.cs 프로젝트: iambmelt/Vipr
 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
파일: Interface.cs 프로젝트: iambmelt/Vipr
 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();
        }