Example #1
0
 public ILStatement GenerateReadInto(ILValue target, ILValue buffer)
 {
     return(target_props
            .Convert(p => target.GetILProp(p))
            .Convert(p => ILSerialize.GenerateObjectReadInto(p, buffer))
            .ToBlock());
 }
Example #2
0
        /// <summary>
        /// Updates the components count.
        /// </summary>
        protected void UpdateComponentsCount()
        {
            components.RemoveAll(IsNullComponent);

            if (components.Count == visibleItems)
            {
                return;
            }

            if (components.Count < visibleItems)
            {
                componentsCache.RemoveAll(IsNullComponent);

                Enumerable.Range(0, visibleItems - components.Count).ForEach(AddComponent);
            }
            else
            {
                var to_cache = components.GetRange(visibleItems, components.Count - visibleItems).OrderByDescending <TComponent, int>(GetComponentIndex);

                to_cache.ForEach(DeactivateComponent);
                componentsCache.AddRange(to_cache);
                components.RemoveRange(visibleItems, components.Count - visibleItems);
            }

            base.Items = components.Convert(x => x as ListViewItem);
        }
Example #3
0
            public Type GetLiaisonType()
            {
                if (liaison_type == null)
                {
                    liaison_type = TypeCreator.CreateType("ObjectLiaison_" + GetTargetType().Name, TypeAttributesExtensions.PUBLIC_CLASS, delegate(TypeBuilder type_builder) {
                        type_builder.SetParent(typeof(ObjectLiaison));

                        target_serializer_prop_groups = target_props
                                                        .Convert(p => TypeSerializerProp.Create(type_builder, p))
                                                        .Group(
                            p => p.GetUpdateInterval(),
                            (i, ps) => new TypeSerializerPropGroup(type_builder, i, ps)
                            ).ToList();

                        liaison_update_interval = target_serializer_prop_groups
                                                  .Convert(g => g.GetUpdateInterval())
                                                  .Min();

                        type_builder.CreateConstructor(MethodAttributesExtensions.PUBLIC, delegate(ConstructorBuilderEX method) {
                            return(new ILBlock(
                                       method.GetBaseILConstruct(method.GetEffectiveILParameter(0)),
                                       target_serializer_prop_groups
                                       .Convert(g => g.GenerateConstructor(method.GetILThis()))
                                       .ToBlock()
                                       ));
                        }, typeof(TypeSerializer));
                    });
                }

                return(liaison_type);
            }
Example #4
0
        public float Plan(float width, EditorGUILayoutState state)
        {
            float total_weight  = elements.Convert(e => e.GetDimension().GetWeight()).Sum();
            float total_minimum = elements.Convert(e => e.GetDimension().GetMinimum()).Sum();

            height = elements.Convert(e => e.Plan(width, total_weight, total_minimum, state)).Max();
            return(height);
        }
Example #5
0
 public SpreadBetweenSceneCommand(GameObject first, GameObject second,
                                  GameObject[] selected) : base(0)
 {
     SceneCommandName = "Spread Between";
     this.first       = first;
     this.second      = second;
     this.selected    = selected.ToList();
     previousPos      = selected.Convert(_ => _.transform.position).ToList();
     previousRot      = selected.Convert(_ => _.transform.rotation).ToList();
 }
Example #6
0
            public ILStatement GenerateRead(ILValue target, ILValue liaison, ILValue buffer)
            {
                return(new ILIf(
                           buffer.GetILInvoke("ReadBoolean"),

                           props
                           .Convert(p => p.GenerateRead(target, liaison, buffer))
                           .ToBlock()
                           ));
            }
Example #7
0
        public override string ToString()
        {
            string output = string.Empty;

            lock (lockList)
            {
                List <string> prettyList =
                    list
                    .Convert(kvp => kvp.Value.PrettyName)
                    .Distinct()
                    .ToList()
                ;
                prettyList
                .Each
                    (prettyName =>
                {
                    List <MethodTimerInfo> prettyInfo =
                        list
                        .Where(kvp => kvp.Value.PrettyName == prettyName)
                        .Convert(kvp => kvp.Value)
                        .ToList()
                    ;
                    TimeSpan minTimeSpan =
                        prettyInfo
                        .Convert(info => info.Stopwatch.Elapsed)
                        .Min()
                    ;
                    TimeSpan maxTimeSpan =
                        prettyInfo
                        .Convert(info => info.Stopwatch.Elapsed)
                        .Max()
                    ;
                    TimeSpan totTimeSpan =
                        prettyInfo
                        .Convert(info => info.Stopwatch.Elapsed)
                        .Sum()
                    ;
                    TimeSpan avgTimeSpan =
                        prettyInfo
                        .Convert(info => info.Stopwatch.Elapsed)
                        .Average()
                    ;
                    output +=
                        prettyName
                        + $" Min {minTimeSpan} Max {maxTimeSpan} Tot {totTimeSpan} Avg {avgTimeSpan} Cnt {prettyInfo.Count}"
                    ;
                    output += Environment.NewLine;
                }
                    )
                ;
            }
            return(output);
        }
Example #8
0
        public void CanConvertEnumerables()
        {
            var list = "1,2,3,4,5".Convert <IList <int> >();

            list.ShouldBe <List <int> >();
            Assert.AreEqual(5, list.Count);
            Assert.AreEqual(3, list[2]);

            var list2 = "1,0,off,wahr,false,y,n".Convert <ICollection <bool> >();

            list2.ShouldBe <List <bool> >();
            Assert.AreEqual(7, list2.Count);
            Assert.AreEqual(true, list2.ElementAt(3));

            "1,2,3,4,5".Convert <IReadOnlyCollection <int> >().ShouldBe <ReadOnlyCollection <int> >();
            "1,2,3,4,5".Convert <IReadOnlyList <int> >().ShouldBe <ReadOnlyCollection <int> >();
            "1,2,3,4,5".Convert <HashSet <double> >().ShouldBe <HashSet <double> >();
            "1,2,3,4,5".Convert <Stack <int> >().ShouldBe <Stack <int> >();
            "1,2,3,4,5".Convert <ISet <int> >().ShouldBe <HashSet <int> >();
            "1,2,3,4,5".Convert <Queue <int> >().ShouldBe <Queue <int> >();
            "1,2,3,4,5".Convert <LinkedList <string> >().ShouldBe <LinkedList <string> >();
            "1,2,3,4,5".Convert <ConcurrentBag <int> >().ShouldBe <ConcurrentBag <int> >();
            "1,2,3,4,5".Convert <ArraySegment <int> >().ShouldBe <ArraySegment <int> >();

            var list3 = new List <int>(new int[] { 1, 2, 3, 4, 5 });
            var str   = list3.Convert <string>();

            Assert.AreEqual("1,2,3,4,5", str);

            var converter = TypeConverterFactory.GetConverter <double[]>();

            converter.ShouldBe <EnumerableConverter <double> >();

            var arr3 = list3.Convert <int[]>();

            arr3.ShouldBe <int[]>();
            Assert.AreEqual(5, list3.Count);
            Assert.AreEqual(3, list3[2]);

            var list4 = ((double)5).Convert <List <int> >();

            list4.ShouldBe <List <int> >();
            Assert.AreEqual(1, list4.Count);
            Assert.AreEqual(5, list4[0]);

            var list5 = new List <string>(new string[] { "1", "2", "3", "4", "5" });
            var arr4  = list5.Convert <float[]>();

            arr4.ShouldBe <float[]>();
            Assert.AreEqual(5, list5.Count);
            Assert.AreEqual("4", list5[3]);
        }
Example #9
0
            public void ReadWithLiaison(object target, object liaison, Buffer buffer)
            {
                if (object_liaison_reader == null)
                {
                    object_liaison_reader = GetTargetType().CreateDynamicMethodDelegateWithForcedParameterTypes <ObjectLiaisonReader>(delegate(ILValue il_target, ILValue il_liaison, ILValue il_buffer) {
                        return(target_serializer_prop_groups
                               .Convert(g => g.GenerateRead(il_target, il_liaison, il_buffer))
                               .ToBlock());
                    }, GetTargetType(), GetLiaisonType(), typeof(Buffer));
                }

                object_liaison_reader(target, liaison, buffer);
            }
Example #10
0
        public IEnumerable <T> GetItemsWithin(Predicate <Rect> predicate)
        {
            if (predicate.DoesDescribe(rect))
            {
                if (is_subdivided)
                {
                    return(child_rects.Convert(c => c.GetItemsWithin(predicate)).Flatten());
                }

                return(child_items.Narrow(c => predicate.DoesDescribe(get_rect_operation(c))));
            }

            return(Empty.IEnumerable <T>());
        }
Example #11
0
 private void UnpackTyonRuntimeInternal(TyonHydrationMode mode)
 {
     try
     {
         UnityTyonSettings.INSTANCE.FetchPrefabPusher(tyon_data)(
             this,
             UnityTyonSettings.INSTANCE.CreateContext(tyon_unity_objects.Convert <UnityEngine.Object, object>())
             );
     }
     catch (Exception ex)
     {
         UnpackTyonEditInternal(mode);
         Debug.LogError(ex + "\n\n" + tyon_data);
     }
 }
        /// <summary>
        /// Update the DisplayedIndices.
        /// </summary>
        /// <param name="newIndices">New indices.</param>
        /// <param name="action">Action.</param>
        public void DisplayedIndicesUpdate(List <int> newIndices, Action <TComponent> action)
        {
            if (IndicesEqual(newIndices))
            {
                return;
            }

            FindIndicesDiff(newIndices);

            if (IndicesRemoved.Count > 0)
            {
                for (int i = Components.Count - 1; i >= 0; i--)
                {
                    var component = Components[i];
                    if (IndicesRemoved.Contains(component.Index))
                    {
                        DeactivateComponent(component);
                        Components.RemoveAt(i);
                        ComponentsCache.Add(component);
                    }
                }
            }

            for (int i = 0; i < IndicesAdded.Count; i++)
            {
                var component = CreateComponent();
                Components.Add(component);
            }

            Owner.Items = Components.Convert(x => x as ListViewItem);

            var start = Components.Count - IndicesAdded.Count;

            for (int i = 0; i < IndicesAdded.Count; i++)
            {
                var component = Components[start + i];
                component.Index = IndicesAdded[i];
                action(component);
            }

            DisplayedIndices.Clear();
            DisplayedIndices.AddRange(newIndices);

            Components.Sort(ComponentsComparer);
            Components.ForEach(SetComponentAsLastSibling);

            LayoutUtilites.UpdateLayoutsRecursive(Owner.Container);
        }
        public IEnumerable <StoredProcedure> GetStoredProcedures()
        {
            List <DBStoredProcedureParamater> _dbspp = this.GetStoredProcedureParamaters();
            IEnumerable <TableStructure>      _sps   = _dbspp.Convert();

            return(_sps.Convert(Config, DBHelper));
        }
Example #14
0
        // GET: Admin/Product/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Product product = await db.Products.FindAsync(id);

            if (product == null)
            {
                return(HttpNotFound());
            }

            //ProductModel model = new ProductModel
            //{
            //    Title = product.Title,
            //    Description = product.Description,
            //    Id = product.Id,
            //    ProductLinkTextId = product.ProductLinkTextId,
            //    ProductTypeId = product.ProductTypeid,
            //    ImageUrl = product.ImageUrl,
            //    ProductLinkTexts = await db.productLinkTexts.ToListAsync(),
            //    ProductTypes = await db.productTypes.ToListAsync()
            //};

            var prod = new List <Product>();

            prod.Add(product);
            var prodModel = await prod.Convert(db);

            var model = prodModel.First();

            return(View(model));
        }
Example #15
0
        public void TypeConverterList(List <EntityA> data, string message)
        {
            var result = data.Convert <EntityB, EntityA>();

            result.Count.Should().Be(data.Count);

            for (var i = 0; i < result.Count; i++)
            {
                result[i].GuidValue.Should().Be(data[i].GuidValue, message);
                result[i].GuidValueNullable.Should().Be(data[i].GuidValueNullable, message);

                result[i].IntValue.Should().Be(data[i].IntValue, message);
                result[i].IntValueNullable.Should().Be(data[i].IntValueNullable, message);

                result[i].StringValue.Should().Be(data[i].StringValue, message);

                result[i].BoolValue.Should().Be(data[i].BoolValue, message);
                result[i].BoolValueNullAble.Should().Be(data[i].BoolValueNullAble, message);

                result[i].EnumValue.Should().Be(data[i].EnumValue, message);
                result[i].EnumValueNullable.Should().Be(data[i].EnumValueNullable, message);

                result[i].DateTimeValue.Should().Be(data[i].DateTimeValue, message);
                result[i].DateTimeValueNullable.Should().Be(data[i].DateTimeValueNullable, message);
            }
        }
        public async Task <ActionResult> CheckOut()
        {
            List <OrderDetail> orderDetail = null;

            try
            {
                orderDetail = await db.Database.SqlQuery <OrderDetail>("Select * from orderdetail").ToListAsync();

                var model = await orderDetail.Convert(db);

                var orderModel = await model.Convert(db, User.Identity.Name);

                if (orderDetail.Count().Equals(0))
                {
                    return(RedirectToAction("Index", "item"));
                }
                return(View(orderModel));
            }
            catch
            {
                if (orderDetail == null)
                {
                    //later
                }
                return(RedirectToAction("Index", "item"));
            }
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Title,Description,ImageUrl,CubicCapicity,FuelType,Price,Colour,CountySoldFrom,ManufacturerYear,NumberOfPreviousOwners,VehicleLinkTextId,VehicleTypeId")]
                                                Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                if (await db.Vehicles.AnyAsync(x => x.Description.ToLower().Equals(vehicle.Description.ToLower())))
                {
                    ModelState.AddModelError("", "A vehicle already exists with that description.");
                }
                else
                {
                    db.Vehicles.Add(vehicle);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            var veh = new List <Vehicle>();

            veh.Add(vehicle);
            var VehicleModel = await veh.Convert(db);

            return(View(VehicleModel.First()));
            //return View(vehicle);
        }
Example #18
0
        protected override void DrawElementInternal(int draw_id, Rect view)
        {
            Rect rect = GetElementRect();

            if (vectorizer != null)
            {
                Sprite sprite = vectorizer.GetTestSprite();

                if (sprite != null)
                {
                    Rect info_rect;

                    rect.SplitByYTopOffset(LINE_HEIGHT, out rect, out info_rect);

                    float line_thickness = vectorizer.GetTestLineThickness();
                    float point_size     = vectorizer.GetTestPointSize();

                    Vector2 divisor = sprite.GetTextureSize() / rect.size.GetMinComponent();
                    List <List <Vector2> > paths = vectorizer.VectorizeSprite(sprite)
                                                   .Convert(l => l.Convert(p => p.GetWithFlippedY().GetComponentDivide(divisor) + rect.center).ToList())
                                                   .ToList();

                    GUIExtensions.DrawSprite(rect, sprite);
                    GUI.Label(info_rect, "Number Vertexs: " + paths.Convert(p => p.Count).Sum());

                    GUI.color = Color.white;
                    paths.Process(p => GUIExtensions.DrawLoop(p, line_thickness, point_size));
                }
            }
        }
Example #19
0
        public void PushToVariable(VariableInstance variable, TyonHydrater hydrater)
        {
            Type log_type           = GetLogSystemType(hydrater);
            Variable_IndexedLog log = Variable_IndexedLog.New(log_type);

            if (variable.GetContents() != null)
            {
                int index = 0;
                foreach (object old_element in variable.GetContents().Convert <IEnumerable>())
                {
                    log.CreateStrongInstance(index++).SetContents(old_element);
                }
            }

            GetTyonValueList().IfNotNull(l => l.PushToLogVariable(log, hydrater));

            hydrater.DeferProcess(delegate() {
                List <object> values = log.GetValues()
                                       .Truncate(GetNumberTyonValues())
                                       .ToList();

                Type final_type = IsExplicitlyTyped().ConvertBool(
                    () => log_type,
                    () => values.Convert(v => v.GetTypeEX()).GetCommonAncestor()
                    );

                variable.SetContents(values.ToArrayOfType(final_type));
            });
        }
Example #20
0
        /// <summary>
        /// Updates the items.
        /// </summary>
        /// <param name="newItems">New items.</param>
        protected virtual void SetNewItems(ObservableList <TItem> newItems)
        {
            //Start();

            DataSource.OnChange -= UpdateItems;

            if (Sort && SortFunc != null)
            {
                newItems.BeginUpdate();

                var sorted = SortFunc(newItems).ToArray();

                newItems.Clear();
                newItems.AddRange(sorted);

                newItems.EndUpdate();
            }

            SilentDeselect(SelectedIndicies);
            var new_selected_indicies = SelectedItemsCache.Convert <TItem, int>(newItems.IndexOf);

            new_selected_indicies.RemoveAll(IndexNotFound);

            dataSource = newItems;

            if (KeepSelection)
            {
                SilentSelect(new_selected_indicies);
            }
            SelectedItemsCache = SelectedItems;

            UpdateView();

            DataSource.OnChange += UpdateItems;
        }
Example #21
0
        public EditTarget(IEnumerable <object> o, EditTarget p)
        {
            objects     = o.ToList();
            target_type = objects.Convert(z => z.GetTypeEX()).GetCommonAncestor();

            parent = p;
        }
Example #22
0
        /// <summary>
        /// Updates the items.
        /// </summary>
        /// <param name="newItems">New items.</param>
        void UpdateItems(List <GameObject> newItems)
        {
            RemoveCallbacks();

            newItems = SortItems(newItems);

            var new_selected_indices = new List <int>();
            var old_selected_indices = SelectedIndices;

            foreach (var index in old_selected_indices)
            {
                var new_index = objects.Count > index?newItems.IndexOf(objects[index]) : -1;

                if (new_index != -1)
                {
                    new_selected_indices.Add(new_index);
                }
                else
                {
                    Deselect(index);
                }
            }

            objects = newItems;
            Items   = newItems.Convert <GameObject, ListViewItem>(Utilites.GetOrAddComponent <ListViewItem>);

            SelectedIndices = new_selected_indices;

            AddCallbacks();
        }
Example #23
0
        /// <summary>
        /// Updates the items.
        /// </summary>
        /// <param name="newItems">New items.</param>
        void SetNewItems(ObservableList <string> newItems)
        {
            DataSource.OnChange -= UpdateItems;

            if (Sort && SortFunc != null)
            {
                newItems.BeginUpdate();

                var sorted = SortFunc(newItems).ToArray();

                newItems.Clear();
                newItems.AddRange(sorted);

                newItems.EndUpdate();
            }

            SilentDeselect(SelectedIndicies);
            var new_selected_indicies = SelectedItemsCache.Convert <string, int>(newItems.IndexOf);

            new_selected_indicies.RemoveAll(IndexNotFound);

            dataSource = newItems;

            SilentSelect(new_selected_indicies);
            SelectedItemsCache = SelectedIndicies.Convert <int, string>(GetDataItem);

            UpdateView();

            DataSource.OnChange += UpdateItems;
        }
Example #24
0
        public void CanConvertEnumerables()
        {
            var list = "1,2,3,4,5".Convert <IList <int> >();

            list.ShouldBe <List <int> >();
            Assert.AreEqual(5, list.Count);
            Assert.AreEqual(3, list[2]);

            var list2 = "1,0,off,wahr,false,y,n".Convert <ICollection <bool> >();

            list2.ShouldBe <List <bool> >();
            Assert.AreEqual(7, list2.Count);
            Assert.AreEqual(true, list2.ElementAt(3));

            "1,2,3,4,5".Convert <IReadOnlyCollection <int> >().ShouldBe <ReadOnlyCollection <int> >();
            "1,2,3,4,5".Convert <IReadOnlyList <int> >().ShouldBe <ReadOnlyCollection <int> >();
            "1,2,3,4,5".Convert <HashSet <double> >().ShouldBe <HashSet <double> >();
            "1,2,3,4,5".Convert <Stack <int> >().ShouldBe <Stack <int> >();
            "1,2,3,4,5".Convert <ISet <int> >().ShouldBe <HashSet <int> >();
            "1,2,3,4,5".Convert <Queue <int> >().ShouldBe <Queue <int> >();
            "1,2,3,4,5".Convert <LinkedList <string> >().ShouldBe <LinkedList <string> >();
            "1,2,3,4,5".Convert <ConcurrentBag <int> >().ShouldBe <ConcurrentBag <int> >();
            "1,2,3,4,5".Convert <ArraySegment <int> >().ShouldBe <ArraySegment <int> >();

            var list3 = new List <int>(new int[] { 1, 2, 3, 4, 5 });
            var str   = list3.Convert <string>();

            Assert.AreEqual("1,2,3,4,5", str);

            var list4 = ((double)5).Convert <List <int> >();

            list4.ShouldBe <List <int> >();
            Assert.AreEqual(1, list4.Count);
            Assert.AreEqual(5, list4[0]);
        }
Example #25
0
        public async Task <List <RealTimeStockItem> > GetMultipleRealTimeStockAsync(List <StockInfoItem> stockList)
        {
            // hard code to display taiwan tse stock
            stockList.Insert(0, new StockInfoItem {
                Id = "t00", MarketType = "上市"
            });


            SessionData session = await GetSession();

            List <StockInfoModel> queryStockList = stockList.Convert();

            List <RealTimeStockModel> results = new List <RealTimeStockModel>();

            try
            {
                TwseStockClient client = new TwseStockClient();
                results = await client.QueryStockAsync(queryStockList, session);
            }
            catch (Exception e)
            {
                Debug.WriteLine(DateTime.Now + " : " + "Cookie time out");
                ReleaseSession();
            }

            return(results.Convert());
        }
Example #26
0
        public object AssertInvokeConstructor(CmlContext context, string name, IEnumerable <object> system_values)
        {
            List <object> system_value_list = system_values.ToList();

            return(GetConstructor(name, system_value_list.Convert(o => o.GetTypeEX()))
                   .AssertNotNull(() => new CmlRuntimeError_InvalidIdException("constructor", name + "(" + system_value_list.Convert(o => o.GetTypeEX()).ToString(", ") + ")"))
                   .Invoke(context, system_value_list));
        }
Example #27
0
        public List <List <bool> > GetNext(List <List <bool> > world)
        {
            var cells     = world.Convert();
            var nextState = GetNextState(cells);
            var newWorld  = nextState.Convert();

            return(newWorld);
        }
Example #28
0
        public AIMachineNode Update()
        {
            behaviour.Update();

            return(transitions
                   .Convert(t => t.Update())
                   .GetFirstNonNull() ?? this);
        }
        public static void fetchResult(this StoredProcedure aSP, Config aConfig, DBHelper aHelper)
        {
            List <DBColumn> _result    = new List <DBColumn>();
            var             paramaters = GetParamaters(aSP.Paramaters);
            var             query      = NativeStoredProcedureQuery.GetSQLQuery(aSP.Name, paramaters);

            using (SqlConnection con = new SqlConnection(aConfig.DataSource))
            {
                try
                {
                    con.Open();
                    String q = query.Query;
                    q = "SET FMTONLY ON;" + q + ";SET FMTONLY OFF;";
                    using (SqlCommand Command = new SqlCommand(query.Query, con))
                    {
                        Command.Parameters.AddRange(query.Parameters.ToArray());
                        logger.Debug(q);

                        using (SqlDataReader aReader = Command.ExecuteReader())
                        {
                            DataTable _schema = aReader.GetSchemaTable();
                            if (_schema != null)
                            {
                                foreach (DataRow row in _schema.Rows)
                                {
                                    _result.Add(new DBColumn
                                    {
                                        TABLE_NAME  = "SP" + aSP.Name,
                                        DATA_TYPE   = row["DataType"].ToString(),
                                        COLUMN_NAME = row["BaseColumnName"].ToString()
                                    });
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Debug(ex);
                    con.Close();
                    _result.Add(new DBColumn
                    {
                        TABLE_NAME  = "SP" + aSP.Name,
                        DATA_TYPE   = typeof(DataTable).ToString(),
                        COLUMN_NAME = "Result"
                    });

                    var q = NativeQuery.SimpleQueryHelper("SET FMTONLY OFF;");
                    aHelper.Execute(delegate(DbSession aDBSession)
                    {
                        aDBSession.Execute(q, new DataReaderBinder());
                    });
                }

                var r = _result.Convert(false);
                aSP.Result = r.Count() > 0 ? r.First() : null;
            }
        }
Example #30
0
        /// <inheritdoc />
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_ObjectWrapper fieldGoo = null;

            if (!DA.GetData(0, ref fieldGoo))
            {
                return;
            }

            List <GH_Point> points = new List <GH_Point>();

            if (!DA.GetDataList(1, points))
            {
                return;
            }

            switch (fieldGoo.Value)
            {
            case IField3d <double> f:
            {
                var vals = points.Convert(p => f.ValueAt(p.Value), true);
                DA.SetDataList(0, vals.Select(x => new GH_Number(x)));
                break;
            }

            case IField3d <Vector2d> f:
            {
                var vals = points.Convert(p => f.ValueAt(p.Value), true);
                DA.SetDataList(0, vals.Select(x => new GH_Vector(x.As3d)));
                break;
            }

            case IField3d <Vector3d> f:
            {
                var vals = points.Convert(p => f.ValueAt(p.Value), true);
                DA.SetDataList(0, vals.Select(x => new GH_Vector(x)));
                break;
            }

            default:
            {
                throw new ArgumentException("The given field object can not be evaluated.");
            }
            }
        }
        public async Task<List<RealTimeStockItem>> GetMultipleRealTimeStockAsync(List<StockInfoItem> stockList)
        {
            // hard code to display taiwan tse stock
            stockList.Insert(0, new StockInfoItem { Id = "t00", MarketType = "上市" });


            SessionData session = await GetSession();
            List<StockInfoModel> queryStockList = stockList.Convert();
            
            List<RealTimeStockModel> results = new List<RealTimeStockModel>();
            try
            {
                TwseStockClient client = new TwseStockClient();
                results = await client.QueryStockAsync(queryStockList, session);
            }
            catch (Exception e)
            {
                Debug.WriteLine(DateTime.Now + " : " + "Cookie time out");
                ReleaseSession();
            }

            return results.Convert();
        }
 IExpressionNode[] CreateNodes(List<INode> nodes)
 {
     return nodes.Convert(n => CreateNode(n));
 }
		public static void SetBundleData(this OrderItem orderItem, List<ProductBundleItemOrderData> bundleData)
		{
			string rawData = null;

			if (bundleData != null && bundleData.Count > 0)
				rawData = bundleData.Convert<string>();

			orderItem.BundleData = rawData;
		}
Example #34
0
    /// <summary>
    /// Checks the second transition in a 2-transition jump and sees if we can
    /// perform the collapse (there's no overlap, etc.)
    /// </summary>
    /// <param name="beginning">The first expanded node (beginning, middle, 
    /// end)</param>
    /// <param name="jump1">The first edge (beginning-middle)</param>
    /// <param name="jump1Events">The events in the first edge</param>
    /// <param name="involvedInFirst">The objects involved in jump1</param>
    /// <param name="edgesToAdd">(out) A list in which we write the edges to
    /// add to the graph</param>
    private static void AnalyzeEndpoints(
        ExplorationNode beginning,
        ExplorationEdge jump1,
        IEnumerable<TransitionEvent> jump1Events,
        HashSet<uint> involvedInFirst,
        IList<ExplorationEdge> edgesToAdd)
    {
        // Get all of the final endpoint jumps (middle-end)
        foreach (ExplorationEdge jump2 in jump1.Target.Outgoing)
        {
            ExplorationNode end = jump2.Target;
            List<TransitionEvent> jump2Events =
                new List<TransitionEvent>(jump2.Events);

            // All the objects in jump2 
            HashSet<uint> involvedSecond = new HashSet<uint>();
            GetInvolved(jump2Events).ForEach(
                (uint id) =>
                {
                    DebugUtil.Assert(involvedSecond.Contains(id) == false);
                    involvedSecond.Add(id);
                });

            // There's no overlap
            if (involvedInFirst.Overlaps(involvedSecond) == false)
            {
                List<TransitionEvent> combined = new List<TransitionEvent>();
                combined.AddRange(
                    jump1Events.Convert(s => new TransitionEvent(s)));
                combined.AddRange(
                    jump2Events.Convert(s => new TransitionEvent(s)));
                edgesToAdd.Add(
                    new ExplorationEdge(beginning, end, combined.ToArray()));
            }
        }
    }
Example #35
0
    /// <summary>
    /// Collects all of the requirements for each parameter index
    /// </summary>
    private StateName[][] CollectStateRequirements()
    {
        List<List<StateName>> requirements =
            new List<List<StateName>>(this.ParameterCount);

        for (int i = 0; i < this.ParameterCount; i++)
            requirements.Add(new List<StateName>());

        foreach (StateCondition req in this.StateReqs)
        {
            // Make sure the index is valid
            DebugUtil.Assert(req.Index >= 0);
            DebugUtil.Assert(req.Index < this.ParameterCount);
            requirements[req.Index].AddRange(req.Tags);
        }

        return requirements.Convert(l => l.ToArray()).ToArray();
    }