public void PlaceShips(System.Collections.ObjectModel.ReadOnlyCollection <Ship> ships)
        {
            BoardView <bool> board = new BoardView <bool>(size);
            var AllOrientations    = new[] {
                ShipOrientation.Horizontal,
                ShipOrientation.Vertical
            };

            foreach (var ship in ships)
            {
                int avoidTouching = 3;
                while (!ship.IsPlaced)
                {
                    var l = rand.Pick(board.Select(c => c.Location));
                    var o = rand.Pick(AllOrientations);
                    if (ship.IsLegal(ships, size, l, o))
                    {
                        if (ship.IsTouching(ships, l, o) && --avoidTouching > 0)
                        {
                            continue;
                        }
                        ship.Place(l, o);
                    }
                }
            }
        }
        /// <summary>
        /// Initializes all the primitive types
        /// </summary>
        private void InitializePrimitiveTypes()
        {
            if (_primitiveTypes != null)
            {
                return;
            }

            PrimitiveType[] primitiveTypes = new PrimitiveType[s_PrimitiveTypeCount];
            primitiveTypes[(int)PrimitiveTypeKind.Binary]         = CreatePrimitiveType(typeof(Byte[]), PrimitiveTypeKind.Binary);
            primitiveTypes[(int)PrimitiveTypeKind.Boolean]        = CreatePrimitiveType(typeof(Boolean), PrimitiveTypeKind.Boolean);
            primitiveTypes[(int)PrimitiveTypeKind.Byte]           = CreatePrimitiveType(typeof(Byte), PrimitiveTypeKind.Byte);
            primitiveTypes[(int)PrimitiveTypeKind.DateTime]       = CreatePrimitiveType(typeof(DateTime), PrimitiveTypeKind.DateTime);
            primitiveTypes[(int)PrimitiveTypeKind.Time]           = CreatePrimitiveType(typeof(TimeSpan), PrimitiveTypeKind.Time);
            primitiveTypes[(int)PrimitiveTypeKind.DateTimeOffset] = CreatePrimitiveType(typeof(DateTimeOffset), PrimitiveTypeKind.DateTimeOffset);
            primitiveTypes[(int)PrimitiveTypeKind.Decimal]        = CreatePrimitiveType(typeof(Decimal), PrimitiveTypeKind.Decimal);
            primitiveTypes[(int)PrimitiveTypeKind.Double]         = CreatePrimitiveType(typeof(Double), PrimitiveTypeKind.Double);
            primitiveTypes[(int)PrimitiveTypeKind.Geography]      = CreatePrimitiveType(typeof(DbGeography), PrimitiveTypeKind.Geography);
            primitiveTypes[(int)PrimitiveTypeKind.Geometry]       = CreatePrimitiveType(typeof(DbGeometry), PrimitiveTypeKind.Geometry);
            primitiveTypes[(int)PrimitiveTypeKind.Guid]           = CreatePrimitiveType(typeof(Guid), PrimitiveTypeKind.Guid);
            primitiveTypes[(int)PrimitiveTypeKind.Int16]          = CreatePrimitiveType(typeof(Int16), PrimitiveTypeKind.Int16);
            primitiveTypes[(int)PrimitiveTypeKind.Int32]          = CreatePrimitiveType(typeof(Int32), PrimitiveTypeKind.Int32);
            primitiveTypes[(int)PrimitiveTypeKind.Int64]          = CreatePrimitiveType(typeof(Int64), PrimitiveTypeKind.Int64);
            primitiveTypes[(int)PrimitiveTypeKind.SByte]          = CreatePrimitiveType(typeof(SByte), PrimitiveTypeKind.SByte);
            primitiveTypes[(int)PrimitiveTypeKind.Single]         = CreatePrimitiveType(typeof(Single), PrimitiveTypeKind.Single);
            primitiveTypes[(int)PrimitiveTypeKind.String]         = CreatePrimitiveType(typeof(String), PrimitiveTypeKind.String);

            System.Collections.ObjectModel.ReadOnlyCollection <PrimitiveType> readOnlyTypes = new System.Collections.ObjectModel.ReadOnlyCollection <PrimitiveType>(primitiveTypes);

            // Set the result to _primitiveTypes at the end
            Interlocked.CompareExchange <System.Collections.ObjectModel.ReadOnlyCollection <PrimitiveType> >(ref _primitiveTypes, readOnlyTypes, null);
        }
Exemple #3
0
 protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
 {
     // Subsequent launches
     base.OnStartupNextInstance(eventArgs);
     _commandLine = eventArgs.CommandLine;
     _application.Activate(_commandLine.ToArray());
 }
Exemple #4
0
 private static IEnumerable <int> GetCells(IWebElement row)
 {
     System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> cells = row.FindElements(By.TagName("td"));
     foreach (IWebElement cell in cells)
     {
         yield return(int.Parse(cell.Text));
     }
 }
Exemple #5
0
 internal static Boxi CreateFromPointList(System.Collections.ObjectModel.ReadOnlyCollection <Vec2i> points, int positionY)
 {
     Vec2i[] array = new Vec2i[points.Count];
     for (int i = 0; i < points.Count; ++i)
     {
         array[i] = points[i];
     }
     return(CreateFromPointList(array, positionY));
 }
Exemple #6
0
        public static string ReadtheRefID()
        {
            DL_Lab_MRR_Table.NavigateToLastPage(DL_Lab_MRR_Table.Pager);
            System.Collections.ObjectModel.ReadOnlyCollection <IControl> rows = null;
            int    rowCount = WebTableUtilities.GetRowCount(DL_Lab_MRR_Table.MrrTable, out rows);
            string refID    = WebTableUtilities.GetValue(DL_Lab_MRR_Table.MrrTable, rowCount - 1, 1);

            return(refID);
        }
Exemple #7
0
        // effects: Returns true if the key exists and false if not.
        //          In case the Key exists, the out parameter is assigned the List for that key,
        //          otherwise it is assigned a null value
        internal bool TryGetListForKey(TKey key, out System.Collections.ObjectModel.ReadOnlyCollection <TValue> valueCollection)
        {
            List <TValue> list;

            valueCollection = null;
            if (m_map.TryGetValue(key, out list))
            {
                valueCollection = new System.Collections.ObjectModel.ReadOnlyCollection <TValue>(list);
                return(true);
            }
            return(false);
        }
 static IControl GetFilterCell(IControl filterRow, int columnIndex)
 {
     if (filterRow != null && filterRow.WebElement != null)
     {
         System.Collections.ObjectModel.ReadOnlyCollection <IControl> filterCellList = SyncUtilities.FindElements_Parent(filterRow.WebElement, By.TagName("th"));
         if (columnIndex < filterCellList.Count)
         {
             return(filterCellList[columnIndex]);
         }
     }
     return(null);
 }
        public FieldNameLookup(System.Collections.ObjectModel.ReadOnlyCollection <string> columnNames, int defaultLocaleID)
        {
            int count = columnNames.Count;

            string[] strArray = new string[count];
            for (int i = 0; i < count; i++)
            {
                strArray[i] = columnNames[i];
            }
            this._fieldNames      = strArray;
            this._defaultLocaleID = defaultLocaleID;
            this.GenerateLookup();
        }
Exemple #10
0
        public PortableDeviceManager()

        {
            _Manager = (COMNative.PortableDevices.IPortableDeviceManager) new COMNative.PortableDevices.PortableDeviceManager();

            _portableDevices = new List <PortableDevice>();

            PortableDevices = new System.Collections.ObjectModel.ReadOnlyCollection <PortableDevice>(_portableDevices);

            _privatePortableDevices = new List <PortableDevice>();

            PrivatePortableDevices = new System.Collections.ObjectModel.ReadOnlyCollection <PortableDevice>(_privatePortableDevices);
        }
Exemple #11
0
        private void FazerLogin()
        {
            DigitaTextoId("ct", _banco.LerConfiguracao("usuario"));
            ClicaId("IBOK");
            TrocaPopUp(By.Id("tc1"), true);
            #region TELA DE LOGIN - BUSCA TECLAS DAS SENHAS E FORÇA LOGIN
            var senha = _banco.LerConfiguracao("senha");

            List <IWebElement> listaTeclas = new List <IWebElement>();
            listaTeclas.Add(driver.FindElement(By.Id("tc1")));
            listaTeclas.Add(driver.FindElement(By.Id("tc2")));
            listaTeclas.Add(driver.FindElement(By.Id("tc3")));
            listaTeclas.Add(driver.FindElement(By.Id("tc4")));
            listaTeclas.Add(driver.FindElement(By.Id("tc5")));
            listaTeclas.Add(driver.FindElement(By.Id("tc6")));
            listaTeclas.Add(driver.FindElement(By.Id("tc7")));
            listaTeclas.Add(driver.FindElement(By.Id("tc8")));
            listaTeclas.Add(driver.FindElement(By.Id("tc9")));
            listaTeclas.Add(driver.FindElement(By.Id("tc10")));

            var teclas = new System.Collections.ObjectModel.ReadOnlyCollection <IWebElement>(listaTeclas);

            foreach (var itemSENHA in senha.ToArray())
            {
                if (teclas.Count == 0)
                {
                    teclas = driver.FindElements(By.ClassName("esconde"));
                }

                foreach (var itemTECLA in teclas)
                {
                    if (itemTECLA.Text == itemSENHA.ToString())
                    {
                        itemTECLA.Click();
                        break;
                    }
                }
            }

            //clica no botão para entrar no banco

            driver.FindElements(By.ClassName("Coluna200"))[1].FindElement(By.CssSelector("a[onclick*='document.form1.submit()']")).Click();
            #endregion
        }
Exemple #12
0
 /// <summary>
 /// Purpose: Entry point to the program and test method for delegates and Lambda Expressions
 /// </summary>
 static void Main()
 {
     Program prog = new Program();
     //------------ Declaration and initialization of a delegrate variable-------------
     MyDelegate mdel1 = new MyDelegate(prog.Method_1);   //old initialization
     MyDelegate mdel2 = prog.Method_1;   //shorter way
     MyDelegate mdel3 = mdel1;   //assignment of one reference to another
     mdel3 += mdel2;     //chaining of delegate references
     mdel3 += mdel3;     //chaining of delegate references
     Console.WriteLine(mdel3(222, 55.55));
     //------------ new chaining initialization -------------
     mdel3 = prog.Method_1;
     mdel3 += prog.Method_2;
     mdel3 += prog.Method_3;
     mdel3 += prog.Method_4;
     Console.WriteLine(mdel3(1, 7.7));
     //------------ unchain assignment -------------
     mdel3 -= prog.Method_1;
     Console.WriteLine(mdel3(1, 3.33));
     //------------ chaining of references -------------
     mdel3 = mdel3 + mdel2 + mdel1;
     //------------ anonymous delegate declaration -------------
     mdel3 += delegate(int a, double b) { Console.WriteLine("Anonymous iv={0:D} dv={1:F2}", a, b); return "Anonymous"; };
     //------------ Declaration of a Lambda Expression -------------
     mdel3 += (c, d) => "Lambda Expression";
     Console.WriteLine(mdel3(5, 3.75));
     //------------ Declaration of a Lambda Expression using an outer variable max -------------
     int max = 100;
     Func<int> fdel = () => max + 5;
     Console.WriteLine("fdel -> {0:D}", fdel());
     //------------ Declaration and initialization of an Expression -------------
     Expression<Func<int,int,bool>> exp = (a,b) => a> b;
     Func<int,int,bool> A = exp.Compile();
     //var B = exp.Parameters;
     System.Collections.ObjectModel.ReadOnlyCollection<ParameterExpression> B = exp.Parameters;
     var C = exp.Body;
     string D = exp.ToString();
     var E = exp.Type;
     Console.Write("\nPress Enter to continue ... ");
     Console.ReadLine();
 }//End Main()
Exemple #13
0
 /// <summary>
 /// Returns all bottom-level mappings (e.g. conditions and scalar property mappings but not complex property mappings
 /// whose components are returned)
 /// </summary>
 private static IEnumerable <StoragePropertyMapping> FlattenPropertyMappings(System.Collections.ObjectModel.ReadOnlyCollection <StoragePropertyMapping> propertyMappings)
 {
     foreach (StoragePropertyMapping propertyMapping in propertyMappings)
     {
         StorageComplexPropertyMapping complexPropertyMapping = propertyMapping as StorageComplexPropertyMapping;
         if (null != complexPropertyMapping)
         {
             foreach (StorageComplexTypeMapping complexTypeMapping in complexPropertyMapping.TypeMappings)
             {
                 // recursively call self with nested type
                 foreach (StoragePropertyMapping nestedPropertyMapping in FlattenPropertyMappings(complexTypeMapping.AllProperties))
                 {
                     yield return(nestedPropertyMapping);
                 }
             }
         }
         else
         {
             yield return(propertyMapping);
         }
     }
 }
        public static ReadOnlyCollection <LocalVariableInfo> GetLocalVars(string asmPath, string typeName, string methodName)
        {
            Assembly   asm     = Assembly.LoadFrom(asmPath);
            Type       asmType = asm.GetType(typeName);
            MethodInfo mi      = asmType.GetMethod(methodName);
            MethodBody mb      = mi.GetMethodBody();

            System.Collections.ObjectModel.ReadOnlyCollection <LocalVariableInfo> vars =
                (System.Collections.ObjectModel.ReadOnlyCollection <LocalVariableInfo>)
                mb.LocalVariables;

            // Display information about each local variable
            foreach (LocalVariableInfo lvi in vars)
            {
                Console.WriteLine($"IsPinned: {lvi.IsPinned}");
                Console.WriteLine($"LocalIndex: {lvi.LocalIndex}");
                Console.WriteLine($"LocalType.Module: {lvi.LocalType.Module}");
                Console.WriteLine($"LocalType.FullName: {lvi.LocalType.FullName}");
                Console.WriteLine($"ToString(): {lvi.ToString()}");
            }
            return(vars);
        }
Exemple #15
0
 protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs eventArgs)
 {
     // First time _application is launched
     _commandLine = eventArgs.CommandLine;
     _application = new App();
     try
     {
         _application.Run();
     }
     catch (Exception ex)
     {
         while (ex.InnerException != null)
         {
             ex = ex.InnerException;
         }
         MessageBox.Show(Application.Current.MainWindow, ex.Message + Environment.NewLine + ex.StackTrace, "Serious problem occured - App may crash!", MessageBoxButton.OK, MessageBoxImage.Error);
         ((ServiceLocator.GetService <IMainWindow>() as Window1).DataContext as Main).ExitCommand.Execute(null);
         return(false);
     }
     ((ServiceLocator.GetService <IMainWindow>() as Window1).DataContext as Main).ExitCommand.Execute(null);
     return(false);
 }
        /// <summary>
        /// Initializes all the primitive types
        /// </summary>
        private void InitializePrimitiveTypes()
        {
            if (_primitiveTypes != null)
            {
                return;
            }

            PrimitiveType[] primitiveTypes = new PrimitiveType[s_PrimitiveTypeCount];
            primitiveTypes[(int)PrimitiveTypeKind.Binary] = CreatePrimitiveType(typeof(Byte[]), PrimitiveTypeKind.Binary);
            primitiveTypes[(int)PrimitiveTypeKind.Boolean] = CreatePrimitiveType(typeof(Boolean), PrimitiveTypeKind.Boolean);
            primitiveTypes[(int)PrimitiveTypeKind.Byte] = CreatePrimitiveType(typeof(Byte), PrimitiveTypeKind.Byte);
            primitiveTypes[(int)PrimitiveTypeKind.DateTime] = CreatePrimitiveType(typeof(DateTime), PrimitiveTypeKind.DateTime);
            primitiveTypes[(int)PrimitiveTypeKind.Time] = CreatePrimitiveType(typeof(TimeSpan), PrimitiveTypeKind.Time);
            primitiveTypes[(int)PrimitiveTypeKind.DateTimeOffset] = CreatePrimitiveType(typeof(DateTimeOffset), PrimitiveTypeKind.DateTimeOffset);
            primitiveTypes[(int)PrimitiveTypeKind.Decimal] = CreatePrimitiveType(typeof(Decimal), PrimitiveTypeKind.Decimal);
            primitiveTypes[(int)PrimitiveTypeKind.Double] = CreatePrimitiveType(typeof(Double), PrimitiveTypeKind.Double);
            primitiveTypes[(int)PrimitiveTypeKind.Geography] = CreatePrimitiveType(typeof(DbGeography), PrimitiveTypeKind.Geography);
            primitiveTypes[(int)PrimitiveTypeKind.Geometry] = CreatePrimitiveType(typeof(DbGeometry), PrimitiveTypeKind.Geometry);
            primitiveTypes[(int)PrimitiveTypeKind.Guid] = CreatePrimitiveType(typeof(Guid), PrimitiveTypeKind.Guid);
            primitiveTypes[(int)PrimitiveTypeKind.Int16] = CreatePrimitiveType(typeof(Int16), PrimitiveTypeKind.Int16);
            primitiveTypes[(int)PrimitiveTypeKind.Int32] = CreatePrimitiveType(typeof(Int32), PrimitiveTypeKind.Int32);
            primitiveTypes[(int)PrimitiveTypeKind.Int64] = CreatePrimitiveType(typeof(Int64), PrimitiveTypeKind.Int64);
            primitiveTypes[(int)PrimitiveTypeKind.SByte] = CreatePrimitiveType(typeof(SByte), PrimitiveTypeKind.SByte);
            primitiveTypes[(int)PrimitiveTypeKind.Single] = CreatePrimitiveType(typeof(Single), PrimitiveTypeKind.Single);
            primitiveTypes[(int)PrimitiveTypeKind.String] = CreatePrimitiveType(typeof(String), PrimitiveTypeKind.String);

            System.Collections.ObjectModel.ReadOnlyCollection<PrimitiveType> readOnlyTypes = new System.Collections.ObjectModel.ReadOnlyCollection<PrimitiveType>(primitiveTypes);

            // Set the result to _primitiveTypes at the end
            Interlocked.CompareExchange<System.Collections.ObjectModel.ReadOnlyCollection<PrimitiveType>>(ref _primitiveTypes, readOnlyTypes, null);
        }
Exemple #17
0
            private bool DeleteProducts(
                IReadOnlyCollection <ProductCatalog> productCatalogs,
                ICatalogPublisher catalogPublisher)
            {
                Stopwatch watchTotalDelete = Stopwatch.StartNew();
                bool      changesDetected  = false;

                //// 1: delete listings for the catalogs which are no longer exist in AX (were retracted for instance).
                //// This is the one of 2 fastest steps (because we don't need to query CRT for each product to figure out whether it is still there or not)

                DataAccessor dataAccessor = new DataAccessor(this.onlineChannel.RecordId, this.runtime.Configuration.ConnectionString, this.publishingConfig.CRTListingPageSize);
                Stopwatch    watch        = Stopwatch.StartNew();
                Dictionary <string, List <long> > catalogsToBeDeleted = dataAccessor.GetNotExistingCatalogs(productCatalogs);

                watch.Stop();
                this.LogTimingMessage(Resources.Duration_GetNotExistingCatalogs, watch.Elapsed, catalogsToBeDeleted.Count, catalogsToBeDeleted.Values.Count);

                if (catalogsToBeDeleted.Count > 0)
                {
                    watch.Restart();
                    catalogPublisher.OnDeleteProductsByCatalogIdRequested(catalogsToBeDeleted);
                    watch.Stop();
                    this.LogTimingMessage(Resources.Duration_Processor_DeleteListingsByCatalogs, watch.Elapsed);
                }

                watch.Restart();
                dataAccessor.DeleteListingsByCatalogs(catalogsToBeDeleted.SelectMany(c => c.Value));
                watch.Stop();
                this.LogTimingMessage(Resources.Duration_Manager_DeleteListingsByCatalogs, watch.Elapsed);

                // 2. delete listings for languages which are no longer exist on channel, this is another fast operation (in terms of querying CRT).
                watch.Restart();
                Dictionary <string, List <string> > languagesToBeDeleted = dataAccessor.GetNotExistingLanguages(this.ChannelLanguages);

                watch.Stop();
                this.LogTimingMessage(Resources.Duration_GetNotExistingLanguages, watch.Elapsed, languagesToBeDeleted.Keys.Count, languagesToBeDeleted.Values.Count);

                if (languagesToBeDeleted.Count > 0)
                {
                    watch.Restart();
                    catalogPublisher.OnDeleteProductsByLanguageIdRequested(languagesToBeDeleted);
                    watch.Stop();
                    this.LogTimingMessage(Resources.Duration_Processor_DeleteListingsByLanguage, watch.Elapsed);
                }

                if (languagesToBeDeleted.Count > 0)
                {
                    watch.Restart();
                    dataAccessor.DeleteListingsByLanguages(languagesToBeDeleted.SelectMany(c => c.Value));
                    watch.Stop();
                    this.LogTimingMessage(Resources.Duration_Processor_DeleteListingsByLanguages, watch.Elapsed);
                }

                changesDetected |= (catalogsToBeDeleted.Count > 0) || (languagesToBeDeleted.Count > 0);

                if (this.publishingConfig.CheckEveryListingForRemoval)
                {
                    // 3: Finally read all listings left from published listings table and ask CRT whehter the product still available there or not
                    watch.Restart();
                    Dictionary <long, List <ListingIdentity> > catalogs = dataAccessor.LoadAllListingsMap();
                    watch.Stop();
                    int listingsCount = 0;
                    foreach (List <ListingIdentity> list in catalogs.Values)
                    {
                        listingsCount += list.Count;
                    }

                    this.LogTimingMessage(Resources.Duration_LoadListingsMap, watch.Elapsed, listingsCount, catalogs.Keys.Count);

                    // Loop over published listings which are grouped by a catalog
                    foreach (KeyValuePair <long, List <ListingIdentity> > catalog in catalogs)
                    {
                        int bottomIndex = 0;
                        List <ListingIdentity> publishedIds = catalog.Value;

                        // Calling CRT, in a separate pages, to find out whether the products are still available or not.
                        while (bottomIndex < publishedIds.Count)
                        {
                            int topIndex = bottomIndex + this.publishingConfig.CRTListingPageSize - 1;
                            if (topIndex + 1 >= publishedIds.Count)
                            {
                                topIndex = publishedIds.Count - 1;
                            }

                            List <ListingIdentity> currentPagePublishedIds = publishedIds.GetRange(bottomIndex, topIndex + 1 - bottomIndex);
                            int previousBottomIndex = bottomIndex;
                            bottomIndex = topIndex + 1;

                            watch.Restart();
                            System.Collections.ObjectModel.ReadOnlyCollection <ProductExistenceId> crtIds = this.VerifyProductExistence(catalog.Key, ConvertToProductExistenceId(currentPagePublishedIds));
                            watch.Stop();
                            this.LogTimingMessage(Resources.Duration_VerifyProductExistence, watch.Elapsed, currentPagePublishedIds.Count, previousBottomIndex, publishedIds.Count, crtIds.Count);

                            IList <ListingIdentity> idsToBeRemoved = GetIdsToBeRemoved(crtIds, currentPagePublishedIds);
                            changesDetected |= idsToBeRemoved.Any();

                            if (idsToBeRemoved.Count > 0)
                            {
                                watch.Restart();
                                catalogPublisher.OnDeleteIndividualProductsRequested(idsToBeRemoved);
                                watch.Stop();
                                this.LogTimingMessage(Resources.Duration_Processor_DeleteListingsByCompositeIds, watch.Elapsed, idsToBeRemoved.Count);

                                watch.Restart();
                                dataAccessor.DeleteListingsByCompositeIds(catalog.Key, idsToBeRemoved);
                                watch.Stop();
                                this.LogTimingMessage(Resources.Duration_Manager_DeleteListingsByCompositeIds, watch.Elapsed, idsToBeRemoved.Count);
                            }

                            List <ListingPublishStatus> statuses = new List <ListingPublishStatus>();
                            foreach (ListingIdentity id in idsToBeRemoved)
                            {
                                statuses.Add(Listing.CreateStatusSuccessfullyDeleted(this.onlineChannel.RecordId, id.CatalogId, id.ProductId, id.LanguageId));
                            }

                            if (statuses.Count > 0)
                            {
                                this.UpdateListingPublishingStatus(statuses);
                            }
                        }
                    }

                    watchTotalDelete.Stop();
                    this.LogTimingMessage(Resources.Duration_DeleteProducts, watchTotalDelete.Elapsed, changesDetected);
                }

                return(changesDetected);
            }
Exemple #18
0
    public void Populate()
    {
        #region Types of Keywords

        FieldPublicDynamic = new { PropPublic1 = "A", PropPublic2 = 1, PropPublic3 = "B", PropPublic4 = "B", PropPublic5 = "B", PropPublic6 = "B", PropPublic7 = "B", PropPublic8 = "B", PropPublic9 = "B", PropPublic10 = "B", PropPublic11 = "B", PropPublic12 = new { PropSubPublic1 = 0, PropSubPublic2 = 1, PropSubPublic3 = 2 } };
        FieldPublicObject  = new StringBuilder("Object - StringBuilder");
        FieldPublicInt32   = int.MaxValue;
        FieldPublicInt64   = long.MaxValue;
        FieldPublicULong   = ulong.MaxValue;
        FieldPublicUInt    = uint.MaxValue;
        FieldPublicDecimal = 100000.999999m;
        FieldPublicDouble  = 100000.999999d;
        FieldPublicChar    = 'A';
        FieldPublicByte    = byte.MaxValue;
        FieldPublicBoolean = true;
        FieldPublicSByte   = sbyte.MaxValue;
        FieldPublicShort   = short.MaxValue;
        FieldPublicUShort  = ushort.MaxValue;
        FieldPublicFloat   = 100000.675555f;

        FieldPublicInt32Nullable   = int.MaxValue;
        FieldPublicInt64Nullable   = 2;
        FieldPublicULongNullable   = ulong.MaxValue;
        FieldPublicUIntNullable    = uint.MaxValue;
        FieldPublicDecimalNullable = 100000.999999m;
        FieldPublicDoubleNullable  = 100000.999999d;
        FieldPublicCharNullable    = 'A';
        FieldPublicByteNullable    = byte.MaxValue;
        FieldPublicBooleanNullable = true;
        FieldPublicSByteNullable   = sbyte.MaxValue;
        FieldPublicShortNullable   = short.MaxValue;
        FieldPublicUShortNullable  = ushort.MaxValue;
        FieldPublicFloatNullable   = 100000.675555f;

        #endregion

        #region System

        FieldPublicDateTime         = new DateTime(2000, 1, 1, 1, 1, 1);
        FieldPublicTimeSpan         = new TimeSpan(1, 10, 40);
        FieldPublicEnumDateTimeKind = DateTimeKind.Local;

        // Instantiate date and time using Persian calendar with years,
        // months, days, hours, minutes, seconds, and milliseconds
        FieldPublicDateTimeOffset = new DateTimeOffset(1387, 2, 12, 8, 6, 32, 545,
                                                       new System.Globalization.PersianCalendar(),
                                                       new TimeSpan(1, 0, 0));

        FieldPublicIntPtr         = new IntPtr(100);
        FieldPublicTimeZone       = TimeZone.CurrentTimeZone;
        FieldPublicTimeZoneInfo   = TimeZoneInfo.Utc;
        FieldPublicTuple          = Tuple.Create <string, int, decimal>("T-string\"", 1, 1.1m);
        FieldPublicType           = typeof(object);
        FieldPublicUIntPtr        = new UIntPtr(100);
        FieldPublicUri            = new Uri("http://www.site.com");
        FieldPublicVersion        = new Version(1, 0, 100, 1);
        FieldPublicGuid           = new Guid("d5010f5b-0cd1-44ca-aacb-5678b9947e6c");
        FieldPublicSingle         = Single.MaxValue;
        FieldPublicException      = new Exception("Test error", new Exception("inner exception"));
        FieldPublicEnumNonGeneric = EnumTest.ValueA;
        FieldPublicAction         = () => true.Equals(true);
        FieldPublicAction2        = (a, b) => true.Equals(true);
        FieldPublicFunc           = () => true;
        FieldPublicFunc2          = (a, b) => true;

        #endregion

        #region Arrays and Collections

        FieldPublicArrayUni    = new string[2];
        FieldPublicArrayUni[0] = "[0]";
        FieldPublicArrayUni[1] = "[1]";

        FieldPublicArrayTwo       = new string[2, 2];
        FieldPublicArrayTwo[0, 0] = "[0, 0]";
        FieldPublicArrayTwo[0, 1] = "[0, 1]";
        FieldPublicArrayTwo[1, 0] = "[1, 0]";
        FieldPublicArrayTwo[1, 1] = "[1, 1]";

        FieldPublicArrayThree          = new string[1, 1, 2];
        FieldPublicArrayThree[0, 0, 0] = "[0, 0, 0]";
        FieldPublicArrayThree[0, 0, 1] = "[0, 0, 1]";

        FieldPublicJaggedArrayTwo    = new string[2][];
        FieldPublicJaggedArrayTwo[0] = new string[5] {
            "a", "b", "c", "d", "e"
        };
        FieldPublicJaggedArrayTwo[1] = new string[4] {
            "a1", "b1", "c1", "d1"
        };

        FieldPublicJaggedArrayThree          = new string[1][][];
        FieldPublicJaggedArrayThree[0]       = new string[1][];
        FieldPublicJaggedArrayThree[0][0]    = new string[2];
        FieldPublicJaggedArrayThree[0][0][0] = "[0][0][0]";
        FieldPublicJaggedArrayThree[0][0][1] = "[0][0][1]";

        FieldPublicMixedArrayAndJagged = new int[3][, ]
        {
            new int[, ] {
                { 1, 3 }, { 5, 7 }
            },
            new int[, ] {
                { 0, 2 }, { 4, 6 }, { 8, 10 }
            },
            new int[, ] {
                { 11, 22 }, { 99, 88 }, { 0, 9 }
            }
        };

        FieldPublicDictionary = new System.Collections.Generic.Dictionary <string, string>();
        FieldPublicDictionary.Add("Key1", "Value1");
        FieldPublicDictionary.Add("Key2", "Value2");
        FieldPublicDictionary.Add("Key3", "Value3");
        FieldPublicDictionary.Add("Key4", "Value4");

        FieldPublicList = new System.Collections.Generic.List <int>();
        FieldPublicList.Add(0);
        FieldPublicList.Add(1);
        FieldPublicList.Add(2);

        FieldPublicQueue = new System.Collections.Generic.Queue <int>();
        FieldPublicQueue.Enqueue(10);
        FieldPublicQueue.Enqueue(11);
        FieldPublicQueue.Enqueue(12);

        FieldPublicHashSet = new System.Collections.Generic.HashSet <string>();
        FieldPublicHashSet.Add("HashSet1");
        FieldPublicHashSet.Add("HashSet2");

        FieldPublicSortedSet = new System.Collections.Generic.SortedSet <string>();
        FieldPublicSortedSet.Add("SortedSet1");
        FieldPublicSortedSet.Add("SortedSet2");
        FieldPublicSortedSet.Add("SortedSet3");

        FieldPublicStack = new System.Collections.Generic.Stack <string>();
        FieldPublicStack.Push("Stack1");
        FieldPublicStack.Push("Stack2");
        FieldPublicStack.Push("Stack3");

        FieldPublicLinkedList = new System.Collections.Generic.LinkedList <string>();
        FieldPublicLinkedList.AddFirst("LinkedList1");
        FieldPublicLinkedList.AddLast("LinkedList2");
        FieldPublicLinkedList.AddAfter(FieldPublicLinkedList.Find("LinkedList1"), "LinkedList1.1");

        FieldPublicObservableCollection = new System.Collections.ObjectModel.ObservableCollection <string>();
        FieldPublicObservableCollection.Add("ObservableCollection1");
        FieldPublicObservableCollection.Add("ObservableCollection2");

        FieldPublicKeyedCollection = new MyDataKeyedCollection();
        FieldPublicKeyedCollection.Add(new MyData()
        {
            Data = "data1", Id = 0
        });
        FieldPublicKeyedCollection.Add(new MyData()
        {
            Data = "data2", Id = 1
        });

        var list = new List <string>();
        list.Add("list1");
        list.Add("list2");
        list.Add("list3");

        FieldPublicReadOnlyCollection = new ReadOnlyCollection <string>(list);

        FieldPublicReadOnlyDictionary           = new ReadOnlyDictionary <string, string>(FieldPublicDictionary);
        FieldPublicReadOnlyObservableCollection = new ReadOnlyObservableCollection <string>(FieldPublicObservableCollection);
        FieldPublicCollection = new Collection <string>();
        FieldPublicCollection.Add("collection1");
        FieldPublicCollection.Add("collection2");
        FieldPublicCollection.Add("collection3");

        FieldPublicArrayListNonGeneric = new System.Collections.ArrayList();
        FieldPublicArrayListNonGeneric.Add(1);
        FieldPublicArrayListNonGeneric.Add("a");
        FieldPublicArrayListNonGeneric.Add(10.0m);
        FieldPublicArrayListNonGeneric.Add(new DateTime(2000, 01, 01));

        FieldPublicBitArray    = new System.Collections.BitArray(3);
        FieldPublicBitArray[2] = true;

        FieldPublicSortedList = new System.Collections.SortedList();
        FieldPublicSortedList.Add("key1", 1);
        FieldPublicSortedList.Add("key2", 2);
        FieldPublicSortedList.Add("key3", 3);
        FieldPublicSortedList.Add("key4", 4);

        FieldPublicHashtableNonGeneric = new System.Collections.Hashtable();
        FieldPublicHashtableNonGeneric.Add("key1", 1);
        FieldPublicHashtableNonGeneric.Add("key2", 2);
        FieldPublicHashtableNonGeneric.Add("key3", 3);
        FieldPublicHashtableNonGeneric.Add("key4", 4);

        FieldPublicQueueNonGeneric = new System.Collections.Queue();
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric1");
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric2");
        FieldPublicQueueNonGeneric.Enqueue("QueueNonGeneric3");

        FieldPublicStackNonGeneric = new System.Collections.Stack();
        FieldPublicStackNonGeneric.Push("StackNonGeneric1");
        FieldPublicStackNonGeneric.Push("StackNonGeneric2");

        FieldPublicIEnumerable = FieldPublicSortedList;

        FieldPublicBlockingCollection = new System.Collections.Concurrent.BlockingCollection <string>();
        FieldPublicBlockingCollection.Add("BlockingCollection1");
        FieldPublicBlockingCollection.Add("BlockingCollection2");

        FieldPublicConcurrentBag = new System.Collections.Concurrent.ConcurrentBag <string>();
        FieldPublicConcurrentBag.Add("ConcurrentBag1");
        FieldPublicConcurrentBag.Add("ConcurrentBag2");
        FieldPublicConcurrentBag.Add("ConcurrentBag3");

        FieldPublicConcurrentDictionary = new System.Collections.Concurrent.ConcurrentDictionary <string, int>();
        FieldPublicConcurrentDictionary.GetOrAdd("ConcurrentDictionary1", 0);
        FieldPublicConcurrentDictionary.GetOrAdd("ConcurrentDictionary2", 0);

        FieldPublicConcurrentQueue = new System.Collections.Concurrent.ConcurrentQueue <string>();
        FieldPublicConcurrentQueue.Enqueue("ConcurrentQueue1");
        FieldPublicConcurrentQueue.Enqueue("ConcurrentQueue2");

        FieldPublicConcurrentStack = new System.Collections.Concurrent.ConcurrentStack <string>();
        FieldPublicConcurrentStack.Push("ConcurrentStack1");
        FieldPublicConcurrentStack.Push("ConcurrentStack2");

        // FieldPublicOrderablePartitioner = new OrderablePartitioner();
        // FieldPublicPartitioner;
        // FieldPublicPartitionerNonGeneric;

        FieldPublicHybridDictionary = new System.Collections.Specialized.HybridDictionary();
        FieldPublicHybridDictionary.Add("HybridDictionaryKey1", "HybridDictionary1");
        FieldPublicHybridDictionary.Add("HybridDictionaryKey2", "HybridDictionary2");

        FieldPublicListDictionary = new System.Collections.Specialized.ListDictionary();
        FieldPublicListDictionary.Add("ListDictionaryKey1", "ListDictionary1");
        FieldPublicListDictionary.Add("ListDictionaryKey2", "ListDictionary2");
        FieldPublicNameValueCollection = new System.Collections.Specialized.NameValueCollection();
        FieldPublicNameValueCollection.Add("Key1", "Value1");
        FieldPublicNameValueCollection.Add("Key2", "Value2");

        FieldPublicOrderedDictionary = new System.Collections.Specialized.OrderedDictionary();
        FieldPublicOrderedDictionary.Add(1, "OrderedDictionary1");
        FieldPublicOrderedDictionary.Add(2, "OrderedDictionary1");
        FieldPublicOrderedDictionary.Add("OrderedDictionaryKey2", "OrderedDictionary2");

        FieldPublicStringCollection = new System.Collections.Specialized.StringCollection();
        FieldPublicStringCollection.Add("StringCollection1");
        FieldPublicStringCollection.Add("StringCollection2");

        #endregion

        #region Several

        PropXmlDocument = new XmlDocument();
        PropXmlDocument.LoadXml("<xml>something</xml>");

        var tr = new StringReader("<Root>Content</Root>");
        PropXDocument         = XDocument.Load(tr);
        PropStream            = GenerateStreamFromString("Stream");
        PropBigInteger        = new System.Numerics.BigInteger(100);
        PropStringBuilder     = new StringBuilder("StringBuilder");
        FieldPublicIQueryable = new List <string>()
        {
            "IQueryable"
        }.AsQueryable();

        #endregion

        #region Custom

        FieldPublicMyCollectionPublicGetEnumerator           = new MyCollectionPublicGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsPublicGetEnumerator   = new MyCollectionInheritsPublicGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionExplicitGetEnumerator         = new MyCollectionExplicitGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsExplicitGetEnumerator = new MyCollectionInheritsExplicitGetEnumerator("a b c", new char[] { ' ' });
        FieldPublicMyCollectionInheritsTooIEnumerable        = new MyCollectionInheritsTooIEnumerable("a b c", new char[] { ' ' });

        FieldPublicEnumSpecific = EnumTest.ValueB;
        MyDelegate            = MethodDelegate;
        EmptyClass            = new EmptyClass();
        StructGeneric         = new ThreeTuple <int>(0, 1, 2);
        StructGenericNullable = new ThreeTuple <int>(0, 1, 2);
        FieldPublicNullable   = new Nullable <ThreeTuple <int> >(StructGeneric);

        #endregion
    }
Exemple #19
0
        protected override void ProcessOnMenuDeleteCommand()
        {
            if (this.SelectedElement is MetaModelLibrary)
            {
                if ((this.SelectedElement as MetaModelLibrary).ImportedLibrary == null)
                {
                    using (Transaction transaction = this.ModelingDocData.Store.TransactionManager.BeginTransaction("Unload model library."))
                    {
                        (this.SelectedElement as MetaModelLibrary).Delete();
                        transaction.Commit();
                    }
                    return;
                }

                List <ModelElement> classes = new List <ModelElement>();
                foreach (BaseModelContext mc in (this.SelectedElement as MetaModelLibrary).MetaModel.ModelContexts)
                {
                    if (mc is LibraryModelContext)
                    {
                        LibraryModelContext m = mc as LibraryModelContext;
                        foreach (DomainClass d in m.Classes)
                        {
                            classes.Add(d);
                            classes.AddRange(d.Properties);
                        }
                        foreach (DomainRelationship r in m.Relationships)
                        {
                            classes.AddRange(r.Roles);
                        }
                    }
                    if (mc is ExternModelContext)
                    {
                        classes.Add(mc);
                    }
                }


                DependenciesViewModel vm         = new DependenciesViewModel(LanguageDSLDocData.ViewModelStore, false);
                List <ModelElement>   metaModels = new List <ModelElement>();
                metaModels.Add((this.SelectedElement as MetaModelLibrary).MetaModel);

                System.Collections.ObjectModel.ReadOnlyCollection <ModelElement> libraries = this.SelectedElement.Store.ElementDirectory.FindElements(MetaModelLibrary.DomainClassId);
                foreach (ModelElement m in libraries)
                {
                    if (m != this.SelectedElement)
                    {
                        if ((m as MetaModelLibrary).ImportedLibrary != null)
                        {
                            metaModels.Add((m as MetaModelLibrary).ImportedLibrary);
                        }
                    }
                }

                vm.Set(classes, metaModels, LanguageDSLDependenciesItemsProvider.GetAllCategories());

                bool bDelete = true;
                if (vm.ActiveDependencies.Count > 0)
                {
                    DeleteElementsPopup popup = new DeleteElementsPopup();
                    popup.DataContext = vm;
                    if (popup.ShowDialog().Value != true)
                    {
                        bDelete = false;
                    }
                }

                if (bDelete)
                {
                    using (Transaction transaction = this.ModelingDocData.Store.TransactionManager.BeginTransaction("Unload model library."))
                    {
                        (this.SelectedElement as MetaModelLibrary).FilePath = null;
                        (this.SelectedElement as MetaModelLibrary).Delete();
                        transaction.Commit();
                    }
                }

                vm.Dispose();
                GC.Collect();
                return;
            }

            base.ProcessOnMenuDeleteCommand();
        }
Exemple #20
0
        /// <summary>
        /// Applies file name, children and imports from an other module instance
        /// </summary>
        /// <param name="Other"></param>
        public override void AssignFrom(INode Other)
        {
            if (Other is IAbstractSyntaxTree)
                ParseErrors = ((IAbstractSyntaxTree)Other).ParseErrors;

            base.AssignFrom(Other);
        }