public static MenuItemDataProperty CreateMenuItem(IProperty p, LimnorContextMenuCollection menus)
        {
            PropertyPointer pp = p as PropertyPointer;

            if (pp != null)
            {
                return(new PropertyItem(p.Name, menus.Owner, pp.Info));
            }
            else
            {
                PropertyClass pc = p as PropertyClass;
                if (pc != null)
                {
                    return(new PropertyItemClassPointer(p.Name, menus.Owner, pc));
                }
                else
                {
                    IPropertyWrapper w = p as IPropertyWrapper;
                    if (w != null)
                    {
                    }
                }
            }
            throw new DesignerException("Unsupported property type {0} for CreateMenuItem", p.GetType());
        }
예제 #2
0
        public override void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
        {
            base.OnReadFromXmlNode(serializer, node);
            PropertyId      = XmlUtil.GetAttributeUInt(node, XMLATTR_PropertyId);
            PropertyClassId = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_ClassID);
            XmlObjectReader reader = (XmlObjectReader)serializer;

            if (PropertyClassId == 0)
            {
                PropertyClassId = reader.ObjectList.ClassId;
            }
            ClassPointer root = ClassPointer.CreateClassPointer(PropertyClassId, reader.ObjectList.Project);

            PropertyClass mc = root.GetCustomPropertyById(PropertyId);

            if (mc == null)
            {
                MathNode.LogError(string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                "Property {0} not found in class {1}", PropertyId, root.ClassId));
            }
            else
            {
                _property = mc;
            }
        }
예제 #3
0
        public void TrySetProperty_WhenValueTypeDoesNotMatchProperty_ThrowsInvalidOperationException()
        {
            var testClass = new PropertyClass();
            var exception = Assert.Catch <InvalidOperationException>(() => testClass.TrySetProperty(nameof(PropertyClass.Writable), 0));

            Assert.AreEqual("Property type is not assignable from the Value type.", exception.Message);
        }
예제 #4
0
        public void SetProperty_WhenTypeObjectIsNull_ReturnsTypeObjectUnchanged()
        {
            PropertyClass testClass = null;
            var           result    = testClass.SetProperty(a => a.Writable, It.IsAny <string>());

            Assert.AreEqual(testClass, result);
        }
예제 #5
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                accountProperty = accountMgr.CheckNameAndPasswd(textBox1.Text.Trim(), maskedTextBox1.Text.Trim());
                Logger.Info(accountProperty.UserId + "," + accountProperty.Job + " logged in");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not connect to the server.Please contact the admin");
                Logger.Error(ex.StackTrace);
                return;
            }

            if (accountProperty == null)
            {
                MessageBox.Show("Invalid Name or Password");
            }
            else
            {
                UserInfo.UserId   = accountProperty.UserId;
                UserInfo.UserName = accountProperty.AccountName;
                UserInfo.Job      = (JobDescription)accountProperty.Job;

                MainFrame mainFrame = new MainFrame();
                this.Hide();
                mainFrame.WindowState = FormWindowState.Maximized;
                mainFrame.Show();
            }
        }
예제 #6
0
        public void OnSetDefinition()
        {
            if (_definingClass == null)
            {
                throw new DesignerException("Defining class not loaded for accessing properties for class {0}", _definingClassId);
            }
            _classVersion = _definingClass.EditVersion;
            XmlNode classXmlNode = _definingClass.XmlData;

            _typeName   = XmlUtil.GetNameAttribute(classXmlNode);
            _properties = new List <PropertyClassDescriptor>();
            Dictionary <string, PropertyClass> ps = _definingClass.CustomProperties;

            foreach (PropertyClass p in ps.Values)
            {
                if (p.Implemented && p.AccessControl == EnumAccessControl.Public)
                {
                    PropertyClass p0 = (PropertyClass)p.Clone();
                    p0.SetHolder(this);
                    _properties.Add(new PropertyClassDescriptor(p0));
                }
            }
            if (string.IsNullOrEmpty(_iconFilename))
            {
                _iconFilename = SerializeUtil.ReadIconFilename(classXmlNode);
            }
        }
예제 #7
0
 private void setScope(SetterClass setter)
 {
     _prop = setter.Property;
     SetDataType(_prop.PropertyType);
     Method = setter;
     init();
 }
예제 #8
0
            public static PropertyField Property(this PanelCreator self, PropertyClass target, Rcon.Property property)
            {
                var control = self.panel.AddChild <PropertyField>();

                control.SetTarget(target, property);
                return(control);
            }
예제 #9
0
        public void TrySetProperty_WhenClassObjectIsNull_ReturnsUnchangedObject()
        {
            PropertyClass testClass = null;
            var           result    = testClass.TrySetProperty(nameof(PropertyClass.Writable), It.IsAny <string>());

            Assert.AreEqual(testClass, result);
        }
예제 #10
0
        public void TrySetProperty_WhenClassDoesNotHaveProperty_ReturnsUnchangedObject()
        {
            var testClass = new PropertyClass();
            var result    = testClass.TrySetProperty("Random", It.IsAny <string>());

            Assert.AreEqual(testClass, result);
        }
예제 #11
0
        public void SetProperty_WhenTryingToSetAReadonlyProperty_ThrowsInvalidOperationException()
        {
            var testClass = new PropertyClass();
            var exception = Assert.Catch <InvalidOperationException>(() => testClass.SetProperty(a => a.Readonly, It.IsAny <string>()));

            Assert.AreEqual("Cannot set a restricted property.", exception.Message);
        }
        public void WorkOrderResponseMaps()
        {
            var workOrder = new Helpers.StubGeneration.Generator <WorkOrder>()
                            .AddDefaultGenerators()
                            .Generate();

            AppointmentDetails appointment = new AppointmentDetails
            {
                Date        = DateTime.UtcNow,
                Description = "test",
                End         = DateTime.UtcNow,
                Start       = DateTime.UtcNow
            };
            var response = workOrder.ToResponse(appointment, new Uri("https://managementAddress.none"), canAssignOperative: false);

            PropertyClass propertyClass = workOrder.Site?.PropertyClass.FirstOrDefault();
            string        addressLine   = propertyClass?.Address?.AddressLine;

            response.CallerNumber.Should().Be(workOrder.Customer.Person.Communication.Where(cc => cc.Channel.Medium == RepairsApi.V2.Generated.CommunicationMediumCode._20).FirstOrDefault()?.Value);
            response.CallerName.Should().Be(workOrder.Customer.Person.Name.Full);
            response.DateRaised.Should().Be(workOrder.DateRaised);
            response.Description.Should().Be(workOrder.DescriptionOfWork);
            response.Owner.Should().Be(workOrder.AssignedToPrimary.Name);
            response.Priority.Should().Be(workOrder.WorkPriority.PriorityDescription);
            response.PriorityCode.Should().Be(workOrder.WorkPriority.PriorityCode);
            response.Property.Should().Be(addressLine);
            response.PropertyReference.Should().Be(workOrder.Site?.PropertyClass.FirstOrDefault()?.PropertyReference);
            response.Reference.Should().Be(workOrder.Id);
            response.Target.Should().Be(workOrder.WorkPriority.RequiredCompletionDateTime);
            response.Property.Should().Be(addressLine);
            response.ExternalAppointmentManagementUrl.ToString().Should().Contain(workOrder.ExternalSchedulerReference);
            response.CanAssignOperative.Should().BeFalse();
            response.PlannerComments.Should().Be(workOrder.PlannerComments);
        }
예제 #13
0
        public void SetProperty_WhenPassingThroughAValueOfDifferentType_ThrowsInvalidOperationException()
        {
            var testClass = new PropertyClass();
            var exception = Assert.Catch <InvalidOperationException>(() => testClass.SetProperty(a => a.Writable, 3));

            Assert.AreEqual("Value type does not match the Property type.", exception.Message);
        }
예제 #14
0
 protected override void OnSetImage()
 {
     if (_property == null && Designer != null)
     {
         ClassPointer root = Designer.GetRootId();
         _property = root.GetCustomPropertyById(PropertyId);
     }
     if (_property != null)
     {
         if (_property.RunAt == EnumWebRunAt.Client)
         {
             SetIconImage(Resources._custPropClient.ToBitmap());
         }
         else if (_property.RunAt == EnumWebRunAt.Server)
         {
             SetIconImage(Resources._custPropServer.ToBitmap());
         }
         else
         {
             SetIconImage(Resources._custProp.ToBitmap());
         }
     }
     else
     {
         SetIconImage(Resources._custProp.ToBitmap());
     }
 }
예제 #15
0
    private void ReadPropertyFile()
    {
        //Method which is used to read tyhe property file.
        string fileContent = System.IO.File.ReadAllText(PROPERTY_FILE_PATH);                                                    // Reads the content of the file.

        if (!fileContent.Contains(","))                                                                                         // Checks if the file contains a period ",". If not, then leaves the method.
        {
            return;
        }
        string[] values = fileContent.Split(',');                                                                               // If it does have one, than the file contains data. Split on the periods "," creating a string array.

        foreach (PropertyClass property in list)                                                                                // Check for same name property.
        {
            if (values[0].Equals(property.name))
            {
                return;
            }
        }
        PropertyClass newProperty = new PropertyClass();                                                                        // Create a new Property class and set the values to the contents of the file.

        newProperty.name        = values[0];
        newProperty.type        = System.Convert.ToInt32(values[1]);
        newProperty.value       = SetValue(newProperty.type);
        newProperty.description = values[2];
        if (values.Length > 3)
        {
            newProperty.type    += 5;
            newProperty.minValue = System.Convert.ToInt32(values[3]);
            newProperty.maxValue = System.Convert.ToInt32(values[4]);
        }
        list.Add(newProperty);                                                                                                  // Add the new property to the list.
        File.Create(PROPERTY_FILE_PATH);                                                                                        // Used to overwrite the property file so the data is not copied twice.
    }
예제 #16
0
        public void SetProperty_WhenSettingPropertyWithNonPublicAccessModifiers_ChangesPropertyValue()
        {
            var value     = "test";
            var testClass = new PropertyClass();

            testClass.SetProperty(a => a.PrivateWritable, value);
            Assert.AreEqual(value, testClass.PrivateWritable);
        }
예제 #17
0
        public void SetProperty_ChangesPropertyValue()
        {
            var value     = "test";
            var testClass = new PropertyClass();

            testClass.SetProperty(a => a.Writable, value);
            Assert.AreEqual(value, testClass.Writable);
        }
예제 #18
0
        public void TrySetProperty_ChangesPropertyValue()
        {
            var value     = "test";
            var testClass = new PropertyClass();

            testClass.TrySetProperty(nameof(PropertyClass.Writable), value);
            Assert.AreEqual(value, testClass.Writable);
        }
예제 #19
0
        public void Property()
        {
            var o = new PropertyClass();

            o.Property = "bar";
            var value = o.Property;

            value.ShouldBe("barfoo");
        }
예제 #20
0
        private void LoadMsiDBProperty()
        {
            PropertyClass myProp = new PropertyClass();

            CustomProperty myproperty = new CustomProperty("Installation Guid", misPackage.GetMsiProperty("ProductCode"), true, true);

            myProp.Add(myproperty);
            propertyGrid1.SelectedObject = myProp;
            //LoadListView("Installation Guid", misPackage.GetMsiProperty("ProductCode"));
        }
예제 #21
0
        public void SetProperty_WhenPassingNullAsValueForNonNullableProperty_SetPropertyToDefaultValue()
        {
            var testClass = new PropertyClass()
            {
                NonNullableInt = 1
            };

            testClass.SetProperty(a => a.NonNullableInt, null);
            Assert.AreEqual(default(int), testClass.NonNullableInt);
        }
예제 #22
0
    public static void Main()
    {
        int           n;
        PropertyClass obj = new PropertyClass();

        obj.PrivateValue = 100; // invoke set-accessor
        obj.PrintValue();
        n = obj.PrivateValue;   // invoke get-accessor
        Console.WriteLine(" Value = " + n);
    }
예제 #23
0
    public void TestDumpClassPropertyClass()
    {
        var testClass = new PropertyClass()
        {
            x = 5, y = 7
        };

        Console.WriteLine(JSON.Dump(testClass, EncodeOptions.NoTypeHints));
        Assert.AreEqual("{\"y\":7,\"p1\":1,\"p2\":2,\"p3\":3,\"p4\":4,\"p5\":5,\"p6\":6}", JSON.Dump(testClass, EncodeOptions.NoTypeHints));
    }
예제 #24
0
        public void GetPropertyTest()
        {
            PropertyClass propertyClass = new PropertyClass();

            PropertyInfo actual = PropertyFinder <PropertyClass> .Find(x => x.GetMe);

            PropertyInfo expected = propertyClass.GetType().GetProperty("GetMe");

            Assert.AreEqual(expected, actual);
        }
예제 #25
0
        public override bool IsForThePointer(IObjectPointer pointer)
        {
            PropertyClass ic = pointer as PropertyClass;

            if (ic != null)
            {
                return(ic.MemberId == this.PropertyId);
            }
            return(false);
        }
예제 #26
0
        public void GetInterfaceProperty()
        {
            var property = typeof(IPropertyClass).GetProperty("StringProperty");
            var instance = new PropertyClass();

            instance.StringProperty = "StringProperty";
            var result = (string)property.GetValue(instance, null);

            AssertEquals(result, "StringProperty");
        }
예제 #27
0
 public void SetProperty_ClassString_Blank()
 {
     var obj = new PropertyClass();
     var stopwatch = Stopwatch.StartNew();
     for (var i = 0; i < Iterations; i++)
     {
         obj.StringProperty = "";
     }
     stopwatch.StopAndLog(Iterations);
 }
예제 #28
0
 public PropertyItemClassPointer(string key, IClass owner, PropertyClass property)
     : base(key, owner)
 {
     _property = (PropertyClass)property.Clone();
     _property.SetHolder(owner);
     _pointer = owner.VariableCustomType;
     if (_pointer == null)
     {
         throw new DesignerException("null VariableCustomType creating PropertyItemClassPointer");
     }
 }
예제 #29
0
        public void GetProperty_ClassString_Blank()
        {
            var obj       = new PropertyClass();
            var stopwatch = Stopwatch.StartNew();

            for (var i = 0; i < Iterations; i++)
            {
                var prop = obj.StringProperty;
            }
            stopwatch.StopAndLog(Iterations);
        }
예제 #30
0
        private void LoadResourceProperties(string resource)
        {
            PropertyClass myProp = new PropertyClass();

            foreach (var item in misPackage.GetResourceProperties(resource))
            {
                CustomProperty myproperty = new CustomProperty(item.Key, item.Value, true, true);
                myProp.Add(myproperty);
            }
            propertyGrid1.SelectedObject = myProp;
        }
예제 #31
0
        private void btnOkClick(object sender, EventArgs e)
        {
            if (pc == null)
            {
                pc = new PropertyClass();
            }

            pc.PcCode = tbPCCode.Text;
            pc.PcName = tbPCName.Text;
            this.Tag  = true;
            this.Close();
        }