Exemple #1
0
        public static ListSet GetAirfields(String text)
        {
            ListSet aset = new ListSet();

            if (text.Contains("(") && text.Contains(")"))
            {
                String id = text.Substring(text.LastIndexOf("(") + 1, text.LastIndexOf(")") - text.LastIndexOf("(") - 1);
                if (id.Contains("Lat:") && id.Contains("Long:"))
                {
                    Airfield a = new Airfield();
                    a.ICAOCODE     = "T-T" + RandomPassword.Generate(5);
                    a.AirfieldName = text.Remove(text.IndexOf(",")).Trim();
                    a.Country      = text.Substring(text.IndexOf(",") + 1, text.IndexOf("(") - text.IndexOf(",") - 1).Trim();
                    foreach (String l in id.Split(",".ToCharArray()))
                    {
                        Double temp;
                        if (l.Contains("Lat:"))
                        {
                            temp = Double.Parse(l.Substring(l.LastIndexOf(":") + 1));
                            string[] parts = DDtoDMS(temp, CoordinateType.latitude).Split(".".ToCharArray());
                            a.LattitudeDegrees = Int32.Parse(parts[0]);
                            a.LattitudeMinutes = Int32.Parse(parts[1]);
                            a.NS = Char.Parse(parts[2]);
                        }
                        else if (l.Contains("Long:"))
                        {
                            temp = Double.Parse(l.Substring(l.LastIndexOf(":") + 1));
                            string[] parts = DDtoDMS(temp, CoordinateType.longitude).Split(".".ToCharArray());
                            a.LongitudeDegrees = Int32.Parse(parts[0]);
                            a.LongitudeMinutes = Int32.Parse(parts[1]);
                            a.EW = Char.Parse(parts[2]);
                        }
                    }
                    aset.Add(a);
                }
                else
                {
                    Airfield a = AirfieldDAO.FindAirfieldByID(id);
                    aset.Add(a);
                }
            }
            else
            {
                aset.AddAll(SearchAifields(text));
                if (aset.Count == 0)
                {
                    String[] keywords = text.Split(", ".ToCharArray());
                    foreach (String s in keywords)
                    {
                        if (s.Length >= 3)
                        {
                            aset.AddAll(SearchAifields(s));
                        }
                    }
                }
            }
            return(aset);
        }
        public ListSet GetLegCountries()
        {
            ListSet ls = new ListSet();

            foreach (Leg l in this.Legs)
            {
                ls.Add(l.Source.Country.Trim());
                ls.Add(l.Destination.Country.Trim());
            }
            return(ls);
        }
    public String GetBidJson(BookRequest b, Operator op)
    {
        String resp = "";
        IList <OperatorBid> bidlist    = BookRequestDAO.GetBidsForRequest(b);
        ListSet             opbids     = new ListSet();
        OperatorBid         minbid     = null;
        Currency            targetcurr = AdminDAO.GetCurrencyByID("USD");
        Double minval = double.PositiveInfinity;

        foreach (OperatorBid ob in bidlist)
        {
            if (ob.Operator.Equals(op))
            {
                opbids.Add(ob);
            }

            Double temp = ob.Currency.ConvertTo(ob.BidAmount, targetcurr);
            if (temp < minval)
            {
                minval = temp;
                minbid = ob;
            }
        }
        resp += "{\"TotalBids\":" + bidlist.Count + ",\"OperatorBids\":" + JavaScriptConvert.SerializeObject(opbids) + ",\"MinBid\":" + JavaScriptConvert.SerializeObject(minbid) + "}";
        return(resp);
    }
Exemple #4
0
        public void ManyToManyUsingSet()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(),
                                           typeof(Order), typeof(Product) /*, typeof(LineItem)*/);
            Recreate();

            Order.DeleteAll();
            Product.DeleteAll();

            Order myOrder = new Order();

            myOrder.OrderedDate = DateTime.Parse("05/09/2004");
            Product coolGadget = new Product();

            coolGadget.Name  = "PSP";
            coolGadget.Price = 250.39f;

            using (new SessionScope())
            {
                coolGadget.Save();
                ISet products = new ListSet();
                products.Add(coolGadget);
                myOrder.Products = products;
                myOrder.Save();
            }

            Order secondRef2Order = Order.Find(myOrder.ID);

            Assert.IsFalse(secondRef2Order.Products.IsEmpty);

            Product secondRef2Product = Product.Find(coolGadget.ID);

            Assert.AreEqual(1, secondRef2Product.Orders.Count);
        }
Exemple #5
0
 protected virtual void ActivateSensor(ISensor sensor)
 {
     if (active.Add(sensor))
     {
         SensorAdded?.Invoke(sensor);
     }
 }
Exemple #6
0
        private void WriteSprite(Sprite s, ListSet <Timeline> unboundClasses)
        {
            foreach (ICharacterReference cr in s.CharacterRefs)
            {
                this.WriteCharacter(cr.Character, unboundClasses);
            }

            if (s.HasClass && !(s.Class is AdobeClass) && !unboundClasses.Contains(s))
            {
                unboundClasses.Add(s);
            }

            int         id        = this.characterMarshal.GetIDFor(s);
            WriteBuffer tagWriter = this.OpenTag(Tag.DefineSprite, s.ToString() + ";id=" + id.ToString());

            tagWriter.WriteUI16((uint)id);
            tagWriter.WriteUI16(s.FrameCount);
#if DEBUG
            this.LogMessage("char id=" + id);
#endif

            foreach (Frame f in s.Frames)
            {
                if (f.HasLabel)
                {
#if DEBUG
                    this.LogMessage("frame label=" + f.Label);
#endif
                    WriteBuffer labelWriter = this.OpenTag(Tag.FrameLabel);
                    labelWriter.WriteString(f.Label);
                    this.CloseTag();
                }

                foreach (IDisplayListItem dli in f.DisplayList)
                {
                    switch (dli.Type)
                    {
                    case DisplayListItemType.PlaceObjectX:
                        this.WritePlaceObjectTag((PlaceObject)dli);
                        break;

                    case DisplayListItemType.RemoveObjectX:
                        this.WriteRemoveObjectTag((RemoveObject)dli);
                        break;

                    default:
                        /* ISSUE 73 */
                        throw new SWFModellerException(
                                  SWFModellerError.UnimplementedFeature,
                                  "Unsupported tag in SWF sprite writer: " + dli.GetType().ToString());
                    }
                }

                this.WriteBodylessTag(Tag.ShowFrame);
            }

            this.WriteBodylessTag(Tag.End, id.ToString());

            this.CloseTag(); /* DefineSprite */
        }
Exemple #7
0
        public static ListSet SearchAifields(String text)
        {
            ListSet          aset        = new ListSet();
            IList <Airfield> alistbyname = AirfieldDAO.FindByAirfieldName(text, "Start");

            if (alistbyname.Count > 0)
            {
                foreach (Airfield a in alistbyname)
                {
                    aset.Add(a);
                }
            }
            Airfield abyicao = AirfieldDAO.FindAirfieldByICAO(text);

            if (abyicao != null)
            {
                aset.Add(abyicao);
            }
            Airfield abyiata = AirfieldDAO.FindAirfieldByIATA(text);

            if (abyiata != null)
            {
                aset.Add(abyiata);
            }

            IList <Airfield> alistbycity = AirfieldDAO.FindAirfieldByCity(text, "");

            if (alistbycity.Count > 0)
            {
                foreach (Airfield a in alistbycity)
                {
                    aset.Add(a);
                }
            }
            if (aset.Count == 0)
            {
                IList <Airfield> alistbystate = AirfieldDAO.FindAirfieldByState(text, "");
                if (alistbystate.Count > 0)
                {
                    foreach (Airfield a in alistbystate)
                    {
                        aset.Add(a);
                    }
                }
            }
            return(aset);
        }
Exemple #8
0
 public void ActivateSensor(Sensor sensor)
 {
     if (active.Add(sensor))
     {
         if (SensorAdded != null)
         {
             SensorAdded(sensor);
         }
     }
 }
Exemple #9
0
 protected virtual void ActivateSensor(ISensor sensor)
 {
     if (active.Add(sensor))
     {
         if (SensorAdded != null)
         {
             SensorAdded(sensor);
         }
     }
 }
        /// <summary>
        /// Given a string, returns all instances of @abc in an ordered set containing abc (the token without the @ sign). If a token is used more than once, it
        /// only appears in the list once. A different prefix may be used for certain databases.
        /// </summary>
        internal static ListSet<string> GetNamedParamList( DatabaseInfo info, string statement )
        {
            // We don't want to find parameters in quoted text.
            statement = statement.RemoveTextBetweenStrings( "'", "'" ).RemoveTextBetweenStrings( "\"", "\"" );

            var parameters = new ListSet<string>();
            foreach( Match match in Regex.Matches( statement, getParamRegex( info ) ) )
                parameters.Add( match.Value.Substring( 1 ) );

            return parameters;
        }
Exemple #11
0
        internal void Add_UpdateDicionaryAsExpected(ListSet <string> target, string added)
        {
            bool success;
            var  expected = new HashSet <string>(target);
            bool result   = expected.Add(added);

            var res = target.Add(added, out success);

            res.Should().BeEquivalentTo(expected);
            result.Should().Be(success);
        }
Exemple #12
0
        /// <summary>
        /// Update the input mapping dictionary to reflect an input
        /// recently added to the circuit
        /// </summary>
        /// <param name="input">The shape (label) corresponding to the input</param>
        public void addInput(Sketch.Shape inputShape)
        {
            ListSet <String> strokeIDs = new ListSet <String>();

            foreach (Sketch.Substroke substroke in inputShape.Substrokes)
            {
                strokeIDs.Add(sketchStrokesToInkStrokes[substroke.Id]);
            }

            inputMapping.Add(strokeIDs, inputShape.Name);
        }
Exemple #13
0
        /// <summary>
        /// Update the wire-to-input-gate mapping dictionary to reflect
        /// the addition of a gate to the circuit
        /// </summary>
        /// <param name="gate">The gate that has been added to the circuit.</param>
        /// <param name="wire">The wire mesh connected to the gate output.</param>
        public void addWire(Sketch.Shape gate, Sketch.Shape wire)
        {
            ListSet <String> strokeIDs = new ListSet <string>();

            foreach (Sketch.Substroke substroke in wire.Substrokes)
            {
                strokeIDs.Add(sketchStrokesToInkStrokes[substroke.Id]);
            }

            wireToInputGateMapping.Add(strokeIDs, gate.Name);
        }
Exemple #14
0
        private static ListSet <SignInfo> GetSigns()
        {
            ListSet <SignInfo> signs = new ListSet <SignInfo>();

            for (int i = 0; i < SignCount; i++)
            {
                SignInfo sign = new SignInfo();
                sign.Name = "Sign" + i.ToString();
                signs.Add(sign);
            }
            return(signs);
        }
Exemple #15
0
        internal void Add_Returns_SameInstance(ListSet <string> target, string added)
        {
            bool success;
            var  res = target.Add(added, out success);

            if (success && (res.Count == _Transition))
            {
                res.Should().BeOfType <SimpleHashSet <string> >();
            }
            else
            {
                res.Should().BeSameAs(target);
            }
        }
Exemple #16
0
        /// <summary>
        /// Given a string, returns all instances of @abc in an ordered set containing abc (the token without the @ sign). If a
        /// token is used more than once, it
        /// only appears in the list once. A different prefix may be used for certain databases.
        /// </summary>
        internal static ListSet <string> GetNamedParamList(DatabaseInfo info, string statement)
        {
            // We don't want to find parameters in quoted text.
            statement = statement.RemoveTextBetweenStrings("'", "'").RemoveTextBetweenStrings("\"", "\"");

            var parameters = new ListSet <string>();

            foreach (Match match in Regex.Matches(statement, getParamRegex(info)))
            {
                parameters.Add(match.Value.Substring(1));
            }

            return(parameters);
        }
        public object NullSafeGet(System.Data.IDataReader rs, string[] names, object owner)
        {
            ListSet result = new ListSet();
            Int32   index  = rs.GetOrdinal(names[0]);

            if (rs.IsDBNull(index) || String.IsNullOrEmpty((String)rs[index]))
            {
                return(result);
            }
            foreach (String s in ((String)rs[index]).Split(cStringSeparator))
            {
                result.Add(s);
            }
            return(result);
        }
Exemple #18
0
        public bool AddGroup(SignGroupInfo group)
        {
            bool flg = false;

            if (group != null &&
                !group.IsEmpty &&
                !_allGroups.Contains(group) && !_allSigns.Contains(group.Name))   //&& !_groups.Contains(group))
            {
                _groups.Add(group);
                _allGroups.Add(group);
                group.Parent = this;
                flg          = true;
            }
            return(flg);
        }
Exemple #19
0
 /// <summary>
 /// A MultiPoint is simple if it has no repeated points.
 /// </summary>
 public bool IsSimple(IMultiPoint mp)
 {
     if (mp.IsEmpty) 
         return true;
     ISet points = new ListSet();
     for (int i = 0; i < mp.NumGeometries; i++)
     {
         IPoint pt = (IPoint) mp.GetGeometryN(i);
         ICoordinate p = pt.Coordinate;
         if (points.Contains(p))
             return false;
         points.Add(p);
     }
     return true;
 }   
        public void GetGenericArgumentValueIgnoresAlreadyUsedValues()
        {
            ISet used = new ListSet();

            ConstructorArgumentValues values = new ConstructorArgumentValues();

            values.AddGenericArgumentValue(1);
            values.AddGenericArgumentValue(2);
            values.AddGenericArgumentValue(3);

            Type intType = typeof(int);

            ConstructorArgumentValues.ValueHolder one = values.GetGenericArgumentValue(intType, used);
            Assert.AreEqual(1, one.Value);
            used.Add(one);
            ConstructorArgumentValues.ValueHolder two = values.GetGenericArgumentValue(intType, used);
            Assert.AreEqual(2, two.Value);
            used.Add(two);
            ConstructorArgumentValues.ValueHolder three = values.GetGenericArgumentValue(intType, used);
            Assert.AreEqual(3, three.Value);
            used.Add(three);
            ConstructorArgumentValues.ValueHolder four = values.GetGenericArgumentValue(intType, used);
            Assert.IsNull(four);
        }
Exemple #21
0
        public override void FromTo(MemoryLibraryItem memory)
        {
            base.FromTo(memory);
            var item = memory as RegionInfo;

            if (item != null)
            {
                if (item._items != null && item._items.Count > 0)
                {
                    foreach (var adp in item._items)
                    {
                        _items.Add(adp.Copy());
                    }
                }
            }
        }
Exemple #22
0
        public override void FromTo(MemoryLibraryItem memory)
        {
            base.FromTo(memory);
            var item = memory as MLPlaylistInfo;

            if (item != null)
            {
                if (item._items != null && item._items.Count > 0)
                {
                    foreach (var region in item._items)
                    {
                        _items.Add(region.Copy() as RegionInfo);
                    }
                }
            }
        }
        public void SetSensors(List <ISensor> sensors,
                               IDictionary <ISensor, Color> colors)
        {
            model.Series.Clear();

            var types = new ListSet <SensorType>();

            foreach (var sensor in sensors)
            {
                var series = new LineSeries();
                if (sensor.SensorType == SensorType.Temperature)
                {
                    series.ItemsSource = sensor.Values.Select(value => new DataPoint
                    {
                        X = (now - value.Time).TotalSeconds,
                        Y = unitManager.TemperatureUnit == TemperatureUnit.Celsius
                            ? value.Value
                            : UnitManager.CelsiusToFahrenheit(value.Value).Value
                    });
                }
                else
                {
                    series.ItemsSource = sensor.Values.Select(value => new DataPoint
                    {
                        X = (now - value.Time).TotalSeconds,
                        Y = value.Value
                    });
                }
                series.Color           = colors[sensor].ToOxyColor();
                series.StrokeThickness = 1;
                series.YAxisKey        = axes[sensor.SensorType].Key;
                series.Title           = sensor.Hardware.Name + " " + sensor.Name;
                model.Series.Add(series);

                types.Add(sensor.SensorType);
            }

            foreach (var pair in axes.Reverse())
            {
                var axis = pair.Value;
                var type = pair.Key;
                axis.IsAxisVisible = types.Contains(type);
            }

            UpdateAxesPosition();
            InvalidatePlot();
        }
Exemple #24
0
        public bool AddSign(SignInfo sign)
        {
            bool flg = false;

            if (sign != null &&
                !sign.IsEmpty &&
                !_allSigns.Contains(sign) &&
                !_allGroups.Contains(sign.Name))   //&& !_signs.Contains(sign))
            {
                _signs.Add(sign);
                _allSigns.Add(sign);
                sign.Parent        = this;
                sign.Parent.Active = true;
                flg = true;
            }

            return(flg);
        }
Exemple #25
0
        /// <summary>
        /// Update the output mapping dictionary to reflect an output
        /// recently added to the circuit
        /// </summary>
        /// <param name="ouput">The shape (label) corresponding to the output</param>
        public void addOutput(Sketch.Shape outputShape)
        {
            if (debug)
            {
                Console.WriteLine("Trying to add " + outputShape.Type + " called " + outputShape.Name + " to outputs");
            }

            ListSet <String> strokeIDs = new ListSet <string>();

            foreach (Sketch.Substroke substroke in outputShape.Substrokes)
            {
                strokeIDs.Add(sketchPanel.InkSketch.GetInkStrokeIDBySubstroke(substroke));
            }

            if (!outputMapping.ContainsKey(outputShape.Name))
            {
                outputMapping.Add(outputShape.Name, strokeIDs);
            }
        }
        /// <summary>
        /// Update the input mapping dictionary to reflect an input
        /// recently added to the circuit
        /// </summary>
        /// <param name="input">The shape (label) corresponding to the input</param>
        private void addInput(Sketch.Shape inputShape)
        {
            if (debug)
            {
                Console.WriteLine("Trying to add " + inputShape.Type.Name + " called " + inputShape.Name + " to inputs");
            }

            ListSet <String> strokeIDs = new ListSet <String>();

            foreach (Sketch.Substroke substroke in inputShape.Substrokes)
            {
                strokeIDs.Add(sketchPanel.InkSketch.GetInkStrokeIDBySubstroke(substroke));
            }

            if (!inputMapping.ContainsKey(inputShape))
            {
                inputMapping.Add(inputShape, strokeIDs);
            }
        }
Exemple #27
0
        /// <summary>
        /// Check that a ring does not self-intersect, except at its endpoints.
        /// Algorithm is to count the number of times each node along edge occurs.
        /// If any occur more than once, that must be a self-intersection.
        /// </summary>
        private void CheckNoSelfIntersectingRing(EdgeIntersectionList eiList)
        {
            ISet nodeSet = new ListSet();
            bool isFirst = true;

            foreach (EdgeIntersection ei in eiList)
            {
                if (isFirst)
                {
                    isFirst = false;
                    continue;
                }
                if (nodeSet.Contains(ei.Coordinate))
                {
                    _validErr = new TopologyValidationError(TopologyValidationErrorType.RingSelfIntersection, ei.Coordinate);
                    return;
                }
                nodeSet.Add(ei.Coordinate);
            }
        }
Exemple #28
0
        /// <summary>
        /// A MultiPoint is simple if it has no repeated points.
        /// </summary>
        public bool IsSimple(IMultiPoint mp)
        {
            if (mp.IsEmpty)
            {
                return(true);
            }
            ISet points = new ListSet();

            for (int i = 0; i < mp.NumGeometries; i++)
            {
                IPoint      pt = (IPoint)mp.GetGeometryN(i);
                ICoordinate p  = pt.Coordinate;
                if (points.Contains(p))
                {
                    return(false);
                }
                points.Add(p);
            }
            return(true);
        }
Exemple #29
0
        public static ListSet RemoveHeliports(ListSet total)
        {
            Int32   count = total.Count;
            ListSet ls    = new ListSet();

            foreach (Airfield a in total)
            {
                if (a.IsHeliport())
                {
                    ls.Add(a);
                }
            }

            total.RemoveAll(ls);
            if (count > 0 && total.Count == 0)
            {
                throw new HeliportException();
            }
            return(total);
        }
Exemple #30
0
        private ListSet <ICharacterReference> PopulateCharacterRefList(ListSet <ICharacterReference> refs)
        {
            foreach (Frame f in FrameList)
            {
                foreach (IDisplayListItem dli in f.DisplayList)
                {
                    if (dli is ICharacterReference)
                    {
                        ICharacterReference cr = (ICharacterReference)dli;

                        refs.Add(cr);

                        if (cr.Character is Sprite && !refs.Contains(cr))
                        {
                            ((Sprite)cr.Character).PopulateCharacterRefList(refs);
                        }
                    }
                }
            }
            return(refs);
        }
Exemple #31
0
        public void SetDefaults()
        {
            DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            StringSet = new HashedSet();
            StringSet.Add("foo");
            StringSet.Add("bar");
            StringSet.Add("baz");

            StringDateMap = new SortedList();
            StringDateMap.Add("now", DateTime.Now);
            StringDateMap.Add("never", null); // value is persisted since NH-2199
            // according to SQL Server the big bag happened in 1753 ;)
            StringDateMap.Add("big bang", new DateTime(1753, 01, 01));
            //StringDateMap.Add( "millenium", new DateTime( 2000, 01, 01 ) );
            ArrayList list = new ArrayList();
            list.AddRange(StringSet);
            StringList = list;
            IntArray = new int[] {1, 3, 3, 7};
            FooArray = new Foo[0];
            StringArray = (String[]) list.ToArray(typeof(string));
            Customs = new ArrayList();
            Customs.Add(new String[] {"foo", "bar"});
            Customs.Add(new String[] {"A", "B"});
            Customs.Add(new String[] {"1", "2"});

            FooSet = new HashedSet();
            Components = new FooComponent[]
                {
                    new FooComponent("foo", 42, null, null),
                    new FooComponent("bar", 88, null, new FooComponent("sub", 69, null, null))
                };
            TimeArray = new DateTime[]
                {
                    new DateTime(),
                    new DateTime(),
                    new DateTime(), // H2.1 has null here, but it's illegal on .NET
                    new DateTime(0)
                };

            Count = 667;
            Name = "Bazza";
            TopComponents = new ArrayList();
            TopComponents.Add(new FooComponent("foo", 11, new DateTime[] {today, new DateTime(2123, 1, 1)}, null));
            TopComponents.Add(
                new FooComponent("bar", 22, new DateTime[] {new DateTime(2007, 2, 3), new DateTime(1945, 6, 1)}, null));
            TopComponents.Add(null);
            Bag = new ArrayList();
            Bag.Add("duplicate");
            Bag.Add("duplicate");
            Bag.Add("duplicate");
            Bag.Add("unique");

            Cached = new ListSet();

            CompositeElement ce = new CompositeElement();
            ce.Foo = "foo";
            ce.Bar = "bar";
            CompositeElement ce2 = new CompositeElement();
            ce2.Foo = "fooxxx";
            ce2.Bar = "barxxx";
            Cached.Add(ce);
            Cached.Add(ce2);
            CachedMap = new SortedList();
            CachedMap.Add(this, ce);
        }
Exemple #32
0
        public void SetDefaults()
        {
            DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            StringSet = new HashedSet();
            StringSet.Add("foo");
            StringSet.Add("bar");
            StringSet.Add("baz");

            StringDateMap = new SortedList();
            StringDateMap.Add("now", DateTime.Now);
            StringDateMap.Add("never", null);             // value is persisted since NH-2199
            // according to SQL Server the big bag happened in 1753 ;)
            StringDateMap.Add("big bang", new DateTime(1753, 01, 01));
            //StringDateMap.Add( "millenium", new DateTime( 2000, 01, 01 ) );
            ArrayList list = new ArrayList();

            list.AddRange(StringSet);
            StringList  = list;
            IntArray    = new int[] { 1, 3, 3, 7 };
            FooArray    = new Foo[0];
            StringArray = (String[])list.ToArray(typeof(string));
            Customs     = new ArrayList();
            Customs.Add(new String[] { "foo", "bar" });
            Customs.Add(new String[] { "A", "B" });
            Customs.Add(new String[] { "1", "2" });

            FooSet     = new HashedSet();
            Components = new FooComponent[]
            {
                new FooComponent("foo", 42, null, null),
                new FooComponent("bar", 88, null, new FooComponent("sub", 69, null, null))
            };
            TimeArray = new DateTime[]
            {
                new DateTime(),
                new DateTime(),
                new DateTime(),                         // H2.1 has null here, but it's illegal on .NET
                new DateTime(0)
            };

            Count         = 667;
            Name          = "Bazza";
            TopComponents = new ArrayList();
            TopComponents.Add(new FooComponent("foo", 11, new DateTime[] { today, new DateTime(2123, 1, 1) }, null));
            TopComponents.Add(
                new FooComponent("bar", 22, new DateTime[] { new DateTime(2007, 2, 3), new DateTime(1945, 6, 1) }, null));
            TopComponents.Add(null);
            Bag = new ArrayList();
            Bag.Add("duplicate");
            Bag.Add("duplicate");
            Bag.Add("duplicate");
            Bag.Add("unique");

            Cached = new ListSet();

            CompositeElement ce = new CompositeElement();

            ce.Foo = "foo";
            ce.Bar = "bar";
            CompositeElement ce2 = new CompositeElement();

            ce2.Foo = "fooxxx";
            ce2.Bar = "barxxx";
            Cached.Add(ce);
            Cached.Add(ce2);
            CachedMap = new SortedList();
            CachedMap.Add(this, ce);
        }
Exemple #33
0
        private void WriteCharacter(ICharacter ch, ListSet<Timeline> unboundClasses)
        {
            int cid;

            if (ch == null)
            {
                return;
            }

            if (this.characterMarshal.HasMarshalled(ch))
            {
                return;
            }

            int fontID = -1;

            if (ch is IFontUserProcessor)
            {
                IFontUserProcessor fup = (IFontUserProcessor)ch;
                fup.FontUserProc(delegate(IFontUser fu)
                {
                    if (fu.HasFont && !characterMarshal.HasMarshalled(fu.Font))
                    {
                        fontID = characterMarshal.GetIDFor(fu.Font);
                        this.WriteFont(fu.Font, fontID);
                    }
                    else
                    {
                        fontID = characterMarshal.GetExistingIDFor(fu.Font);
                    }
                });
            }

            if (ch is IShape)
            {
                IImage[] images = ((IShape)ch).GetImages();

                if (images != null)
                {
                    foreach (IImage image in images)
                    {
                        this.WriteImage(image);
                    }
                }

                Tag format;
                byte[] shapeBytes = ShapeWriter.ShapeToBytes((IShape)ch, out format);

                WriteBuffer shapeTag = this.OpenTag(format);
                cid = this.characterMarshal.GetIDFor(ch);
                shapeTag.WriteUI16((uint)cid);
                shapeTag.WriteBytes(shapeBytes);
            #if DEBUG
                this.LogMessage("char id=" + cid);
            #endif
                this.CloseTag();
            }
            else if (ch is Sprite)
            {
                this.WriteSprite((Sprite)ch, unboundClasses);
            }
            else if (ch is EditText)
            {
                this.WriteEditText((EditText)ch, fontID);
            }
            else if (ch is StaticText)
            {
                this.WriteStaticText((StaticText)ch);
            }
            else
            {
                /* ISSUE 73 */
                throw new SWFModellerException(
                            SWFModellerError.UnimplementedFeature,
                            "Character of type " + ch.GetType().ToString() + " not currently supported in writer");
            }

            if (ch is Timeline)
            {
                Timeline tl = (Timeline)ch;
                if (tl.HasClass && !(tl.Class is AdobeClass) && !unboundClasses.Contains(tl))
                {
                    unboundClasses.Add(tl);
                }
            }
        }
Exemple #34
0
        private void WriteSprite(Sprite s, ListSet<Timeline> unboundClasses)
        {
            foreach (ICharacterReference cr in s.CharacterRefs)
            {
                this.WriteCharacter(cr.Character, unboundClasses);
            }

            if (s.HasClass && !(s.Class is AdobeClass) && !unboundClasses.Contains(s))
            {
                unboundClasses.Add(s);
            }

            int id = this.characterMarshal.GetIDFor(s);
            WriteBuffer tagWriter = this.OpenTag(Tag.DefineSprite, s.ToString() + ";id=" + id.ToString());
            tagWriter.WriteUI16((uint)id);
            tagWriter.WriteUI16(s.FrameCount);
            #if DEBUG
            this.LogMessage("char id=" + id);
            #endif

            foreach (Frame f in s.Frames)
            {
                if (f.HasLabel)
                {
            #if DEBUG
                    this.LogMessage("frame label=" + f.Label);
            #endif
                    WriteBuffer labelWriter = this.OpenTag(Tag.FrameLabel);
                    labelWriter.WriteString(f.Label);
                    this.CloseTag();
                }

                foreach (IDisplayListItem dli in f.DisplayList)
                {
                    switch (dli.Type)
                    {
                        case DisplayListItemType.PlaceObjectX:
                            this.WritePlaceObjectTag((PlaceObject)dli);
                            break;

                        case DisplayListItemType.RemoveObjectX:
                            this.WriteRemoveObjectTag((RemoveObject)dli);
                            break;

                        default:
                            /* ISSUE 73 */
                            throw new SWFModellerException(
                                    SWFModellerError.UnimplementedFeature,
                                    "Unsupported tag in SWF sprite writer: " + dli.GetType().ToString());
                    }
                }

                this.WriteBodylessTag(Tag.ShowFrame);
            }

            this.WriteBodylessTag(Tag.End, id.ToString());

            this.CloseTag(); /* DefineSprite */
        }
Exemple #35
0
        private ListSet<ICharacterReference> PopulateCharacterRefList(ListSet<ICharacterReference> refs)
        {
            foreach (Frame f in FrameList)
            {
                foreach (IDisplayListItem dli in f.DisplayList)
                {
                    if (dli is ICharacterReference)
                    {
                        ICharacterReference cr = (ICharacterReference)dli;

                        refs.Add(cr);

                        if (cr.Character is Sprite && !refs.Contains(cr))
                        {
                            ((Sprite)cr.Character).PopulateCharacterRefList(refs);
                        }
                    }
                }
            }
            return refs;
        }
    public void SetSensors(List<ISensor> sensors,
      IDictionary<ISensor, Color> colors) {
      this.model.Series.Clear();

      ListSet<SensorType> types = new ListSet<SensorType>();

      foreach (ISensor sensor in sensors) {
        var series = new LineSeries();
        if (sensor.SensorType == SensorType.Temperature) {
          series.ItemsSource = sensor.Values.Select(value => new DataPoint {
            X = (now - value.Time).TotalSeconds,
            Y = unitManager.TemperatureUnit == TemperatureUnit.Celsius ? 
              value.Value : UnitManager.CelsiusToFahrenheit(value.Value).Value
          });
        } else {
          series.ItemsSource = sensor.Values.Select(value => new DataPoint {
            X = (now - value.Time).TotalSeconds, Y = value.Value
          });
        }
        series.Color = colors[sensor].ToOxyColor();
        series.StrokeThickness = 1;
        series.YAxisKey = axes[sensor.SensorType].Key;
        series.Title = sensor.Hardware.Name + " " + sensor.Name;
        this.model.Series.Add(series);

        types.Add(sensor.SensorType);
      }

      foreach (var pair in axes.Reverse()) {
        var axis = pair.Value;
        var type = pair.Key;
        axis.IsAxisVisible = types.Contains(type);
      } 

      UpdateAxesPosition();
      InvalidatePlot();
    }
Exemple #37
0
        private void WriteCharacter(ICharacter ch, ListSet <Timeline> unboundClasses)
        {
            int cid;

            if (ch == null)
            {
                return;
            }

            if (this.characterMarshal.HasMarshalled(ch))
            {
                return;
            }

            int fontID = -1;

            if (ch is IFontUserProcessor)
            {
                IFontUserProcessor fup = (IFontUserProcessor)ch;
                fup.FontUserProc(delegate(IFontUser fu)
                {
                    if (fu.HasFont && !characterMarshal.HasMarshalled(fu.Font))
                    {
                        fontID = characterMarshal.GetIDFor(fu.Font);
                        this.WriteFont(fu.Font, fontID);
                    }
                    else
                    {
                        fontID = characterMarshal.GetExistingIDFor(fu.Font);
                    }
                });
            }

            if (ch is IShape)
            {
                IImage[] images = ((IShape)ch).GetImages();

                if (images != null)
                {
                    foreach (IImage image in images)
                    {
                        this.WriteImage(image);
                    }
                }

                Tag    format;
                byte[] shapeBytes = ShapeWriter.ShapeToBytes((IShape)ch, out format);

                WriteBuffer shapeTag = this.OpenTag(format);
                cid = this.characterMarshal.GetIDFor(ch);
                shapeTag.WriteUI16((uint)cid);
                shapeTag.WriteBytes(shapeBytes);
#if DEBUG
                this.LogMessage("char id=" + cid);
#endif
                this.CloseTag();
            }
            else if (ch is Sprite)
            {
                this.WriteSprite((Sprite)ch, unboundClasses);
            }
            else if (ch is EditText)
            {
                this.WriteEditText((EditText)ch, fontID);
            }
            else if (ch is StaticText)
            {
                this.WriteStaticText((StaticText)ch);
            }
            else
            {
                /* ISSUE 73 */
                throw new SWFModellerException(
                          SWFModellerError.UnimplementedFeature,
                          "Character of type " + ch.GetType().ToString() + " not currently supported in writer");
            }

            if (ch is Timeline)
            {
                Timeline tl = (Timeline)ch;
                if (tl.HasClass && !(tl.Class is AdobeClass) && !unboundClasses.Contains(tl))
                {
                    unboundClasses.Add(tl);
                }
            }
        }
		public void ManyToManyUsingSet()
		{
			ActiveRecordStarter.Initialize(GetConfigSource(), 
				typeof(Order), typeof(Product)/*, typeof(LineItem)*/);
			Recreate();
			
			Order.DeleteAll();
			Product.DeleteAll();
			
			Order myOrder = new Order();
			myOrder.OrderedDate = DateTime.Parse("05/09/2004");
			Product coolGadget = new Product();
			coolGadget.Name = "PSP";
			coolGadget.Price = 250.39f;
			
			using (new SessionScope())
			{
				coolGadget.Save();
				ISet products = new ListSet();
				products.Add(coolGadget);
				myOrder.Products = products;
				myOrder.Save();
			}
			
			Order secondRef2Order = Order.Find(myOrder.ID);
			Assert.IsFalse(secondRef2Order.Products.IsEmpty);
			
			Product secondRef2Product = Product.Find(coolGadget.ID);
			Assert.AreEqual(1, secondRef2Product.Orders.Count);	
		}
Exemple #39
0
 /// <summary>
 /// Check that a ring does not self-intersect, except at its endpoints.
 /// Algorithm is to count the number of times each node along edge occurs.
 /// If any occur more than once, that must be a self-intersection.
 /// </summary>
 private void CheckNoSelfIntersectingRing(EdgeIntersectionList eiList)
 {
     ISet nodeSet = new ListSet();    
     bool isFirst = true;
     foreach(EdgeIntersection ei in eiList)
     {                
         if (isFirst)
         {
             isFirst = false;
             continue;
         }
         if (nodeSet.Contains(ei.Coordinate))
         {
             validErr = new TopologyValidationError(TopologyValidationErrors.RingSelfIntersection, ei.Coordinate);
             return;
         }
         else nodeSet.Add(ei.Coordinate);
     }
 }
 /// <summary>
 /// Return an array of object-type property names that are unsatisfied.
 /// </summary>
 /// <remarks>
 /// <p>
 /// These are probably unsatisfied references to other objects in the
 /// factory. Does not include simple properties like primitives or
 /// <see cref="System.String"/>s.
 /// </p>
 /// </remarks>
 /// <returns>
 /// An array of object-type property names that are unsatisfied.
 /// </returns>
 /// <param name="definition">
 /// The definition of the named object.
 /// </param>
 /// <param name="wrapper">
 /// The <see cref="Spring.Objects.IObjectWrapper"/> wrapping the target object.
 /// </param>
 protected string[] UnsatisfiedNonSimpleProperties(RootObjectDefinition definition, IObjectWrapper wrapper)
 {
     ListSet results = new ListSet();
     IPropertyValues pvs = definition.PropertyValues;
     PropertyInfo[] properties = wrapper.GetPropertyInfos();
     foreach (PropertyInfo property in properties)
     {
         string name = property.Name;
         if (property.CanWrite
             && !IsExcludedFromDependencyCheck(property)
             && !pvs.Contains(name)
             && !ObjectUtils.IsSimpleProperty(property.PropertyType))
         {
             results.Add(name);
         }
     }
     return (string[])CollectionUtils.ToArray(results, typeof(string));
 }