public void ShouldSerializeCustomCollection()
		{
			var orig = new CustomCollection
			{
				AddressUri = new Uri("http://www.example.com/"),
				IntValue = 123,
				SomeType = typeof(CustomCollection)
			};

			var s = TypeSerializer.SerializeToString(orig);

			//FYI TypeSerializer is recognized as an IList<CustomCollectionItem>
			//Where CustomCollectionItem has a property of 'object Value' where it 
			//is unable to work out the original types so there deserialized back out as strings
			var clone = TypeSerializer.DeserializeFromString<CustomCollection>(s);

			Assert.That(clone, Is.Not.Null);
			Assert.That(clone, Has.All.No.Null);
			Assert.That(clone.Count, Is.EqualTo(orig.Count));
			Assert.That(clone.AddressUri, Is.EqualTo(orig.AddressUri));
			Assert.That(clone.IntValue, Is.EqualTo(orig.IntValue));
			Assert.That(clone.SomeType, Is.EqualTo(orig.SomeType));

			//Collections are not same, one has object values, the other has string values as explained above
			//Assert.That(clone, Is.EquivalentTo(orig));
		}
 async Task<bool> DealWithCustomRepo(CustomCollection customCollection) {
     if (!customCollection.HasCustomRepo() ||
         (!customCollection.CustomRepoUrl.EndsWith(".yml") ||
          customCollection.CustomRepoUrl.EndsWith("config.yml")))
         return true;
     var sixMessageBoxResult = await CustomRepoDialog(customCollection);
     return sixMessageBoxResult.IsYes();
 }
Exemple #3
0
 /// <summary>
 /// Creates new instance of metro tile and assigns the name and text to it.
 /// </summary>
 /// <param name="sItemName">Item name.</param>
 /// <param name="ItemText">item text.</param>
 public MetroTileItem(string sItemName, string ItemText)
     : base(sItemName, ItemText)
 {
     _Frames = new CustomCollection<MetroTileFrame>();
     _Frames.CollectionChanged += new NotifyCollectionChangedEventHandler(FramesCollectionChanged);
     MetroTileFrame frame = new MetroTileFrame();
     frame.MarkupLinkClick += new MarkupLinkClickEventHandler(MarkupLinkClick);
     _Frames.Add(frame);
 }
        //ExportFactory<PickContactViewModel> pickContactFactory, Lazy<ModsViewModel> mods
        public CustomRepoAvailabilityWarningViewModel(CustomCollection customCollection) {
            DisplayName = "Third party content";
            _customRepo = customCollection.CustomRepo;
            _customCollection = customCollection;

            this.SetCommand(x => x.OkCommand).Subscribe(() => {
                HandleDontAskAgain();
                TryClose(true);
            });
        }
        public void Add_AddNewItemByKeyWithNullName_ArgumentNullExceptionThrowed()
        {
            // arrange
            var collection = new CustomCollection<int, object, string>
            {
                {0, "James", "value0"}
            };

            // act and assert
            Assert.Throws<ArgumentNullException>(() => collection.Add(1, null, "value1"));
        }
        public void Add_AddNewItemByExistingKey_ArgumentOutOfRangeExceptionThrowed()
        {
            // arrange
            var collection = new CustomCollection<int, string, string>
            {
                {0, "James", "value0"}
            };

            // act and assert
            Assert.Throws<ArgumentOutOfRangeException>(() => collection.Add(0, "James", "value1"));
        }
        public void Refresh(CustomCollection customCollection) {
            Items.Clear();

            var customRepo = customCollection == null ? null : customCollection.CustomRepo;
            if (_updateManager.IsUpdateNeeded && (customCollection == null || !customCollection.ForceModUpdate))
                Items.Add(new MenuItem("Play without updating", () => Play()));
            if (customRepo == null)
                return;

            foreach (var app in customRepo.Apps.Where(x => !x.Value.IsHidden)) {
                Items.Add(new MenuItem(app.Value.GetDisplayName(),
                    () => { _processManager.StartAndForget(new ProcessStartInfo(app.Value.Address, null)); }));
            }
        }
Exemple #8
0
        public static CustomCollection GetCollection(object instance)
        {
            object col;
            var success = AttachedProperties.TryGetValue(instance, out col);
            if (success)
            {
                return (CustomCollection) col;
            }
            else
            {

                var customCollection = new CustomCollection();

                AttachedProperties[instance] = customCollection;
                return customCollection;
            }
        }
        public void Add_AddNewItemByNonExistingKey_NewItemAddedToCollection()
        {
            // arrange
            var collection = new CustomCollection<int, string, string>
            {
                {0, "James", "value0"},
                {1, "Michael", "value1"},
                {2, "John", "value2"},
                {0, "Michael", "value3"}
            };

            // act
            collection.Add(1, "John", "value4");

            // assert
            Assert.AreEqual(collection.Count, 5);
        }
Exemple #10
0
 public static void TestCC1()
 {
     Console.WriteLine("Test CC1");
     CustomCollection cc = new CustomCollection();
     for (int i = 0; i < 4; i++) {
         cc.Add(i);
     }
     for (int i = 0; i < 4; i++) {
         int o = Int32.Parse(cc[i]); // use indexer -- way cool!!
         Console.WriteLine("index[{0}]: {1}", i, o);
     }
     foreach (var j in cc) { // use IEnumerable
         Console.WriteLine("j = {0}", j);
     }
     for (int i = 0; i < 4; i++) { // use getter
         int o = Int32.Parse(cc.Get(i));
         Console.WriteLine("got: {0}", o);
     }
     cc.Clear();
 }
Exemple #11
0
        /// <summary>
        /// Add a registry requirement to an existing deployment type
        /// </summary>
        public static void AddRequirement(string applicationName, string authoringScopeId, string logicalName, string settingLogicalName, string value, string dataType, string expressionOperator, string server)
        {
            Application app = CMApplication.GetApplicationByName(applicationName, server);
            DeploymentType deploymentType = app.DeploymentTypes[0];

            CustomCollection<ExpressionBase> settingsOperands = new CustomCollection<ExpressionBase>();
            GlobalSettingReference settingReferences = null;
            ConstantValue constant = null;

            switch (dataType)
            {
                case "Version":
                    settingReferences = new GlobalSettingReference(authoringScopeId, logicalName, DataType.Version, settingLogicalName, ConfigurationItemSettingSourceType.Registry);
                    constant = new ConstantValue(value, DataType.Version);
                    break;
                default:
                    break;
            }

            settingsOperands.Add(settingReferences);
            settingsOperands.Add(constant);

            Expression expression = null;

            switch (expressionOperator)
            {
                case "IsEquals":
                    expression = new Expression(ExpressionOperator.IsEquals, settingsOperands);
                    break;
                case "LessEquals":
                    expression = new Expression(ExpressionOperator.LessEquals, settingsOperands);
                    break;
                default:
                    break;
            }

            Rule rule = new Rule(Guid.NewGuid().ToString("N"), NoncomplianceSeverity.Critical, null, expression);

            deploymentType.Requirements.Add(rule);
            CMApplication.Save(app, server);
        }
Exemple #12
0
        static void Main(string[] args)
        {
            CollectionIteratorDelegate<int> intDel = Iterator<int>.EvenEnumerator;
            CustomCollection<int> IntCollection = new CustomCollection<int>(new int[]{1,2,3,4,5});
            IEnumerator<int> intIterator = IntCollection.GetEnumerator(intDel);

            while (intIterator.MoveNext())
            {
                Console.Write("{0}\t",intIterator.Current);
            }
            Console.WriteLine();

            CollectionIteratorDelegate<double> doubleDel = Iterator<double>.UpToDownEnumerator;
            CustomCollection<double> doubleCollection = new CustomCollection<double>(new double[] { 0.2, 100.1, 0.3, 4.2 });
            IEnumerator<double> doubleIterator = doubleCollection.GetEnumerator(doubleDel);
            while (doubleIterator.MoveNext())
            {
                Console.Write("{0}\t",doubleIterator.Current);
            }
            Console.ReadKey(true);
        }
        public void CustomCollection_Iterate_List()
        {
            var customCollection =
                new CustomCollection<Person>(new[]
                {new Person("Ted", "A"), new Person("Andrew", "B"), new Person("Bob", "C")});

            var enumerator = customCollection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current.FirstName);
            }

            Console.WriteLine("\nSorted via Extension:");

            //            customCollection.SortArray();
            customCollection.SortIEnumerable();
            //            customCollection.ItemCollection.SortSelf();
            EnumerableExtensions.Each(customCollection, Console.WriteLine);

            //            Console.WriteLine("\nSorted Directly:");
            //            customCollection.SortManual();
            //            customCollection.Each(Console.WriteLine);
        }
        public void TryGet_GetValueByNonExistingKey_FalseResultAndDefaultValueReturned()
        {
            // arrange
            var collection = new CustomCollection<int, string, string>()
            {
                {0, "James", "value0"},
                {0, "Tom", "value1"},
                {1, "James", "value2"}
            };

            // act
            string item;
            var result = collection.TryGet(1, "Tom", out item);

            // assert
            Assert.IsFalse(result);
            Assert.IsNull(item);
        }
 public bool TestEquals(CustomCollection <Person> col1, CustomCollection <Person> col2)
 {
     return(col1.Equals(col2));
 }
        public override CustomCollection Clone() {
            var cm = new CustomCollection(Guid.NewGuid(), Game);
            cm.Import(this);

            return cm;
        }
Exemple #17
0
 void list_AfterRemove(object sender, CustomCollection <Sample> .CustomCollectionEventArgs e)
 {
     this.textBox2.Text += "\r\nAfterRemove";
 }
Exemple #18
0
        /// <summary>
        /// Add a script installer deployment type to an application, using registry key in HKLM
        /// </summary>
        public static void AddScriptInstaller(string applicationName, string installName, string hklmKey, bool is64bit, string valueName, string valueNameValue, string dataType, string expressionOperator, string installCommand, string uninstallCommand, int postInstallBehaviour, int userInteractMode, int maxExecTime, int estimateExecTime, int execContext, string server)
        {
            Application     app       = CMApplication.GetApplicationByName(applicationName, server);
            ScriptInstaller installer = ReturnStandardScriptInstaller(installCommand, uninstallCommand, postInstallBehaviour, userInteractMode, maxExecTime, estimateExecTime, execContext);

            installer.DetectionMethod = DetectionMethod.Enhanced;
            EnhancedDetectionMethod enhancedDetectionMethod = new EnhancedDetectionMethod();

            ConstantValue   expectedValue   = null;
            RegistrySetting registrySetting = new RegistrySetting(null);

            registrySetting.RootKey           = RegistryRootKey.LocalMachine;
            registrySetting.Key               = hklmKey;
            registrySetting.Is64Bit           = is64bit;
            registrySetting.ValueName         = valueName;
            registrySetting.CreateMissingPath = false;

            switch (dataType)
            {
            case "Version":
                registrySetting.SettingDataType = DataType.Version;
                expectedValue = new ConstantValue(valueNameValue, DataType.Version);
                break;

            default:
                break;
            }

            enhancedDetectionMethod.Settings.Add(registrySetting);

            SettingReference settingReference = new SettingReference(app.Scope, app.Name, app.Version.GetValueOrDefault(), registrySetting.LogicalName, registrySetting.SettingDataType, registrySetting.SourceType, false);

            settingReference.MethodType = ConfigurationItemSettingMethodType.Value;

            CustomCollection <ExpressionBase> operands = new CustomCollection <ExpressionBase>();

            operands.Add(settingReference);
            operands.Add(expectedValue);

            Expression expression = null;

            switch (expressionOperator)
            {
            case "IsEquals":
                expression = new Expression(ExpressionOperator.IsEquals, operands);
                break;

            case "LessEquals":
                expression = new Expression(ExpressionOperator.LessEquals, operands);
                break;

            default:
                break;
            }

            Rule rule = new Rule(Guid.NewGuid().ToString("N"), NoncomplianceSeverity.None, null, expression);

            enhancedDetectionMethod.Rule = rule;

            installer.EnhancedDetectionMethod = enhancedDetectionMethod;

            DeploymentType deploymentType = new DeploymentType(installer, ScriptInstaller.TechnologyId, NativeHostingTechnology.TechnologyId);

            deploymentType.Title = installName;
            app.DeploymentTypes.Add(deploymentType);

            CMApplication.Save(app, server);
        }
        public void CustomCollectionTest()
        {
            var originalCollection = new CustomCollection <MyModel>(true)
            {
                new MyModel(),
                new MyModel(),
                new MyModel()
            };

            var synchronizingCollection = new SynchronizingCollectionCore <MyDataModel, MyModel>(
                originalCollection, m => new MyDataModel(m));

            AssertHelper.SequenceEqual(originalCollection, synchronizingCollection.Select(dm => dm.Model));

            // Check add operation with collection changed event.
            bool handlerCalled = false;
            NotifyCollectionChangedEventHandler handler = (sender, e) =>
            {
                handlerCalled = true;
                Assert.AreEqual(synchronizingCollection, sender);
                Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action);
                Assert.AreEqual(3, e.NewStartingIndex);
                Assert.AreEqual(originalCollection.Last(), e.NewItems.Cast <MyDataModel>().Single().Model);
            };

            synchronizingCollection.CollectionChanged += handler;
            originalCollection.Add(new MyModel());
            synchronizingCollection.CollectionChanged -= handler;
            Assert.IsTrue(handlerCalled);

            // Compare the collections
            AssertHelper.SequenceEqual(originalCollection, synchronizingCollection.Select(dm => dm.Model));

            // Check remove operation with collection changed event.
            MyModel itemToRemove = originalCollection[2];

            handlerCalled = false;
            handler       = (sender, e) =>
            {
                handlerCalled = true;
                Assert.AreEqual(synchronizingCollection, sender);
                Assert.AreEqual(NotifyCollectionChangedAction.Remove, e.Action);
                Assert.AreEqual(2, e.OldStartingIndex);
                Assert.AreEqual(itemToRemove, e.OldItems.Cast <MyDataModel>().Single().Model);
            };
            synchronizingCollection.CollectionChanged += handler;
            originalCollection.Remove(itemToRemove);
            synchronizingCollection.CollectionChanged -= handler;
            Assert.IsTrue(handlerCalled);

            // Check replace operation with collection changed event.
            MyModel itemToReplace      = originalCollection[1];
            int     handlerCalledCount = 0;

            handler = (sender, e) =>
            {
                Assert.AreEqual(synchronizingCollection, sender);
                if (handlerCalledCount == 0)
                {
                    Assert.AreEqual(NotifyCollectionChangedAction.Remove, e.Action);
                    Assert.AreEqual(itemToReplace, e.OldItems.Cast <MyDataModel>().Single().Model);
                }
                else
                {
                    Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action);
                    Assert.AreEqual(originalCollection[1], e.NewItems.Cast <MyDataModel>().Single().Model);
                }
                handlerCalledCount++;
            };
            synchronizingCollection.CollectionChanged += handler;
            originalCollection[1] = new MyModel();
            synchronizingCollection.CollectionChanged -= handler;
            Assert.AreEqual(2, handlerCalledCount);

            // Check reset operation with collection changed event.
            var newItems = new List <MyModel>()
            {
                new MyModel(),
                new MyModel()
            };

            handlerCalledCount = 0;
            handler            = (sender, e) =>
            {
                Assert.AreEqual(synchronizingCollection, sender);
                if (handlerCalledCount == 0)
                {
                    Assert.AreEqual(NotifyCollectionChangedAction.Reset, e.Action);
                }
                else
                {
                    Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action);
                }
                handlerCalledCount++;
            };
            synchronizingCollection.CollectionChanged += handler;
            originalCollection.Reset(newItems);
            synchronizingCollection.CollectionChanged -= handler;
            Assert.AreEqual(3, handlerCalledCount);
            AssertHelper.SequenceEqual(newItems, synchronizingCollection.Select(dm => dm.Model));
        }
Exemple #20
0
        public static CollectionBase GenerateBossCollectionFromReader(IDataReader returnData)
        {
            //creating the instance of Employee collection
            CustomCollection<FirstLevelBoss> colBoss = new CustomCollection<FirstLevelBoss>();

            //Iterating through the data reader, to generate Employee collection.
            //each iteration cause to create a separate instance of Employee and be added to the Employee collection.
            while (returnData.Read())
            {
                FirstLevelBoss newBoss = new FirstLevelBoss
                (
                    returnData["EmployeeId"] == System.DBNull.Value ? GetIdMinValue : (int)returnData["EmployeeId"],
                    returnData["LastName"] == System.DBNull.Value ? string.Empty : (string)returnData["LastName"],
                    returnData["FirstName"] == System.DBNull.Value ? string.Empty : (string)returnData["FirstName"],
                    returnData["Title"] == System.DBNull.Value ? string.Empty : (string)returnData["Title"]
                );

                colBoss.Add(newBoss);
            }

            //returns the collection of Employee objects
            return (colBoss);
        }
 protected bool Equals(SupportedCustomCollectionModel2 other)
 {
     return(string.Equals(Id, other.Id) && (CustomCollection?.SequenceEqual(other.CustomCollection) ?? other.CustomCollection == null));
 }
Exemple #22
0
 public RootObject()
 {
     collection = new CustomCollection();
 }
 internal Enumerator(CustomCollection <T> collection)
 {
     _ptr      = collection._ptr;
     _index    = UInt32.MaxValue;
     _endIndex = (uint)collection.Length;
 }
Exemple #24
0
 public SixRepo()
 {
     Config      = new SixRepoConfig();
     Servers     = new Dictionary <string, SixRepoServer>();
     Collections = new CustomCollection[0];
 }
        static void Main(string[] args)
        {
            #region [TEST #1: SEARCH BY REFERENCE]

            var normalType1 = new NormalType(1, "Smith");
            var normalType2 = new NormalType(0, "Brown");
            var normalType3 = new NormalType(0, "Doe");

            var normalCollection = new CustomCollection<NormalType, string, string>
            {
                {normalType1, "Tom", "value0"},
                {normalType2, "Michael", "value1"},
                {normalType3, "John", "value2"}
            };

            var normalSearchResult1 = normalCollection[new NormalType(0, "Brown")].ToList();

            Debug.Assert(normalSearchResult1.Count == 0);

            var normalSearchResult2 = normalCollection[normalType2].ToList();

            Debug.Assert(normalSearchResult2.Count == 1);

            #endregion

            #region [TEST #2: SEARCH BY VALUE]

            var userType1 = new UserType(1, "Smith");
            var userType2 = new UserType(0, "Brown");
            var userType3 = new UserType(0, "Doe");

            var userCollection = new CustomCollection<UserType, string, string>
            {
                {userType1, "Tom", "value0"},
                {userType2, "Michael", "value1"},
                {userType3, "John", "value2"}
            };

            var userSearchResult = userCollection[new UserType(0, "Brown")].ToList();

            Debug.Assert(userSearchResult.Count == 1);

            #endregion
        }
        public void Values_GetAllValues_AllCollectionValuesReturned()
        {
            // arrange
            var collection = new CustomCollection<int, string, string>
            {
                {0, "James", "value0"},
                {1, "Michael", "value1"},
                {2, "John", "value2"},
                {0, "Michael", "value3"},
                {1, "John", "value4"}
            };

            // act
            var values = collection.Values.ToList();

            // assert
            Assert.AreEqual(values.Count, 5);
            Assert.IsTrue(values.Contains("value0"));
            Assert.IsTrue(values.Contains("value1"));
            Assert.IsTrue(values.Contains("value2"));
            Assert.IsTrue(values.Contains("value3"));
            Assert.IsTrue(values.Contains("value4"));
        }
        public void TryGet_GetValueByExistingKey_TrueResultAndValueWithSameKeyReturned()
        {
            // arrange
            var collection = new CustomCollection<int, string, string>()
            {
                {0, "James", "value0"},
                {0, "John", "value1"},
                {1, "James", "value2"}
            };

            // act
            string item;
            var result = collection.TryGet(0, "James", out item);

            // assert
            Assert.AreEqual(item, "value0");
            Assert.IsTrue(result);
        }
 public static void Add(this CustomCollection @this,
                        int value) => @this.Insert(value);
Exemple #29
0
 public RootObject()
 {
     collection = new CustomCollection();
 }
Exemple #30
0
 public void SaveAsBundle(CustomCollection collection, IAbsoluteDirectoryPath destination)
 {
     WriteBundleToDisk(CreateBundle(collection), destination);
 }
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Id != null ? Id.GetHashCode() : 0) * 397) ^ (CustomCollection != null ? CustomCollection.GetHashCode() : 0));
     }
 }
        Task<SixMessageBoxResult> CustomRepoDialog(CustomCollection customCollection) {
            return _dialogManager.MessageBoxAsync(
                new MessageBoxDialogParams(
                    @"Warning !!!

You are about to publish a collection that is linked to the following Custom Repository:

" + customCollection.CustomRepo.Name + "(" + customCollection.CustomRepoUrl + ")" + @"

Dependent on the publish state, the custom repository will be available publicly.

Are you authorized to publish the custom repository?",
                    "Are you authorized to publish this custom repository?", SixMessageBoxButton.YesNo));
        }
        public void Clear_ClearCollectionOf2Items_AllItemsRemoved()
        {
            // arrange
            var collecton = new CustomCollection<int, string, string>
            {
                {0, "John", "Smith"},
                {1, "James", "Bond"}
            };

            // act
            collecton.Clear();

            // assert
            Assert.AreEqual(collecton.Count, 0);
        }
Exemple #34
0
        /// <summary>
        /// Add a script installer deployment type to an application, using registry key in HKLM
        /// </summary>
        public static void AddScriptInstaller(string applicationName, string installName, string hklmKey, bool is64bit, string valueName, string valueNameValue, string dataType, string expressionOperator, string installCommand, string uninstallCommand, int postInstallBehaviour, int userInteractMode, int maxExecTime, int estimateExecTime, int execContext, string server)
        {
            Application app = CMApplication.GetApplicationByName(applicationName, server);
            ScriptInstaller installer = ReturnStandardScriptInstaller(installCommand, uninstallCommand, postInstallBehaviour, userInteractMode, maxExecTime, estimateExecTime, execContext);

            installer.DetectionMethod = DetectionMethod.Enhanced;
            EnhancedDetectionMethod enhancedDetectionMethod = new EnhancedDetectionMethod();

            ConstantValue expectedValue = null;
            RegistrySetting registrySetting = new RegistrySetting(null);
            registrySetting.RootKey = RegistryRootKey.LocalMachine;
            registrySetting.Key = hklmKey;
            registrySetting.Is64Bit = is64bit;
            registrySetting.ValueName = valueName;
            registrySetting.CreateMissingPath = false;

            switch (dataType)
            {
                case "Version":
                    registrySetting.SettingDataType = DataType.Version;
                    expectedValue = new ConstantValue(valueNameValue, DataType.Version);
                    break;
                default:
                    break;
            }

            enhancedDetectionMethod.Settings.Add(registrySetting);

            SettingReference settingReference = new SettingReference(app.Scope, app.Name, app.Version.GetValueOrDefault(), registrySetting.LogicalName, registrySetting.SettingDataType, registrySetting.SourceType, false);
            settingReference.MethodType = ConfigurationItemSettingMethodType.Value;

            CustomCollection<ExpressionBase> operands = new CustomCollection<ExpressionBase>();
            operands.Add(settingReference);
            operands.Add(expectedValue);

            Expression expression = null;

            switch (expressionOperator)
            {
                case "IsEquals":
                    expression = new Expression(ExpressionOperator.IsEquals, operands);
                    break;
                case "LessEquals":
                    expression = new Expression(ExpressionOperator.LessEquals, operands);
                    break;
                default:
                    break;
            }

            Rule rule = new Rule(Guid.NewGuid().ToString("N"), NoncomplianceSeverity.None, null, expression);
            enhancedDetectionMethod.Rule = rule;

            installer.EnhancedDetectionMethod = enhancedDetectionMethod;

            DeploymentType deploymentType = new DeploymentType(installer, ScriptInstaller.TechnologyId, NativeHostingTechnology.TechnologyId);
            deploymentType.Title = installName;
            app.DeploymentTypes.Add(deploymentType);

            CMApplication.Save(app, server);
        }
Exemple #35
0
 public ContainerWithReadOnlyCustomCollection()
 {
     Items = new CustomCollection();
 }
Exemple #36
0
        /// <summary>
        /// Add an operating system requirement to an existing deployment type
        /// </summary>
        public static void AddRequirement(string applicationName, OperatingSystemValues os, string server)
        {
            Application app = CMApplication.GetApplicationByName(applicationName, server);
            DeploymentType deploymentType = app.DeploymentTypes[0];

            string ruleExpressionText = string.Empty;
            string ruleAnnotationText = string.Empty;

            switch (os)
            {
                case OperatingSystemValues.Windows81x86:
                    ruleExpressionText = "Windows/All_x86_Windows_8.1_Client";
                    ruleAnnotationText = "Operating system One of {All Windows 8.1(32 - bit)}";
                    break;
                case OperatingSystemValues.Windows81x64:
                    ruleExpressionText = "Windows/All_x64_Windows_8.1_Client";
                    ruleAnnotationText = "Operating system One of {All Windows 8.1(64 - bit)}";
                    break;
                case OperatingSystemValues.Windows10x86:
                    ruleExpressionText = "Windows/All_x86_Windows_10_and_higher_Clients";
                    ruleAnnotationText = "Operating system One of {All Windows 10 Professional/Enterprise and higher (32 - bit)}";
                    break;
                case OperatingSystemValues.Windows10x64:
                    ruleExpressionText = "Windows/All_x64_Windows_10_and_higher_Clients";
                    ruleAnnotationText = "Operating system One of {All Windows 10 Professional/Enterprise and higher (64 - bit)}";
                    break;
            }

            CustomCollection<RuleExpression> ruleCollection = new CustomCollection<RuleExpression>();
            RuleExpression ruleExpression = new RuleExpression(ruleExpressionText);
            ruleCollection.Add(ruleExpression);

            OperatingSystemExpression osExpression = new OperatingSystemExpression(ExpressionOperator.OneOf, ruleCollection);

            Rule rule = new Rule(Guid.NewGuid().ToString("N"), NoncomplianceSeverity.None, new Annotation(ruleAnnotationText, null, null, null), osExpression);

            deploymentType.Requirements.Add(rule);
            CMApplication.Save(app, server);
        }
Exemple #37
0
 void list_ItemPropertyChanged(object sender, CustomCollection <Sample> .CustomCollectionEventArgs e)
 {
     this.textBox2.Text += "\r\nPropertyChanged";
 }
 Bundle CreateBundle(CustomCollection collection) {
     return _mapper.Map<Bundle>(collection);
 }
Exemple #39
0
 void list_AfterSet(object sender, CustomCollection <Sample> .CustomCollectionEventArgs2 e)
 {
     this.textBox2.Text += "\r\nAfterSet";
 }
        public void TryGet_GetValueByKeyWithNullName_ArgumentNullExceptionThrowed()
        {
            // arrange
            var collection = new CustomCollection<int, object, string>()
            {
                {0, "James", "value0"},
                {0, "Tom", "value1"},
                {1, "James", "value2"}
            };

            // act and assert
            string item;
            Assert.Throws<ArgumentNullException>(() => collection.TryGet(2, null, out item));
        }
Exemple #41
0
 public CustomCollectionUninitializedPartViaParameter([MefV1.ImportMany] CustomCollection <IServiceProvider> exports)
 {
 }
		public ObjectGraph()
		{
			internalCollection = new CustomCollection();
		}
 public void SaveAsBundle(CustomCollection collection, IAbsoluteDirectoryPath destination) {
     WriteBundleToDisk(CreateBundle(collection), destination);
 }
		protected ObjectGraph(SerializationInfo info, StreamingContext context)
		{
			internalCollection = (CustomCollection)info.GetValue("col", typeof(CustomCollection));
			Data = (DataContainer)info.GetValue("data", typeof(DataContainer));
		}
Exemple #45
0
 Bundle CreateBundle(CustomCollection collection) => _mapper.Map <Bundle>(collection);
 public int TestTrim(CustomCollection <Person> col)
 {
     col.Trim();
     return(col.Size);
 }
Exemple #47
0
        /// <summary>
        /// Creates and returns a strongly typed collection of Employee custom entity. 
        /// The collection is created through iterating on the IdataReader object which contains Employee information, as a set of records, similar to tabular format.
        /// </summary>
        /// <param name="returnData">Contains the data retrieved from database.</param>
        /// <returns>A collection of Employee custom entity.</returns>
        protected static CollectionBase GenerateEmployeeCollectionFromReader(IDataReader returnData)
        {
            //creating the instance of Employee collection
            CustomCollection<Employee> colEmployee = new CustomCollection<Employee>();

            /************************* Architecture note:**********************************
             * Below code includes the null value functionality to retrieve the data which has nill value in database end.
             * Design consideration:
             * Besides general data fields, special care should be taken for primary keys, to assign '0'/default value, rather passing 'Null' value in constructor parameter.
             * Although we are considering sqldb type data for the current data container, but while retrieving data from database end, through datareader object, we need to cast data reader objects using .net primitive data type,
             * rather using sqldb type to cast, since data reader objects don't support sql db type to be casted.
             *****************************************************************************/

            //Iterating through the data reader, to generate Employee collection.
            //each iteration cause to create a separate instance of Employee and be added to the Employee collection.
            while (returnData.Read())
            {
                //passing the Employee constructor parameters from the current instance of data reader fields.
                Employee newEmployee = new Employee
                    (
                        returnData["EmployeeId"] == System.DBNull.Value ? SelectEmployeeIdMinValue : (int)returnData["EmployeeId"],
                        returnData["LastName"] == System.DBNull.Value ? null : (string)returnData["LastName"],
                        returnData["FirstName"] == System.DBNull.Value ? null : (string)returnData["FirstName"],
                        returnData["Title"] == System.DBNull.Value ? null : (string)returnData["Title"],
                        returnData["TitleOfCourtesy"] == System.DBNull.Value ? null : (string)returnData["TitleOfCourtesy"],
                        returnData["BirthDate"] == System.DBNull.Value ? (DateTime?)null : (DateTime)returnData["BirthDate"],
                        returnData["HireDate"] == System.DBNull.Value ? DateTime.MinValue : (DateTime)returnData["HireDate"],
                        returnData["Address"] == System.DBNull.Value ? null : (string)returnData["Address"],
                        returnData["City"] == System.DBNull.Value ? null : (string)returnData["City"],
                        returnData["Region"] == System.DBNull.Value ? null : (string)returnData["Region"],
                        returnData["PostalCode"] == System.DBNull.Value ? null : (string)returnData["PostalCode"],
                        returnData["Country"] == System.DBNull.Value ? null : (string)returnData["Country"],
                        returnData["HomePhone"] == System.DBNull.Value ? null : (string)returnData["HomePhone"],
                        returnData["Extension"] == System.DBNull.Value ? null : (string)returnData["Extension"],
                        returnData["Photo"] == System.DBNull.Value ? null : (byte[])returnData["Photo"],
                        returnData["Notes"] == System.DBNull.Value ? null : (string)returnData["Notes"],
                        returnData["ReportsTo"] == System.DBNull.Value ? (int?)null : (int)returnData["ReportsTo"],
                        returnData["PhotoPath"] == System.DBNull.Value ? null : (string)returnData["PhotoPath"]

                    );

                //adding the Employee to the collection
                colEmployee.Add(newEmployee);
            }

            //returns the collection of Employee objects
            return (colEmployee);
        }
 public void SetUp()
 {
     _customCollection = new CustomCollection <MockCustomItem>();
     _customCollection.Add(new MockCustomItem());
     _customCollection.Add(new MockCustomItem());
 }