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 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; }