示例#1
0
        void _Create(GraphFactory graph, bool isElman, int inputSize, float[] memory, INode activation, INode activation2, string memoryName)
        {
            _isElman     = isElman;
            _inputSize   = inputSize;
            _activation  = activation;
            _activation2 = activation2;
            int hiddenLayerSize = memory.Length;

            _memory = new MemoryFeeder(memory, null, memoryName);
            _input  = new FlowThrough();

            var inputChannel  = graph.Connect(inputSize, _input).AddFeedForward(hiddenLayerSize, "Wh");
            var memoryChannel = graph.Connect(hiddenLayerSize, _memory).AddFeedForward(hiddenLayerSize, "Uh");

            var h = graph.Add(inputChannel, memoryChannel)
                    .AddBackwardAction(new ConstrainSignal())
                    .Add(activation)
            ;

            if (isElman)
            {
                h = h.AddForwardAction(_memory.SetMemoryAction);
            }

            h = h.AddFeedForward(hiddenLayerSize, "Wy")
                .AddBackwardAction(new ConstrainSignal())
                .Add(activation2)
            ;
            if (!isElman)
            {
                h.AddForwardAction(_memory.SetMemoryAction);
            }

            _output = h
                      //.Add(new HookErrorSignal(context => {
                      //    if (_lastBackpropagation != null) {
                      //        foreach (var item in _lastBackpropagation)
                      //            context.AppendErrorSignal(item.Value, item.Key);
                      //        _lastBackpropagation = null;
                      //    }
                      //}))
                      .LastNode
            ;
            _start = new OneToMany(SubNodes, bp => _lastBackpropagation = bp);
        }
示例#2
0
        void _Create(GraphFactory graph, int inputSize, float[] memory, string memoryId)
        {
            _inputSize = inputSize;
            int hiddenLayerSize = memory.Length;

            _memory = new MemoryFeeder(memory, null, memoryId);
            _input  = new FlowThrough();

            var Wz = graph.Connect(inputSize, _input).AddFeedForward(hiddenLayerSize, "Wz");
            var Uz = graph.Connect(hiddenLayerSize, _memory).AddFeedForward(hiddenLayerSize, "Uz");

            var Wr = graph.Connect(inputSize, _input).AddFeedForward(hiddenLayerSize, "Wr");
            var Ur = graph.Connect(hiddenLayerSize, _memory).AddFeedForward(hiddenLayerSize, "Ur");

            // add sigmoids to the gates
            var Rt = graph.Add(Wr, Ur).AddBackwardAction(new ConstrainSignal()).Add(graph.SigmoidActivation("Rt")).LastNode;
            var Zt = graph.Add(Wz, Uz).AddBackwardAction(new ConstrainSignal()).Add(graph.SigmoidActivation("Zt")).LastNode;

            // h1 = tanh(Wh(x) + Uh(Ht1xRt))
            var Wh = graph.Connect(inputSize, _input).AddFeedForward(hiddenLayerSize, "Wh");
            var Uh = graph.Multiply(hiddenLayerSize, Rt, _memory).AddFeedForward(hiddenLayerSize, "Uh");
            var h1 = graph.Add(Wh, Uh).AddBackwardAction(new ConstrainSignal()).Add(graph.TanhActivation());

            // h2 = h1x(1-Zt)
            var h2 = graph.Multiply(h1, graph.Connect(hiddenLayerSize, Zt).Add(graph.CreateOneMinusInput()));

            // h = h1xh2
            var previous = graph.Multiply(hiddenLayerSize, Zt, _memory);

            _output = graph
                      .Add(h2, previous)
                      .AddForwardAction(_memory.SetMemoryAction)
                      //.Add(new HookErrorSignal(context => {
                      //    if (_lastBackpropagation != null) {
                      //        foreach (var item in _lastBackpropagation)
                      //            context.AppendErrorSignal(item.Value, item.Key);
                      //        _lastBackpropagation = null;
                      //    }
                      //}))
                      .LastNode
            ;
            _start = new OneToMany(SubNodes, bp => _lastBackpropagation = bp);
        }
示例#3
0
        void _Create(GraphFactory graph, int inputSize, float[] gamma, float[] beta, float[] derivedMean, float[] derivedM2, int count)
        {
            _inputSize  = inputSize;
            _statistics = new VectorBasedStatistics(graph.LinearAlgebraProvider, inputSize, derivedMean, derivedM2, count);

            if (gamma == null)
            {
                gamma = new float[inputSize];
                for (var i = 0; i < inputSize; i++)
                {
                    gamma[i] = 1f;
                }
            }
            if (beta == null)
            {
                beta = new float[inputSize];
            }

            _input = new FlowThrough();
            _gamma = new VectorInput(gamma, "gamma");
            _beta  = new VectorInput(beta, "beta");

            var mean               = graph.Connect(inputSize, _input).Add(new BatchMean());
            var subtractMean       = graph.Subtract(inputSize, _input, mean.LastNode);
            var subtractMeanOutput = subtractMean.LastNode;

            var stdDev = subtractMean
                         .Add(new InputSquared())
                         .Add(new BatchMean())
                         .Add(new SquareRootOfInput())
                         .Add(new OneDividedByInput());

            var normalised = graph.Multiply(_inputSize, subtractMeanOutput, stdDev.LastNode) /*.Add(new InspectSignals(data => {
                                                                                              * var matrix = data.GetMatrix().AsIndexable();
                                                                                              * var statistics = matrix.Columns.Select(v => (v, v.Average())).Select(v2 => (v2.Item2, v2.Item1.StdDev(v2.Item2))).ToList();
                                                                                              * }))*/;
            var adjusted   = graph.Multiply(_inputSize, _gamma, normalised.LastNode);

            _output = graph.Add(_inputSize, _beta, adjusted.LastNode).LastNode;

            _start = new OneToMany(SubNodes, bp => { });
        }
示例#4
0
        void _Create(GraphFactory graph, float gamma, float beta)
        {
            _input  = new FlowThrough();
            _input2 = new CalculateVariance();
            var main     = graph.Subtract(_inputSize, _input, _input2);
            var mainNode = main.LastNode;

            main.Add(new InputSquared());
            main.Add(new CalculateVariance());
            main.Add(new SquareRootOfInput());
            main.Add(new OneDividedByInput());
            main = graph.Multiply(_inputSize, mainNode, main.LastNode);

            _gamma = new MultiplyWithParameter(gamma);
            _beta  = new MultiplyWithParameter(beta);

            main    = graph.Multiply(_inputSize, _gamma, main.LastNode);
            _output = graph.Add(_inputSize, _beta, main.LastNode).LastNode;
            _start  = new OneToMany(SubNodes, null);
        }
示例#5
0
        void _Create(GraphFactory graph, int inputSize, float[] memory, string memoryId)
        {
            _inputSize = inputSize;
            int hiddenLayerSize = memory.Length;

            _memory = new MemoryFeeder(memory, null, memoryId);
            _state  = new MemoryFeeder(new float[memory.Length]);
            _input  = new FlowThrough();

            var Wf = graph.Connect(inputSize, _input).AddFeedForward(hiddenLayerSize, "Wf");
            var Wi = graph.Connect(inputSize, _input).AddFeedForward(hiddenLayerSize, "Wi");
            var Wo = graph.Connect(inputSize, _input).AddFeedForward(hiddenLayerSize, "Wo");
            var Wc = graph.Connect(inputSize, _input).AddFeedForward(hiddenLayerSize, "Wc");

            var Uf = graph.Connect(hiddenLayerSize, _memory).AddFeedForward(hiddenLayerSize, "Uf");
            var Ui = graph.Connect(hiddenLayerSize, _memory).AddFeedForward(hiddenLayerSize, "Ui");
            var Uo = graph.Connect(hiddenLayerSize, _memory).AddFeedForward(hiddenLayerSize, "Uo");
            var Uc = graph.Connect(hiddenLayerSize, _memory).AddFeedForward(hiddenLayerSize, "Uc");

            var Ft = graph.Add(Wf, Uf).Add(graph.SigmoidActivation("Ft"));
            var It = graph.Add(Wi, Ui).Add(graph.SigmoidActivation("It"));
            var Ot = graph.Add(Wo, Uo).Add(graph.SigmoidActivation("Ot"));

            var ftCt1 = graph.Multiply(hiddenLayerSize, Ft.LastNode, _state);
            var Ct    = graph.Add(ftCt1, graph.Multiply(It, graph.Add(Wc, Uc).Add(graph.TanhActivation())))
                        .AddForwardAction(_state.SetMemoryAction)
            ;

            _output = graph.Multiply(Ot, Ct.Add(graph.TanhActivation()))
                      .AddForwardAction(_memory.SetMemoryAction)
                      //.Add(new HookErrorSignal(context => {
                      //    if (_lastBackpropagation != null) {
                      //        foreach (var item in _lastBackpropagation)
                      //            context.AppendErrorSignal(item.Value, item.Key);
                      //        _lastBackpropagation = null;
                      //    }
                      //}))
                      .LastNode
            ;
            _start = new OneToMany(SubNodes, bp => _lastBackpropagation = bp);
        }
示例#6
0
        private async Task Demo04_OneToMany()
        {
            Console.WriteLine(nameof(Demo04_OneToMany));
            var testfile = "test.jpg";
            var source   = GetSourcePath(testfile);
            var target1  = GetTargetFilename(source, "-target1");
            var target2  = GetTargetFilename(source, "-target2");

            var fileSource  = new FileSource(source);
            var oneToMany   = new OneToMany();
            var fileWriter1 = new FileWriter(target1);
            var fileWriter2 = new FileWriter(target2);

            fileSource.Connect(oneToMany);
            oneToMany.Connect(fileWriter1, fileWriter2);

            await fileSource.Start();

            AssertFilesAreEqual(source, target1);
            AssertFilesAreEqual(source, target2);
        }
示例#7
0
        public void TestWithinOneEdge()
        {
            // build graph.
            var routerDb = new RouterDb();

            routerDb.AddSupportedVehicle(VehicleMock.Car());
            routerDb.Network.AddVertex(0, 0, 0);
            routerDb.Network.AddVertex(1, 1, 1);
            routerDb.Network.AddEdge(0, 1, new Itinero.Data.Network.Edges.EdgeData()
            {
                Distance = 100,
                Profile  = 0,
                MetaId   = 0
            });

            // run algorithm.
            var algorithm = new OneToMany(new Router(routerDb), VehicleMock.Car().Fastest(), (x) => new uint[0][],
                                          new RouterPoint(0, 0, 0, ushort.MaxValue / 10),
                                          new RouterPoint[] { new RouterPoint(1, 1, 0, ushort.MaxValue / 10 * 9) }, float.MaxValue);

            algorithm.Run();

            Assert.IsTrue(algorithm.HasRun);
            Assert.IsTrue(algorithm.HasSucceeded);

            var path = algorithm.GetPath(0);

            Assert.IsNotNull(path);
            Assert.AreEqual(Constants.NO_VERTEX, path.Vertex);
            Assert.AreEqual(VehicleMock.Car().Fastest().FactorAndSpeed(null).Value * 80, path.Weight, 0.01);
            path = path.From;
            Assert.IsNotNull(path);
            Assert.AreEqual(Constants.NO_VERTEX, path.Vertex);
            Assert.AreEqual(0, path.Weight);
            path = path.From;
            Assert.IsNull(path);
        }
示例#8
0
        public void TestOneEdge()
        {
            // build graph.
            var routerDb = new RouterDb();

            routerDb.AddSupportedProfile(MockProfile.CarMock());
            routerDb.Network.AddVertex(0, 0, 0);
            routerDb.Network.AddVertex(1, 0, 0);
            routerDb.Network.AddEdge(0, 1, new Itinero.Data.Network.Edges.EdgeData()
            {
                Distance = 100,
                Profile  = 0,
                MetaId   = 0
            });

            // run algorithm.
            var algorithm = new OneToMany(new Router(routerDb), MockProfile.CarMock(),
                                          new RouterPoint(0, 0, 0, 0), new RouterPoint[] { new RouterPoint(1, 1, 0, ushort.MaxValue) }, float.MaxValue);

            algorithm.Run();

            Assert.IsTrue(algorithm.HasRun);
            Assert.IsTrue(algorithm.HasSucceeded);

            var path = algorithm.GetPath(0);

            Assert.IsNotNull(path);
            Assert.AreEqual(1, path.Vertex);
            Assert.AreEqual(MockProfile.CarMock().Factor(null).Value * 100, path.Weight);
            path = path.From;
            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Vertex);
            Assert.AreEqual(0, path.Weight);
            path = path.From;
            Assert.IsNull(path);
        }
 static void Main(string[] args)
 {
     OneToMany.Run();
     // Sample.Run();
     Console.WriteLine("Hello World!");
 }
示例#10
0
        private ICollection <T> LoadOneToMany <T>(object poco, Column column, ref ICollection <T> loadTo, OneToMany relation)
        {
            var targetEntity       = relation.MappedByEntity;
            var selectQueryBuilder = new SelectQueryBuilder <T>(_ctx, relation.MappedByPocoType);
            var whereColumn        = targetEntity.Columns.Where(c => c.PropInfo == relation.MappedByProperty).First();
            // primary key of the current object!
            var whereValue = _entity.PkColumn.PropInfo.GetMethod.Invoke(poco, new object[0]);

            selectQueryBuilder = selectQueryBuilder
                                 .Where(
                BinaryExpression.Eq(
                    new ColumnExpression(whereColumn.Name),
                    new ValueExpression(whereValue, whereColumn.DbType.PStmtDbType)
                    )
                );
            return(selectQueryBuilder.Build().Execute().ToList());
        }
示例#11
0
        /// <remarks>
        /// Called for all collections. <paramref name="containingType" /> parameter
        /// was added in NH to allow for reflection related to generic types.
        /// </remarks>
        private void BindCollection(XmlNode node, Mapping.Collection model, string className,
                                    string path, System.Type containingType, IDictionary <string, MetaAttribute> inheritedMetas)
        {
            // ROLENAME
            model.Role = StringHelper.Qualify(className, path);
            // TODO: H3.1 has just collection.setRole(path) here - why?

            XmlAttribute inverseNode = node.Attributes["inverse"];

            if (inverseNode != null)
            {
                model.IsInverse = StringHelper.BooleanValue(inverseNode.Value);
            }

            // TODO: H3.1 - not ported: mutable
            XmlAttribute olNode = node.Attributes["optimistic-lock"];

            model.IsOptimisticLocked = olNode == null || "true".Equals(olNode.Value);

            XmlAttribute orderNode = node.Attributes["order-by"];

            if (orderNode != null)
            {
                model.OrderBy = orderNode.Value;
            }
            XmlAttribute whereNode = node.Attributes["where"];

            if (whereNode != null)
            {
                model.Where = whereNode.Value;
            }
            XmlAttribute batchNode = node.Attributes["batch-size"];

            if (batchNode != null)
            {
                model.BatchSize = int.Parse(batchNode.Value);
            }

            // PERSISTER
            XmlAttribute persisterNode = node.Attributes["persister"];

            if (persisterNode == null)
            {
                //persister = CollectionPersisterImpl.class;
            }
            else
            {
                model.CollectionPersisterClass = ClassForNameChecked(
                    persisterNode.Value, mappings,
                    "could not instantiate collection persister class: {0}");
            }

            XmlAttribute typeNode = node.Attributes["collection-type"];

            if (typeNode != null)
            {
                string  typeName = typeNode.Value;
                TypeDef typeDef  = mappings.GetTypeDef(typeName);
                if (typeDef != null)
                {
                    model.TypeName       = typeDef.TypeClass;
                    model.TypeParameters = typeDef.Parameters;
                }
                else
                {
                    model.TypeName = FullQualifiedClassName(typeName, mappings);
                }
            }

            // FETCH STRATEGY
            InitOuterJoinFetchSetting(node, model);

            if ("subselect".Equals(XmlHelper.GetAttributeValue(node, "fetch")))
            {
                model.IsSubselectLoadable = true;
                model.Owner.HasSubselectLoadableCollections = true;
            }

            // LAZINESS
            InitLaziness(node, model, "true", mappings.DefaultLazy);
            XmlAttribute lazyNode = node.Attributes["lazy"];

            if (lazyNode != null && "extra".Equals(lazyNode.Value))
            {
                model.IsLazy    = true;
                model.ExtraLazy = true;
            }

            XmlNode oneToManyNode = node.SelectSingleNode(HbmConstants.nsOneToMany, namespaceManager);

            if (oneToManyNode != null)
            {
                OneToMany oneToMany = new OneToMany(model.Owner);
                model.Element = oneToMany;
                BindOneToMany(oneToManyNode, oneToMany);
                //we have to set up the table later!! yuck
            }
            else
            {
                //TABLE
                XmlAttribute tableNode = node.Attributes["table"];
                string       tableName;
                if (tableNode != null)
                {
                    tableName = mappings.NamingStrategy.TableName(tableNode.Value);
                }
                else
                {
                    tableName = mappings.NamingStrategy.PropertyToTableName(className, path);
                }
                XmlAttribute schemaNode  = node.Attributes["schema"];
                string       schema      = schemaNode == null ? mappings.SchemaName : schemaNode.Value;
                XmlAttribute catalogNode = node.Attributes["catalog"];
                string       catalog     = catalogNode == null ? mappings.CatalogName : catalogNode.Value;

                XmlAttribute actionNode = node.Attributes["schema-action"];
                string       action     = actionNode == null ? "all" : actionNode.Value;

                model.CollectionTable = mappings.AddTable(schema, catalog, tableName, null, false, action);

                log.InfoFormat("Mapping collection: {0} -> {1}", model.Role, model.CollectionTable.Name);
            }

            //SORT
            XmlAttribute sortedAtt = node.Attributes["sort"];

            // unsorted, natural, comparator.class.name
            if (sortedAtt == null || sortedAtt.Value.Equals("unsorted"))
            {
                model.IsSorted = false;
            }
            else
            {
                model.IsSorted = true;
                if (!sortedAtt.Value.Equals("natural"))
                {
                    string comparatorClassName = FullQualifiedClassName(sortedAtt.Value, mappings);
                    model.ComparerClassName = comparatorClassName;
                }
            }

            //ORPHAN DELETE (used for programmer error detection)
            XmlAttribute cascadeAtt = node.Attributes["cascade"];

            if (cascadeAtt != null && cascadeAtt.Value.IndexOf("delete-orphan") >= 0)
            {
                model.HasOrphanDelete = true;
            }

            bool?isGeneric = null;

            XmlAttribute genericAtt = node.Attributes["generic"];

            if (genericAtt != null)
            {
                isGeneric = bool.Parse(genericAtt.Value);
            }

            System.Type collectionType = null;

            if (!isGeneric.HasValue && containingType != null)
            {
                collectionType = GetPropertyType(node, containingType, GetPropertyName(node));
                isGeneric      = collectionType.IsGenericType;
            }

            model.IsGeneric = isGeneric ?? false;

            if (model.IsGeneric)
            {
                // Determine the generic arguments using reflection
                if (collectionType == null)
                {
                    collectionType = GetPropertyType(node, containingType, GetPropertyName(node));
                }
                System.Type[] genericArguments = collectionType.GetGenericArguments();
                model.GenericArguments = genericArguments;
            }

            HandleCustomSQL(node, model);

            //set up second pass
            if (model is List)
            {
                AddListSecondPass(node, (List)model, inheritedMetas);
            }

            else if (model is Map)
            {
                AddMapSecondPass(node, (Map)model, inheritedMetas);
            }

            else if (model is Set)
            {
                AddSetSecondPass(node, (Set)model, inheritedMetas);
            }

            else if (model is IdentifierCollection)
            {
                AddIdentifierCollectionSecondPass(node, (IdentifierCollection)model, inheritedMetas);
            }

            else
            {
                AddCollectionSecondPass(node, model, inheritedMetas);
            }

            foreach (XmlNode filter in node.SelectNodes(HbmConstants.nsFilter, namespaceManager))
            {
                ParseFilter(filter, model);
            }

            XmlNode loader = node.SelectSingleNode(HbmConstants.nsLoader, namespaceManager);

            if (loader != null)
            {
                model.LoaderName = XmlHelper.GetAttributeValue(loader, "query-ref");
            }

            XmlNode key = node.SelectSingleNode(HbmConstants.nsKey, namespaceManager);

            if (key != null)
            {
                model.ReferencedPropertyName = XmlHelper.GetAttributeValue(key, "property-ref");
            }
        }
示例#12
0
        /// <remarks>
        /// Called for all collections
        /// </remarks>
        private void BindCollectionSecondPass(XmlNode node, Mapping.Collection model,
                                              IDictionary <string, PersistentClass> persistentClasses, IDictionary <string, MetaAttribute> inheritedMetas)
        {
            if (model.IsOneToMany)
            {
                OneToMany       oneToMany            = (OneToMany)model.Element;
                string          associatedEntityName = oneToMany.ReferencedEntityName;
                PersistentClass persistentClass;
                if (persistentClasses.TryGetValue(associatedEntityName, out persistentClass) == false)
                {
                    throw new MappingException("Association references unmapped class: " + associatedEntityName);
                }
                oneToMany.AssociatedClass = persistentClass;
                model.CollectionTable     = persistentClass.Table;

                if (log.IsInfoEnabled)
                {
                    log.Info("mapping collection: " + model.Role + " -> " + model.CollectionTable.Name);
                }
            }

            //CHECK
            XmlAttribute chNode = node.Attributes["check"];

            if (chNode != null)
            {
                model.CollectionTable.AddCheckConstraint(chNode.Value);
            }

            //contained elements:
            foreach (XmlNode subnode in node.ChildNodes)
            {
                //I am only concerned with elements that are from the nhibernate namespace
                if (subnode.NamespaceURI != Configuration.MappingSchemaXMLNS)
                {
                    continue;
                }

                string name = subnode.LocalName;                 //.Name;

                if ("key".Equals(name) || "generated-key".Equals(name))
                {
                    string    propRef = model.ReferencedPropertyName;
                    IKeyValue keyValue;
                    if (propRef == null)
                    {
                        keyValue = model.Owner.Identifier;
                    }
                    else
                    {
                        keyValue = (IKeyValue)model.Owner.GetProperty(propRef).Value;
                    }
                    DependantValue key = new DependantValue(model.CollectionTable, keyValue);
                    if (subnode.Attributes["on-delete"] != null)
                    {
                        key.IsCascadeDeleteEnabled = "cascade".Equals(subnode.Attributes["on-delete"].Value);
                    }
                    BindSimpleValue(subnode, key, model.IsOneToMany, Mapping.Collection.DefaultKeyColumnName);
                    if (key.Type.ReturnedClass.IsArray)
                    {
                        throw new MappingException("illegal use of an array as an identifier (arrays don't reimplement Equals)");
                    }
                    model.Key = key;


                    XmlAttribute notNull = subnode.Attributes["not-null"];
                    key.SetNullable(notNull == null || IsFalse(notNull.Value));
                    XmlAttribute updateable = subnode.Attributes["update"];
                    key.SetUpdateable(updateable == null || IsTrue(updateable.Value));
                }
                else if ("element".Equals(name))
                {
                    var elt = new SimpleValue(model.CollectionTable);
                    model.Element = elt;
                    if (model.IsGeneric)
                    {
                        switch (model.GenericArguments.Length)
                        {
                        case 1:
                            // a collection with a generic type parameter
                            elt.TypeName = model.GenericArguments[0].AssemblyQualifiedName;
                            break;

                        case 2:
                            // a map (IDictionary) with 2 parameters
                            elt.TypeName = model.GenericArguments[1].AssemblyQualifiedName;
                            break;
                        }
                    }
                    BindSimpleValue(subnode, elt, true, Mapping.Collection.DefaultElementColumnName);
                }
                else if ("many-to-many".Equals(name))
                {
                    ManyToOne element = new ManyToOne(model.CollectionTable);
                    model.Element = element;
                    BindManyToOne(subnode, element, Mapping.Collection.DefaultElementColumnName, false);
                    BindManyToManySubelements(model, subnode);
                }
                else if ("composite-element".Equals(name))
                {
                    Component element = new Component(model);
                    model.Element = element;
                    BindComponent(subnode, element, null, null, null, model.Role + ".element", true, inheritedMetas);
                }
                else if ("many-to-any".Equals(name))
                {
                    Any element = new Any(model.CollectionTable);
                    model.Element = element;
                    BindAny(subnode, element, true);
                }
                else if ("jcs-cache".Equals(name) || "cache".Equals(name))
                {
                    XmlAttribute usageNode = subnode.Attributes["usage"];
                    model.CacheConcurrencyStrategy = (usageNode != null) ? usageNode.Value : null;
                    XmlAttribute regionNode = subnode.Attributes["region"];
                    model.CacheRegionName = (regionNode != null) ? regionNode.Value : null;
                }
            }
        }
示例#13
0
        private void BindOneToMany(HbmOneToMany oneToManyMapping, OneToMany model)
        {
            model.ReferencedEntityName = GetEntityName(oneToManyMapping, mappings);

            model.IsIgnoreNotFound = oneToManyMapping.NotFoundMode == HbmNotFoundMode.Ignore;
        }
示例#14
0
        /// <remarks>
        /// Called for all collections. <paramref name="containingType" /> parameter
        /// was added in NH to allow for reflection related to generic types.
        /// </remarks>
        private void BindCollection(ICollectionPropertiesMapping collectionMapping, Mapping.Collection model, string className,
                                    string path, System.Type containingType, IDictionary <string, MetaAttribute> inheritedMetas)
        {
            // ROLENAME
            model.Role = path;

            model.IsInverse          = collectionMapping.Inverse;
            model.IsMutable          = collectionMapping.Mutable;
            model.IsOptimisticLocked = collectionMapping.OptimisticLock;
            model.OrderBy            = collectionMapping.OrderBy;
            model.Where = collectionMapping.Where;
            if (collectionMapping.BatchSize.HasValue)
            {
                model.BatchSize = collectionMapping.BatchSize.Value;
            }

            // PERSISTER
            if (!string.IsNullOrEmpty(collectionMapping.PersisterQualifiedName))
            {
                model.CollectionPersisterClass = ClassForNameChecked(collectionMapping.PersisterQualifiedName, mappings,
                                                                     "could not instantiate collection persister class: {0}");
            }

            if (!string.IsNullOrEmpty(collectionMapping.CollectionType))
            {
                TypeDef typeDef = mappings.GetTypeDef(collectionMapping.CollectionType);
                if (typeDef != null)
                {
                    model.TypeName       = typeDef.TypeClass;
                    model.TypeParameters = typeDef.Parameters;
                }
                else
                {
                    model.TypeName = FullQualifiedClassName(collectionMapping.CollectionType, mappings);
                }
            }

            // FETCH STRATEGY
            InitOuterJoinFetchSetting(collectionMapping, model);

            // LAZINESS
            InitLaziness(collectionMapping, model);

            var oneToManyMapping = collectionMapping.ElementRelationship as HbmOneToMany;

            if (oneToManyMapping != null)
            {
                var oneToMany = new OneToMany(model.Owner);
                model.Element = oneToMany;
                BindOneToMany(oneToManyMapping, oneToMany);
                //we have to set up the table later!! yuck
            }
            else
            {
                //TABLE
                string tableName = !string.IsNullOrEmpty(collectionMapping.Table)
                                                        ? mappings.NamingStrategy.TableName(collectionMapping.Table)
                                                        : mappings.NamingStrategy.PropertyToTableName(className, path);

                string schema  = string.IsNullOrEmpty(collectionMapping.Schema) ? mappings.SchemaName : collectionMapping.Schema;
                string catalog = string.IsNullOrEmpty(collectionMapping.Catalog) ? mappings.CatalogName : collectionMapping.Catalog;

                // TODO NH : add schema-action to the xsd
                model.CollectionTable = mappings.AddTable(schema, catalog, tableName, collectionMapping.Subselect, false, "all");

                log.InfoFormat("Mapping collection: {0} -> {1}", model.Role, model.CollectionTable.Name);
            }

            //SORT
            var sortedAtt = collectionMapping.Sort;

            // unsorted, natural, comparator.class.name
            if (string.IsNullOrEmpty(sortedAtt) || sortedAtt.Equals("unsorted"))
            {
                model.IsSorted = false;
            }
            else
            {
                model.IsSorted = true;
                if (!sortedAtt.Equals("natural"))
                {
                    string comparatorClassName = FullQualifiedClassName(sortedAtt, mappings);
                    model.ComparerClassName = comparatorClassName;
                }
            }

            //ORPHAN DELETE (used for programmer error detection)
            var cascadeAtt = collectionMapping.Cascade;

            if (!string.IsNullOrEmpty(cascadeAtt) && cascadeAtt.IndexOf("delete-orphan") >= 0)
            {
                model.HasOrphanDelete = true;
            }

            // GENERIC
            bool?isGeneric = collectionMapping.Generic;

            System.Type collectionType = null;
            if (!isGeneric.HasValue && containingType != null)
            {
                collectionType = GetPropertyType(containingType, collectionMapping.Name, collectionMapping.Access);
                isGeneric      = collectionType.IsGenericType;
            }

            model.IsGeneric = isGeneric ?? false;

            if (model.IsGeneric)
            {
                // Determine the generic arguments using reflection
                if (collectionType == null)
                {
                    collectionType = GetPropertyType(containingType, collectionMapping.Name, collectionMapping.Access);
                }
                System.Type[] genericArguments = collectionType.GetGenericArguments();
                model.GenericArguments = genericArguments;
            }

            // CUSTOM SQL
            HandleCustomSQL(collectionMapping, model);
            if (collectionMapping.SqlLoader != null)
            {
                model.LoaderName = collectionMapping.SqlLoader.queryref;
            }

            new FiltersBinder(model, Mappings).Bind(collectionMapping.Filters);

            var key = collectionMapping.Key;

            if (key != null)
            {
                model.ReferencedPropertyName = key.propertyref;
            }
        }
示例#15
0
 public OneToManyConstraint(OneToMany relation)
 {
     _relation = relation;
 }
示例#16
0
        public void TestThreeEdges()
        {
            // build graph.
            var routerDb = new RouterDb();

            routerDb.AddSupportedVehicle(VehicleMock.Car());
            routerDb.Network.AddVertex(0, 0, 0);
            routerDb.Network.AddVertex(1, 1, 1);
            routerDb.Network.AddVertex(2, 2, 2);
            routerDb.Network.AddEdge(0, 1, new Itinero.Data.Network.Edges.EdgeData()
            {
                Distance = 100,
                Profile  = 0,
                MetaId   = 0
            });
            routerDb.Network.AddEdge(1, 2, new Itinero.Data.Network.Edges.EdgeData()
            {
                Distance = 100,
                Profile  = 0,
                MetaId   = 0
            });
            routerDb.Network.AddEdge(2, 0, new Itinero.Data.Network.Edges.EdgeData()
            {
                Distance = 100,
                Profile  = 0,
                MetaId   = 0
            });

            // run algorithm 0->(1, 2).
            var algorithm = new OneToMany(new Router(routerDb), VehicleMock.Car().Fastest(), (x) => new uint[0][],
                                          routerDb.Network.CreateRouterPointForVertex(0),
                                          new RouterPoint[] {
                routerDb.Network.CreateRouterPointForVertex(1),
                routerDb.Network.CreateRouterPointForVertex(2)
            }, float.MaxValue);

            algorithm.Run();

            Assert.IsTrue(algorithm.HasRun);
            Assert.IsTrue(algorithm.HasSucceeded);

            var weights = algorithm.Weights;

            Assert.IsNotNull(weights);
            Assert.AreEqual(2, weights.Length);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, weights[0], 0.001);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, weights[1], 0.001);

            var path = algorithm.GetPath(0);

            Assert.IsNotNull(path);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, path.Weight, 0.001);
            Assert.AreEqual(1, path.Vertex);
            path = path.From;
            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Weight, 0.001);
            Assert.AreEqual(0, path.Vertex);
            path = path.From;
            Assert.IsNull(path);

            path = algorithm.GetPath(1);
            Assert.IsNotNull(path);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, path.Weight, 0.001);
            Assert.AreEqual(2, path.Vertex);
            path = path.From;
            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Weight, 0.001);
            Assert.AreEqual(0, path.Vertex);
            path = path.From;
            Assert.IsNull(path);

            // run algorithm 1->(0, 2).
            algorithm = new OneToMany(new Router(routerDb), VehicleMock.Car().Fastest(), (x) => new uint[0][],
                                      routerDb.Network.CreateRouterPointForVertex(1),
                                      new RouterPoint[] {
                routerDb.Network.CreateRouterPointForVertex(0),
                routerDb.Network.CreateRouterPointForVertex(2)
            }, float.MaxValue);
            algorithm.Run();

            Assert.IsTrue(algorithm.HasRun);
            Assert.IsTrue(algorithm.HasSucceeded);

            weights = algorithm.Weights;
            Assert.IsNotNull(weights);
            Assert.AreEqual(2, weights.Length);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, weights[0], 0.001);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, weights[1], 0.001);

            path = algorithm.GetPath(0);
            Assert.IsNotNull(path);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, path.Weight, 0.001);
            Assert.AreEqual(0, path.Vertex);
            path = path.From;
            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Weight, 0.001);
            Assert.AreEqual(1, path.Vertex);
            path = path.From;
            Assert.IsNull(path);

            path = algorithm.GetPath(1);
            Assert.IsNotNull(path);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, path.Weight, 0.001);
            Assert.AreEqual(2, path.Vertex);
            path = path.From;
            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Weight, 0.001);
            Assert.AreEqual(1, path.Vertex);
            path = path.From;
            Assert.IsNull(path);

            // run algorithm 2->(0, 1).
            algorithm = new OneToMany(new Router(routerDb), VehicleMock.Car().Fastest(), (x) => new uint[0][],
                                      routerDb.Network.CreateRouterPointForVertex(2),
                                      new RouterPoint[] {
                routerDb.Network.CreateRouterPointForVertex(0),
                routerDb.Network.CreateRouterPointForVertex(1)
            }, float.MaxValue);
            algorithm.Run();

            Assert.IsTrue(algorithm.HasRun);
            Assert.IsTrue(algorithm.HasSucceeded);

            weights = algorithm.Weights;
            Assert.IsNotNull(weights);
            Assert.AreEqual(2, weights.Length);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, weights[0], 0.001);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, weights[1], 0.001);

            path = algorithm.GetPath(0);
            Assert.IsNotNull(path);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, path.Weight, 0.001);
            Assert.AreEqual(0, path.Vertex);
            path = path.From;
            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Weight, 0.001);
            Assert.AreEqual(2, path.Vertex);
            path = path.From;
            Assert.IsNull(path);

            path = algorithm.GetPath(1);
            Assert.IsNotNull(path);
            Assert.AreEqual(100 * VehicleMock.Car().Fastest().FactorAndSpeed(null).Value, path.Weight, 0.001);
            Assert.AreEqual(1, path.Vertex);
            path = path.From;
            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Weight, 0.001);
            Assert.AreEqual(2, path.Vertex);
            path = path.From;
            Assert.IsNull(path);
        }
示例#17
0
        static void Main(string[] args)
        {
            #region Declaration And Initialization Section.
            string      str_Option     = string.Empty;
            string      str_TableName  = string.Empty;
            string      str_FolderPath = string.Empty;
            Tools.Tools oTools         = new Tools.Tools();

            Hierarchy     oHierarchy        = new Hierarchy();
            OneToMany     oOneToMany        = new OneToMany();
            List <String> oList_ChildTables = new List <string>();

            Hierarchy oApplicationHierarchy = new Hierarchy();


            // Initialization.
            // ---------------------------------------------------------------------
            oCodeBooster.Tables_Excluded_From_Generatrion_Process = new List <string>();
            oCodeBooster.KeysMapper = new Dictionary <string, string>();
            oCodeBooster.APIMethodsGenerationMode          = Enum_APIMethodsGenerationMode.Selection;
            oCodeBooster.APIMethodsSelection               = new List <string>();
            oCodeBooster.Methods_With_Events               = new List <string>();
            oCodeBooster.DefaultRecordsToCreate            = new Dictionary <string, string>();
            oCodeBooster.Tables_Static_Data                = new List <string>();
            oCodeBooster.NonSetup_Fields                   = new List <string>();
            oCodeBooster.Tables_To_Create_Get_By_Hierarchy = new List <HierarchyBracket>();
            oCodeBooster.Tables_Exluded_From_12M_Hanlder   = new List <string>();
            oCodeBooster.ByPassed_PreCheck_Notifications   = new List <Notification_ByPassing>();
            oCodeBooster.AssemblyPath                      = ConfigurationManager.AppSettings["BLC_PATH"];
            oCodeBooster.Is_Generate_API_Caller            = true;
            oCodeBooster.Is_Generate_Kotlin_API_Caller     = true;
            oCodeBooster.Is_Generate_Swift_API_Caller      = true;
            oCodeBooster.Android_Package_Name              = "com.example.roni.myapplication";
            oCodeBooster.Is_Apply_Minification             = false;
            oCodeBooster.Is_Show_Notifications_In_Console  = true;
            oCodeBooster.Is_Create_DB_Demo                 = false;
            oCodeBooster.Is_SaaS_Disabled                  = true;
            oCodeBooster.Is_InLine_Audit_Disabled          = true;
            oCodeBooster.Is_Setup_Disabled                 = true;
            oCodeBoosterClient.Is_Handle_Custom_Procedures = true;

            oCodeBoosterClient.Authenticate_User();
            oCodeBoosterClient.Authenticate_User();



            Params_ConvertTypeSchemaToUIFields oParams_ConvertTypeSchemaToUIFields = new Params_ConvertTypeSchemaToUIFields();
            Search_AdvancedProp oSearch_AdvancedProp = new Search_AdvancedProp();
            WebClient           oWebClient           = new WebClient();
            UIFields            oUIFields            = new UIFields();
            // ---------------------------------------------------------------------


            #region Exluded Tables From Generation Process
            oCodeBooster.Tables_Excluded_From_Generatrion_Process = new List <string>();
            //oCodeBooster.Tables_Excluded_From_Generatrion_Process.Add("[TBL_MENU]");
            //oCodeGenerator.Tables_Excluded_From_Generatrion_Process.Add("[TBL_ACCOUNT]");
            #endregion
            #region Excluded Properties From Generation Process
            oCodeBooster.Properties_Excluded_From_Generation_Process = new List <string>();
            //oCodeBooster.Properties_Excluded_From_Generation_Process.Add("[TBL_LEG_PRODUCT]");
            //oCodeBooster.Properties_Excluded_From_Generation_Process.Add("[TBL_LEG_PRODUCT_EINFO]");
            #endregion
            #region Keys Mapper
            //oCodeBooster.KeysMapper.Add("[MAIN_ID]", "[PERSON_ID]");
            //oCodeBooster.KeysMapper.Add("[REL_ID]", "[PERSON_ID]");
            #endregion
            #region Events
            //oCodeBooster.Methods_With_Events.Add("Edit_Car");
            //oCodeBooster.Methods_With_Events.Add("Delete_Car");
            //oCodeBooster.Methods_With_Events.Add("Edit_Uploaded_file");
            //oCodeBooster.Methods_With_Events.Add("Delete_Person");
            #endregion
            #region Excluding Tables From 12M Hanlder
            oCodeBooster.Tables_Exluded_From_12M_Hanlder = new List <string>();
            oCodeBooster.Tables_Exluded_From_12M_Hanlder.Add("[TBL_OWNER]");
            oCodeBooster.Tables_Exluded_From_12M_Hanlder.Add("[TBL_USER]");
            oCodeBooster.Tables_Exluded_From_12M_Hanlder.Add("[TBL_INC]");
            oCodeBooster.Tables_Exluded_From_12M_Hanlder.Add("[TBL_SETUP]");
            #endregion
            #region Handling Static Data
            //oCodeBooster.Tables_Static_Data.Add("[TBL_LOC_L1]");
            //oCodeBooster.Tables_Static_Data.Add("[TBL_LOC_L2]");
            //oCodeBooster.Tables_Static_Data.Add("[TBL_LOC_L3]");
            //oCodeBooster.Tables_Static_Data.Add("[TBL_LOC_L4]");
            #endregion
            #region Uploaded_files
            //oCodeBooster.Is_Uploaded_File_Feature = true;
            //oCodeBooster.Uploaded_Files_BackEnd_Events = new List<Uploaded_File_BackEnd_Event>();
            //oCodeBooster.Uploaded_Files_BackEnd_Events.Add
            //    (
            //        new Uploaded_File_BackEnd_Event()
            //        {
            //            TBL_NAME = "[TBL_USER]",
            //            UI_METHOD_NAME = "Get_User_By_USER_ID", Mode = 1
            //        }
            //    );
            //oCodeBooster.Uploaded_Files_BackEnd_Events.Add
            //   (
            //       new Uploaded_File_BackEnd_Event()
            //       {
            //           TBL_NAME = "[TBL_USER]",
            //           UI_METHOD_NAME = "Get_User_By_Where",
            //           Mode = 1
            //       }
            //   );
            #endregion
            #region Defining Non Setup Fields [Fields That ends with CODE by they are not Setup Fields]
            //oCodeBooster.NonSetup_Fields.Add("[LOC_L1_CODE]");
            //oCodeBooster.NonSetup_Fields.Add("[LOC_L2_CODE]");
            //oCodeBooster.NonSetup_Fields.Add("[LOC_L3_CODE]");
            //oCodeBooster.NonSetup_Fields.Add("[LOC_L4_CODE]");
            #endregion
            #region Audit
            //oCodeBooster.List_Tables_To_Audit = new List<string>();
            //oCodeBooster.List_Tables_To_Audit.Add("[TBL_CAR]");
            #endregion
            #region Custom Procedures / Queries
            //oCodeBooster.List_Procedure_Info = new List<Procedure_Info>();
            //oCodeBooster.List_Procedure_Info.Add
            //        (
            //            new Procedure_Info()
            //            {
            //                Alias = "Get_Person_Test",
            //                Procedure_Name = "UP_GET_TEST",
            //                Result_CLR_Type = "Person",
            //                Result_Mode = Enum_Procedure_Result_Mode.List
            //            }
            //        );

            //oCodeBooster.List_Procedure_Info.Add
            //       (
            //           new Procedure_Info()
            //           {
            //               Alias = "Get_Stats",
            //               Procedure_Name = "GET_STATS",
            //               Result_CLR_Type = "dynamic",
            //               Result_Mode = Enum_Procedure_Result_Mode.List,
            //               Fields = "METHOD_NAME|AVG|NBR|TOTAL_EXECUTE_TIME"
            //           }
            //       );

            //oCodeBooster.List_Procedure_Info.Add
            //      (
            //          new Procedure_Info()
            //          {
            //              Alias = "Get_Stats_2",
            //              Procedure_Name = "GET_STATS_WITH_PARAM",
            //              Result_CLR_Type = "dynamic",
            //              Result_Mode = Enum_Procedure_Result_Mode.List,
            //              Fields = "METHOD_NAME|AVG|NBR|TOTAL_EXECUTE_TIME"
            //          }
            //      );
            #endregion
            #region ByPassing Notification
            oCodeBooster.ByPassed_PreCheck_Notifications = new List <Notification_ByPassing>();
            oCodeBooster.ByPassed_PreCheck_Notifications.Add(new Notification_ByPassing()
            {
                TABLE_NAME = "[TBL_USER_TYPE]", COLUMN_NAME = "[USER_TYPE_CODE]", My_PreCheck_To_ByPass = Enum_Precheck_Enum.INVALID_CODE_FIELD
            });
            oCodeBooster.ByPassed_PreCheck_Notifications.Add(new Notification_ByPassing()
            {
                TABLE_NAME = "[TBL_PERSON]", COLUMN_NAME = "[CHILD_PERSON_ID]", My_PreCheck_To_ByPass = Enum_Precheck_Enum.MAPPED_KEY
            });
            #endregion
            #region Caching
            //oCodeBooster.Is_Caching_Enabled = true;
            //oCodeBooster.Methods_With_Caching = new List<Caching_Topology>();
            //oCodeBooster.Methods_With_Caching.Add(new Caching_Topology() { Method_Name = "Get_Car_By_OWNER_ID", Caching_Level = Enum_Caching_Level.Application });

            //oCodeBooster.Cash_Dropper_Collection = new List<string>();
            //oCodeBooster.Cash_Dropper_Collection.Add("[TBL_CAR]");


            #region System
            //oCodeBooster.Methods_With_Caching.Add(new Caching_Topology() { Method_Name = "Get_City_By_COUNTRY_ID_Adv", Caching_Level = Enum_Caching_Level.Application });
            #endregion


            #endregion
            #region Cascade
            oCodeBooster.List_Cascade_Tables = new List <Cascade>();
            //oCodeBooster.List_Cascade_Tables.Add(new Cascade() { ParentTable = "[TBL_AC_IMAGE]", ChildTables = new List<string>() { "[TBL_AC_IMAGE_RC]" } });

            #endregion

            #endregion
            #region Body Section
            Console.WriteLine("Enter An Option:");
            Console.WriteLine("001 --> Create SP's & BLC Layer");
            Console.WriteLine("002 --> Generate API / JSON Code");
            Console.WriteLine("003 --> Generate UI");
            Console.WriteLine("051 --> Generate Mobile Native UI");

            str_Option = Console.ReadLine();


            #region API


            // Car
            //----------------------------
            //oCodeBooster.APIMethodsSelection.Add("Edit_Car");
            //oCodeBooster.APIMethodsSelection.Add("Delete_Car");
            //oCodeBooster.APIMethodsSelection.Add("Get_Car_By_OWNER_ID");
            //oCodeBooster.APIMethodsSelection.Add("Authenticate");
            //----------------------------

            #endregion
            #region Advanced Options
            oCodeBooster.Is_By_Criteria_Shadowed           = true;
            oCodeBooster.Is_Generate_By_RelatedID_List     = true;
            oCodeBooster.By_Related_ID_List_GenerationMode = Enum_By_Related_ID_List_GenerationMode.All;
            oCodeBooster.Is_OnDemand_DALC = true;
            #endregion
            #region AZURE
            //oCodeBooster.Is_AZURE_Enabled = false;
            #endregion
            #region MemCached
            //oCodeBooster.Is_MemCached_Enabled = true;
            #endregion

            oCodeBoosterClient.Local_Patch_Folder            = @"D:\";
            oCodeBoosterClient.Is_Apply_CB_Rules             = true;
            oCodeBoosterClient.Show_Embedded_TSql_Exceptions = false;
            oCodeBooster.Is_Profiling_Enabled          = false;
            oCodeBooster.Is_Multilingual_Enabled       = false;
            oCodeBooster.Is_BackOffice_Enabled         = false;
            oCodeBooster.Is_Offline_Enabled            = false;
            oCodeBooster.Is_Summary_Enabled            = false;
            oCodeBooster.Is_EnvCode_Enabled            = false;
            oCodeBooster.Is_Generate_API_Caller        = true;
            oCodeBooster.Is_Generate_Kotlin_API_Caller = true;
            oCodeBooster.Is_Generate_Swift_API_Caller  = true;
            oCodeBooster.Is_Embed_USE_DB         = true;
            oCodeBooster.UI_Root_Folder          = @"C:\inetpub\wwwroot\ClinicPlusWeb\Content";
            oCodeBooster.Is_By_Criteria_Shadowed = true;
            #region Inheritance
            #endregion
            switch (str_Option)
            {
                #region case "001":
            case "001":
                oCodeBooster.Is_Method_Monitoring_Enabled                = false;
                oCodeBooster.Is_Renamed_Routines_Generation_Stopped      = true;
                oCodeBooster.Is_Count_UDF_Generation_Stopped             = true;
                oCodeBooster.Is_Create_Default_Record_Generation_Stopped = true;
                oCodeBooster.Is_Get_Rows_Generations_Stopped             = true;
                oCodeBooster.Methods_With_Events_By_Ref = new List <string>();
                //oCodeBooster.Methods_With_Events_By_Ref.Add("Edit_PersoN");
                oCodeBooster.List_Reset_Topology = new List <Reset_Topology>();
                //oCodeBooster.List_Reset_Topology.Add(new Reset_Topology() { ParentTable = "[TBL_PERSONS]", ChildTables = new List<string>() { "[TBL_ADDRES]", "[TBL_CONTACT]" } });

                oCodeBooster.List_Eager_Loading = new List <Eager_Loading>();
                //oCodeBooster.List_Eager_Loading.Add(new Eager_Loading() { Method_Name = "Get_Ac_By_AC_ID_Adv", ParentTable = "[TBL_AC]", ChildTables = new List<string>() { "[TBL_AC_AMENITY]", "[TBL_AC_CARD]", "[TBL_AC_CONTACT]", "[TBL_AC_IMAGE]", "[TBL_AC_SLIDE]","[TBL_AC_SOCIAL]", "[TBL_AC_HWS_INFO]", "[TBL_AC_HWS_XPAGE]", "[TBL_AC_PICKUP]", "[TBL_AC_THEME]", "[TBL_AC_DESCRIPTION]", "[TBL_AC_GW]" } });

                #region One2Many
                oCodeBooster.List_Inheritance = new List <Inheritance>();
                //oCodeBooster.List_Inheritance.Add(new Inheritance() { ParentTable = "[TBL_PERSON]", ChildTable = "[TBL_ADDRESS]", RelationField = "[PERSON_ID]", RelationType = "12M" });
                #endregion
                #region Generate SP's & BLC Layer
                oCodeBoosterClient.GenerateAllSPAndBLCLayer();
                #endregion
                break;

                #endregion
                #region case "002":
            case "002":

                oCodeBooster.My_Enum_API_Target        = Enum_API_Target.WebAPI;
                oCodeBooster.My_Enum_API_Accessibility = Enum_API_Accessibility.Same_Domain;

                oCodeBooster.List_ByPass_Ticketing = new List <string>();
                oCodeBooster.List_ByPass_Ticketing.Add("Authenticate");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_NearBy_Ac_List");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Ac_By_OWNER_ID_Adv");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Currency_By_OWNER_ID");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Language_By_OWNER_ID");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Ac_By_AC_ID_Adv");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Rate_Matrix");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Ac_Front_Data");
                //oCodeBooster.List_ByPass_Ticketing.Add("Clear_Application_Cached_Entry");
                //oCodeBooster.List_ByPass_Ticketing.Add("Delete_Fictitious_Bookings");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Startup_Data_Signature");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Startup_Data");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Person_By_Email");
                //oCodeBooster.List_ByPass_Ticketing.Add("CheckUserExistence");
                //oCodeBooster.List_ByPass_Ticketing.Add("Edit_Person");
                //oCodeBooster.List_ByPass_Ticketing.Add("Clear_Application_Cached_Entry");
                //oCodeBooster.List_ByPass_Ticketing.Add("Clear_Gate_Rate_Matrix_Cached_Entry");
                //oCodeBooster.List_ByPass_Ticketing.Add("Clear_Get_Ac_Front_Data_Application_Cached_Entry_By_Ac");
                //oCodeBooster.List_ByPass_Ticketing.Add("Clear_Cached_Hotel_Page");
                //oCodeBooster.List_ByPass_Ticketing.Add("Issue_Booking");
                //oCodeBooster.List_ByPass_Ticketing.Add("Seriliaze_Booking_02");
                //oCodeBooster.List_ByPass_Ticketing.Add("Send_Email");
                //oCodeBooster.List_ByPass_Ticketing.Add("Request_Booking_Cancelation");
                //oCodeBooster.List_ByPass_Ticketing.Add("Convert_Booking_Data_URI_To_Image");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Guest_Specific_Booking");
                ////oCodeBooster.List_ByPass_Ticketing.Add("Send_HWS_ContactUs_Email");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Ac_pickup_By_AC_ID_Adv");
                ////oCodeBooster.List_ByPass_Ticketing.Add("Chm_Booking_Handler");
                //oCodeBooster.List_ByPass_Ticketing.Add("Get_Ac_Lowest_Price_PerCountry");



                // --------------
                oCodeBoosterClient.GenerateAPILayer();
                // --------------

                break;

                #endregion
                #region case "003":
            case "003":

                // --------------
                UIFields oUIFields_EditUI   = new UIFields();
                UIFields oUIFields_Criteria = new UIFields();
                UIFields oUIFields_Result   = new UIFields();
                // --------------

                // --------------
                oCodeBooster.My_Enum_UI_Target    = Enum_UI_Target.HTML5;
                oCodeBooster.My_Enum_HTML5_Target = Enum_HTML5_Target.NG;
                // --------------


                // Gather Required Data.
                // --------------
                oCodeBoosterClient.Gather_Required_Data();
                // --------------

                // Cleans UI Folder
                // --------------
                oCodeBoosterClient.Cleanse_UI_Patch_Folder();
                // --------------

                #region Person
                #region Search Screen
                oUIFields_Criteria = new UIFields();
                oUIFields_Criteria.MainTableName = "[TBL_PERSON]";
                oUIFields_Criteria.Based_On_Type = "BLC.Params_Get_Person_By_Criteria";

                oUIFields_Result = new UIFields();
                oUIFields_Result.MainTableName = "[TBL_PERSON]";
                oUIFields_Result.Based_On_Type = "BLC.Person";
                oUIFields_Result.GetMethodName = "Get_Person_By_Criteria";
                oUIFields_Result.GridFields    = new List <GridField>();



                oSearch_AdvancedProp = new Search_AdvancedProp();
                oSearch_AdvancedProp.ContainerMargins = "0,5,0,5";
                oCodeBooster.Entity_FriendlyName      = "Person";
                oCodeBoosterClient.Generate_ListUI(Enum_SearchMethod.With_Criteria_Section, oUIFields_Criteria, oUIFields_Result, oSearch_AdvancedProp);
                #endregion
                #endregion


                // Send UI Patch
                // -------------
                oCodeBoosterClient.Send_UI_Patch();
                // --------------

                break;

                #endregion
                #region Case "051"
            case "051":
                Params_Generate_Mobile_Native_UI oParams_Generate_Mobile_Native_UI = new Params_Generate_Mobile_Native_UI();
                oParams_Generate_Mobile_Native_UI.MOBILE_PLATFORM       = "ANDROID";
                oParams_Generate_Mobile_Native_UI.VIEW_TYPE             = "001";
                oParams_Generate_Mobile_Native_UI.TABLE_NAME            = "[TBL_AC]";
                oParams_Generate_Mobile_Native_UI.GET_METHOD_NAME       = "Get_Ac_By_Where";
                oParams_Generate_Mobile_Native_UI.TITLE                 = "Hotels";
                oParams_Generate_Mobile_Native_UI.BAR_BUTTON_ITEM_TITLE = "Bla Bla";
                oParams_Generate_Mobile_Native_UI.IMAGE_BASE_URL        = @"https://www.igloorooms.com/irimages/aclogo/AcLogo_\(myData[indexPath.row].AC_ID!).jpg";
                //oCodeBoosterClient.Generate_Mobile_Native_UI(oParams_Generate_Mobile_Native_UI);

                oParams_Generate_Mobile_Native_UI = new Params_Generate_Mobile_Native_UI();
                oParams_Generate_Mobile_Native_UI.MOBILE_PLATFORM       = "IOS";
                oParams_Generate_Mobile_Native_UI.VIEW_TYPE             = "001";
                oParams_Generate_Mobile_Native_UI.TABLE_NAME            = "[TBL_AC]";
                oParams_Generate_Mobile_Native_UI.GET_METHOD_NAME       = "Get_Ac_By_Where";
                oParams_Generate_Mobile_Native_UI.TITLE                 = "Hotels";
                oParams_Generate_Mobile_Native_UI.BAR_BUTTON_ITEM_TITLE = "Bla Bla";
                oParams_Generate_Mobile_Native_UI.IMAGE_BASE_URL        = @"https://www.igloorooms.com/irimages/aclogo/AcLogo_\(myData[indexPath.row].AC_ID!).jpg";
                //oCodeBoosterClient.Generate_Mobile_Native_UI(oParams_Generate_Mobile_Native_UI);

                break;
                #endregion
            }
            Console.WriteLine("Press Any Key To Exit");
            Console.ReadLine();
            #endregion
        }