Example #1
0
 /// <summary>
 /// Gets or sets property Value using Name as key for data Properties array values.
 /// </summary>
 /// <remarks>If property with the specified key does not exist it is created.</remarks>
 /// <param name="name">The property name value.</param>
 /// <returns>The property value.</returns>
 public string this[string name]
 {
     get
     {
         var result = _data.Properties.FirstOrDefault(p => p.Name == name);
         if (result != null)
         {
             return(result.Value);
         }
         return(null);
     }
     set
     {
         if (value != null)
         {
             var result = _data.Properties.FirstOrDefault(p => p.Name == name);
             if (result != null)
             {
                 result.Value = value;
             }
             else
             {
                 var property = XProperty.Create(_data, name, value);
                 _data.Properties = _data.Properties.Add(property);
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// Clone current instance of the <see cref="XPoint"/>.
        /// </summary>
        /// <returns>The new instance of the <see cref="XPoint"/> class.</returns>
        public XPoint Clone()
        {
            var data = XContext.Create(this.Data.Record);

            // The property Value is of type object and is not cloned.
            if (this.Data.Properties.Length > 0)
            {
                var builder = data.Properties.ToBuilder();
                foreach (var property in this.Data.Properties)
                {
                    builder.Add(
                        XProperty.Create(
                            data,
                            property.Name,
                            property.Value));
                }
                data.Properties = builder.ToImmutable();
            }

            return(new XPoint()
            {
                Name = this.Name,
                Style = this.Style,
                Data = data,
                X = this.X,
                Y = this.Y,
                Alignment = this.Alignment,
                Shape = this.Shape
            });
        }
Example #3
0
        public Output()
        {
            base.Database = new List <KeyValuePair <string, IProperty> >();
            base.Shapes   = new List <IShape>();
            base.Pins     = new List <XPin>();

            base.Name = "OUTPUT";

            IProperty labelProperty = new XProperty("OUT");

            base.Database.Add(new KeyValuePair <string, IProperty>("Label", labelProperty));

            base.Shapes.Add(
                new XText()
            {
                X          = 0,
                Y          = 0,
                Width      = 30,
                Height     = 30,
                HAlignment = HAlignment.Center,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 14,
                Text       = "{0}",
                Properties = new[] { labelProperty }
            });
            base.Shapes.Add(new XRectangle()
            {
                X = 0, Y = 0, Width = 30, Height = 30, IsFilled = false
            });
            base.Pins.Add(new XPin()
            {
                Name = "I", X = 0, Y = 15, PinType = PinType.Input, Owner = null
            });
        }
Example #4
0
            public override void SetValue(object component, object value)
            {
                var element = value as XElement;

                if (element == null)
                {
                    throw new ArgumentException("Incompatible types found in workflow property assignment.", "value");
                }

                var xmlProperties = GetXmlProperties(component);

                if (element.NodeType == XmlNodeType.Text)
                {
                    element = new XProperty(xmlProperties[propertyIndex].Name, element.Value);
                }
                else if (element.Name != xmlProperties[propertyIndex].Name)
                {
                    element = new XElement(
                        xmlProperties[propertyIndex].Name,
                        element.Attributes(),
                        element.Elements(),
                        element.Value);
                }

                xmlProperties[propertyIndex] = element;
            }
Example #5
0
 public void Save(XProperty property, Guid userId)
 {
     //ESystemActionType actionType = (property.IsNew) ? ESystemActionType.Create : ESystemActionType.Update;
     //RulesEngine.Validate(property, actionType, userId);
     this.Validate(property);
     this.bizLayer.Save(property, userId);
 }
Example #6
0
        public void this_Operator_Returns_Property_Value()
        {
            var target = new XContainer();

            target.Data.Properties = target.Data.Properties.Add(XProperty.Create(target.Data, "Name1", "Value1"));

            Assert.Equal("Value1", target["Name1"]);
        }
Example #7
0
        private void Remove(XProperty property)
        {
            if (property == null)
            {
                return;
            }

            property.PropertyChanged -= ObserveProperty;
        }
Example #8
0
        private void Add(XProperty property)
        {
            if (property == null)
            {
                return;
            }

            property.PropertyChanged += ObserveProperty;
        }
Example #9
0
        public void this_Operator_Sets_Property_Value()
        {
            var target = new XContext();

            target.Properties = target.Properties.Add(XProperty.Create(target, "Name1", "Value1"));

            target["Name1"] = "NewValue1";
            Assert.Equal("NewValue1", target["Name1"]);
        }
Example #10
0
 /// <summary>
 /// Add property.
 /// </summary>
 /// <param name="project">The project instance.</param>
 /// <param name="data">The data instance.</param>
 /// <param name="property">The property instance.</param>
 public static void AddProperty(this XProject project, XContext data, XProperty property)
 {
     if (data?.Properties != null && property != null)
     {
         var previous = data.Properties;
         var next     = data.Properties.Add(property);
         project?.History?.Snapshot(previous, next, (p) => data.Properties = p);
         data.Properties = next;
     }
 }
Example #11
0
        /// <summary>
        /// Remove property.
        /// </summary>
        /// <param name="project">The project instance.</param>
        /// <param name="property">The property instance.</param>
        public static void RemoveProperty(this XProject project, XProperty property)
        {
            var data = property?.Owner;

            if (data != null && data.Properties != null)
            {
                var previous = data.Properties;
                var next     = data.Properties.Remove(property);
                project?.History?.Snapshot(previous, next, (p) => data.Properties = p);
                data.Properties = next;
            }
        }
Example #12
0
        static VirtualConnectionPoint()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(VirtualConnectionPoint),
                                                     new FrameworkPropertyMetadata(typeof(VirtualConnectionPoint)));

            XProperty.OverrideMetadata(typeof(VirtualConnectionPoint),
                                       new PropertyMetadata(
                                           (o, a) => Canvas.SetLeft((UIElement)o, ((double)a.NewValue) - Constants.VirtualPointXOffset)));
            YProperty.OverrideMetadata(typeof(VirtualConnectionPoint),
                                       new PropertyMetadata(
                                           (o, a) => Canvas.SetTop((UIElement)o, ((double)a.NewValue) - Constants.VirtualPointYOffset)));
        }
Example #13
0
        public Or()
        {
            base.Database = new List <KeyValuePair <string, IProperty> >();
            base.Shapes   = new List <IShape>();
            base.Pins     = new List <XPin>();

            base.Name = "OR";

            IProperty prefixProperty = new XProperty("≥");

            base.Database.Add(new KeyValuePair <string, IProperty>("Prefix", prefixProperty));

            IProperty counterProperty = new XProperty("1");

            base.Database.Add(new KeyValuePair <string, IProperty>("Counter", counterProperty));

            base.Shapes.Add(
                new XText()
            {
                X          = 0.0,
                Y          = 0.0,
                Width      = 30.0,
                Height     = 30.0,
                HAlignment = HAlignment.Center,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 14.0,
                Text       = "{0}{1}",
                Properties = new[] { prefixProperty, counterProperty }
            });
            base.Shapes.Add(new XRectangle()
            {
                X = 0.0, Y = 0.0, Width = 30.0, Height = 30.0, IsFilled = false
            });
            base.Pins.Add(new XPin()
            {
                Name = "L", X = 0.0, Y = 15.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "R", X = 30.0, Y = 15.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "T", X = 15.0, Y = 0.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "B", X = 15.0, Y = 30.0, PinType = PinType.None, Owner = null
            });
        }
Example #14
0
        private void Validate(XProperty property)
        {
            if (property.Id == Guid.Empty)
            {
                throw new LogicalException("Id cannot be null", "Id");
            }

            if (property.DataType == EDataType.Undefined)
            {
                throw new LogicalException("DataType must be defined", "DataType");
            }

            if ((property.DataType == EDataType.Asset) && (!property.AssetTypeId.HasValue))
            {
                throw new LogicalException("DataType is Asset, but the Asset Type was not specified", "AssetTypeId");
            }

            if ((property.AssetTypeId.HasValue) && (!property.AssetTypeIsInstance.HasValue))
            {
                string msg = "Must know whether the property is dealing with Asset Instances or Asset Definitions.  AssetTypeIsInstance not specified.";
                throw new LogicalException(msg, "AssetTypeIsInstance");
            }

            if (string.IsNullOrEmpty(property.Name))
            {
                throw new LogicalException("Property name must be defined", "Name");
            }

            if (string.IsNullOrEmpty(property.Description))
            {
                throw new LogicalException("Description must be defined", "Description");
            }

            if (property.CreatedBy == Guid.Empty)
            {
                throw new LogicalException("'Created By' cannot be null", "CreatedBy");
            }

            //if (XUserManager.Instance.ValidId(property.CreatedBy) == false)
            //{
            //    throw new LogicalException("Invalid user id", "CreatedBy");
            //}

            //if (property.IsSystem && property.Deleted.HasValue)
            //{
            //    throw new LogicalException("System properties cannot be deleted");
            //}

            //if ((property.IsDirty) && (property.LastModifiedBy == new Guid())) { throw new LogicalException("'Last Modified By' cannot be null", "LastModifiedBy"); }
        }
        bool generateProperty(XProperty xprop, XClass xclass, StringBuilder sbOut, Chilkat.Log log)
        {
            // All properties have getters..
            // Types can be emitted using an existing conversion, or you could write your own..
            sbOut.Append("\t" + ChilkatTypes.genericToAxPrimitive(xprop.m_gt) + " get_" + xprop.EntryName + "() { ... }\r\n");

            // If the property is not read-only, generate the setter.
            if (!xprop.ReadOnly)
            {
                sbOut.Append("\tset_" + xprop.EntryName + "(" +
                             ChilkatTypes.genericToAxPrimitive(xprop.m_gt) + " newval) { ... }\r\n");
            }

            return(true);
        }
Example #16
0
        public Shortcut()
        {
            base.Database = new List <KeyValuePair <string, IProperty> >();
            base.Shapes   = new List <IShape>();
            base.Pins     = new List <XPin>();

            base.Name = "SHORTCUT";

            IProperty labelProperty = new XProperty("A");

            base.Database.Add(new KeyValuePair <string, IProperty>("Label", labelProperty));

            base.Shapes.Add(
                new XText()
            {
                X          = 0.0,
                Y          = 0.0,
                Width      = 30.0,
                Height     = 30.0,
                HAlignment = HAlignment.Center,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 14.0,
                Text       = "{0}",
                Properties = new[] { labelProperty }
            });
            base.Shapes.Add(new XEllipse()
            {
                X = 15.0, Y = 15.0, RadiusX = 15.0, RadiusY = 15.0
            });
            base.Pins.Add(new XPin()
            {
                Name = "L", X = 0.0, Y = 15.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "R", X = 30.0, Y = 15.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "T", X = 15.0, Y = 0.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "B", X = 15.0, Y = 30.0, PinType = PinType.None, Owner = null
            });
        }
Example #17
0
        public And()
        {
            base.Database = new List <KeyValuePair <string, IProperty> >();
            base.Shapes   = new List <IShape>();
            base.Pins     = new List <XPin>();

            base.Name = "AND";

            IProperty labelProperty = new XProperty("&");

            base.Database.Add(new KeyValuePair <string, IProperty>("Label", labelProperty));

            base.Shapes.Add(
                new XText()
            {
                X          = 0.0,
                Y          = 0.0,
                Width      = 30.0,
                Height     = 30.0,
                HAlignment = HAlignment.Center,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 14.0,
                Text       = "{0}",
                Properties = new[] { labelProperty }
            });
            base.Shapes.Add(new XRectangle()
            {
                X = 0.0, Y = 0.0, Width = 30.0, Height = 30.0, IsFilled = false
            });
            base.Pins.Add(new XPin()
            {
                Name = "L", X = 0.0, Y = 15.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "R", X = 30.0, Y = 15.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "T", X = 15.0, Y = 0.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "B", X = 15.0, Y = 30.0, PinType = PinType.None, Owner = null
            });
        }
Example #18
0
        internal static void LoadProperties()
        {
            XProperties = typeof(GuildConfig).GetProperties()
                          .Where(x => x.GetCustomAttributes(typeof(XProperty)).Count() == 1)
                          .ToDictionary(x => x.Name, StringComparer.OrdinalIgnoreCase);

            XPropertiesHelp  = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            XPropertiesUsage = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (PropertyInfo prop in XProperties.Values)
            {
                XProperty attribute = (XProperty)prop.GetCustomAttribute(typeof(XProperty));

                XPropertiesHelp.Add(prop.Name, attribute.Help);
                XPropertiesUsage.Add(prop.Name, attribute.Usage);
            }
        }
Example #19
0
        private bool CheckPropertyPermission(PropertyInfo propertyInfo, SocketGuildUser user)
        {
            XProperty attr = (XProperty)propertyInfo.GetCustomAttribute(typeof(XProperty));

            // If property does not require admin rights
            if (!attr.AdminOnly)
            {
                return(true);
            }

            // If property called is AdminRoleId and that admin role is not set
            else if (propertyInfo.Name == "AdminRoleId" &&
                     Context.Guild.Roles.Where(x => x.Id == Config._INSTANCE.GuildConfigs[Context.Guild.Id].AdminRoleId).Count() == 0)
            {
                return(true);
            }

            // Si propriété est admin only et que l'utilisateur a au moins 1 role de position supérieure ou égale à celle du role Admin spécifié
            else if (attr.AdminOnly)
            {
                if (Context.Guild.Roles.Where(x => x.Id == Config._INSTANCE.GuildConfigs[Context.Guild.Id].AdminRoleId).Count() == 0)
                {
                    return(false);
                }
                else if (user.Roles.Where(x => x.Position >= Context.Guild.Roles
                                          .FirstOrDefault(y => y.Id == Config._INSTANCE.GuildConfigs[Context.Guild.Id].AdminRoleId).Position).Count() > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            // All other cases
            else
            {
                return(false);
            }
        }
Example #20
0
        public Signal()
        {
            base.Database = new List <KeyValuePair <string, IProperty> >();
            base.Shapes   = new List <IShape>();
            base.Pins     = new List <XPin>();

            base.Name = "SIGNAL";

            IProperty designationProperty = new XProperty("Designation");

            base.Database.Add(new KeyValuePair <string, IProperty>("Designation", designationProperty));

            IProperty descriptionProperty = new XProperty("Description");

            base.Database.Add(new KeyValuePair <string, IProperty>("Description", descriptionProperty));

            IProperty signalProperty = new XProperty("Signal");

            base.Database.Add(new KeyValuePair <string, IProperty>("Signal", signalProperty));

            IProperty conditionProperty = new XProperty("Condition");

            base.Database.Add(new KeyValuePair <string, IProperty>("Condition", conditionProperty));

            base.Shapes.Add(
                new XText()
            {
                X          = 5.0,
                Y          = 0.0,
                Width      = 200.0,
                Height     = 15.0,
                HAlignment = HAlignment.Left,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 11.0,
                Text       = "{0}",
                Properties = new[] { designationProperty }
            });
            base.Shapes.Add(
                new XText()
            {
                X          = 5.0,
                Y          = 15.0,
                Width      = 200.0,
                Height     = 15.0,
                HAlignment = HAlignment.Left,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 11.0,
                Text       = "{0}",
                Properties = new[] { descriptionProperty }
            });
            base.Shapes.Add(
                new XText()
            {
                X          = 215.0,
                Y          = 0.0,
                Width      = 80.0,
                Height     = 15.0,
                HAlignment = HAlignment.Left,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 11.0,
                Text       = "{0}",
                Properties = new[] { signalProperty }
            });
            base.Shapes.Add(
                new XText()
            {
                X          = 215.0,
                Y          = 15.0,
                Width      = 80.0,
                Height     = 15.0,
                HAlignment = HAlignment.Left,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 11.0,
                Text       = "{0}",
                Properties = new[] { conditionProperty }
            });
            base.Shapes.Add(new XRectangle()
            {
                X = 0.0, Y = 0.0, Width = 300.0, Height = 30.0, IsFilled = false
            });
            base.Shapes.Add(new XLine()
            {
                X1 = 210.0, Y1 = 0.0, X2 = 210.0, Y2 = 30.0
            });
            base.Pins.Add(new XPin()
            {
                Name = "I", X = 0.0, Y = 15.0, PinType = PinType.Input, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "O", X = 300.0, Y = 15.0, PinType = PinType.Output, Owner = null
            });
        }
Example #21
0
        public TimerPulse()
        {
            base.Database = new List <KeyValuePair <string, IProperty> >();
            base.Shapes   = new List <IShape>();
            base.Pins     = new List <XPin>();

            base.Name = "TIMER-PULSE";

            IProperty prefixProperty = new XProperty("T=");

            base.Database.Add(new KeyValuePair <string, IProperty>("Prefix", prefixProperty));

            IProperty delayProperty = new XProperty("1");

            base.Database.Add(new KeyValuePair <string, IProperty>("Delay", delayProperty));

            IProperty unitProperty = new XProperty("s");

            base.Database.Add(new KeyValuePair <string, IProperty>("Unit", unitProperty));

            base.Shapes.Add(
                new XText()
            {
                X          = -15.0,
                Y          = -15.0,
                Width      = 60.0,
                Height     = 15.0,
                HAlignment = HAlignment.Center,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 11.0,
                Text       = "{0}{1}{2}",
                Properties = new[] { prefixProperty, delayProperty, unitProperty }
            });
            base.Shapes.Add(new XRectangle()
            {
                X = 0.0, Y = 0.0, Width = 30.0, Height = 30.0, IsFilled = false
            });
            base.Shapes.Add(new XLine()
            {
                X1 = 7.0, Y1 = 19.0, X2 = 11.0, Y2 = 19.0
            });
            base.Shapes.Add(new XLine()
            {
                X1 = 19.0, Y1 = 19.0, X2 = 23.0, Y2 = 19.0
            });
            base.Shapes.Add(new XLine()
            {
                X1 = 11.0, Y1 = 11.0, X2 = 19.0, Y2 = 11.0
            });
            base.Shapes.Add(new XLine()
            {
                X1 = 11.0, Y1 = 11.0, X2 = 11.0, Y2 = 19.0
            });
            base.Shapes.Add(new XLine()
            {
                X1 = 19.0, Y1 = 11.0, X2 = 19.0, Y2 = 19.0
            });
            base.Pins.Add(new XPin()
            {
                Name = "L", X = 0.0, Y = 15.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "R", X = 30.0, Y = 15.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "T", X = 15.0, Y = 0.0, PinType = PinType.None, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "B", X = 15.0, Y = 30.0, PinType = PinType.None, Owner = null
            });
        }
        bool generateClassToSb(XClass xclass, StringBuilder sbOut, Chilkat.Log log)
        {
            // We're just going to generate some pseudo-code...
            sbOut.Append("class " + xclass.GenericName + " {\r\n\r\n");

            // We could generate constructors, destructors, creation functions, etc. here...

            // Loop over properties and generate each..
            int i;

            for (i = 0; i < xclass.NumProperties; i++)
            {
                XProperty xprop = xclass.GetProperty(i);

                // Skip some properties we may not want..
                // (What you do here depends on your needs..)
                if (xprop.Deprecated)
                {
                    continue;
                }
                if (!xprop.AxEnabled)
                {
                    continue;                       // We don't want properties that do not exist in the ActiveX..
                }
                if (xprop.IsBytes)
                {
                    continue;                 // maybe we don't want to deal with the few properties that are binary data.
                }
                if (xprop.IsEventRelated())
                {
                    continue;
                }
                // ...

                if (!generateProperty(xprop, xclass, sbOut, log))
                {
                    return(false);
                }
            }

            // Loop over methods and generate each...
            for (i = 0; i < xclass.NumMethods; i++)
            {
                XMethod xmethod = xclass.GetMethod(i);

                // Skip some properties we may not want..
                // (What you do here depends on your needs..)
                if (xmethod.Deprecated)
                {
                    continue;
                }
                if (!xmethod.AxEnabled)
                {
                    continue;                         // We don't want properties that do not exist in the ActiveX..
                }
                if (xmethod.IsBytes || xmethod.HasArgWithGt(ChilkatTypes.GT_BYTES))
                {
                    continue;                                                                  // Maybe we don't want to deal with binary return values or args..
                }
                // ...

                if (!generateMethod(xmethod, xclass, sbOut, log))
                {
                    return(false);
                }
            }



            sbOut.Append("};\r\n");
            return(true);
        }
Example #23
0
 public void Inherits_From_ObservableObject()
 {
     var target = new XProperty();
     Assert.True(target is ObservableObject);
 }
Example #24
0
 get => (double)GetValue(XProperty); set => SetValue(XProperty, value);
Example #25
0
 public void Save(XProperty property, Guid userId)
 {
     this.dal.Save(property);
 }
Example #26
0
        private void Remove(XProperty property)
        {
            if (property == null)
                return;

            property.PropertyChanged -= ObserveProperty;
        }
Example #27
0
        private void Add(XProperty property)
        {
            if (property == null)
                return;

            property.PropertyChanged += ObserveProperty;
        }
Example #28
0
        public XProperty Get(Guid id)
        {
            XProperty property = null;

            List <SqlParameter> paramList = paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@Id", id));

            using (SqlDataReader rdr = base.OpenDataReader(StoredProcs.Property_Get, paramList))
            {
                if ((rdr == null) || (!rdr.HasRows))
                {
                    return(null);
                }

                int Name                = rdr.GetOrdinal("Name");
                int DisplayValue        = rdr.GetOrdinal("DisplayValue");
                int Description         = rdr.GetOrdinal("Description");
                int DataTypeId          = rdr.GetOrdinal("DataTypeId");
                int IsSystem            = rdr.GetOrdinal("IsSystem");
                int SystemTypeId        = rdr.GetOrdinal("SystemTypeId");
                int Precision           = rdr.GetOrdinal("Precision");
                int PickListId          = rdr.GetOrdinal("PickListId");
                int RoleId              = rdr.GetOrdinal("RoleId");
                int IsOrdered           = rdr.GetOrdinal("IsOrdered");
                int AllowMultiValue     = rdr.GetOrdinal("AllowMultiValue");
                int Singular            = rdr.GetOrdinal("Singular");
                int Plural              = rdr.GetOrdinal("Plural");
                int AssetTypeId         = rdr.GetOrdinal("AssetTypeId");
                int AssetTypeIsInstance = rdr.GetOrdinal("AssetTypeIsInstance");
                int Created             = rdr.GetOrdinal("Created");
                int CreatedBy           = rdr.GetOrdinal("CreatedBy");
                //int Approved = rdr.GetOrdinal("Approved");
                //int ApprovedBy = rdr.GetOrdinal("ApprovedBy");
                int LastModified   = rdr.GetOrdinal("LastModified");
                int LastModifiedBy = rdr.GetOrdinal("LastModifiedBy");
                int Deleted        = rdr.GetOrdinal("Deleted");
                int DeletedBy      = rdr.GetOrdinal("DeletedBy");

                property = new XProperty();

                rdr.Read();

                property.Id = id;

                if (!rdr.IsDBNull(Name))
                {
                    property.Name = rdr.GetString(Name);
                }

                if (!rdr.IsDBNull(DisplayValue))
                {
                    property.DisplayValue = rdr.GetString(DisplayValue);
                }

                if (!rdr.IsDBNull(Description))
                {
                    property.Description = rdr.GetString(Description);
                }

                if (!rdr.IsDBNull(DataTypeId))
                {
                    property.DataType = EnumerationOps.EDataTypeFromValue((Int16)rdr.GetByte(DataTypeId));
                }

                if (!rdr.IsDBNull(IsSystem))
                {
                    property.IsSystem = (bool)rdr[IsSystem];
                }

                if (!rdr.IsDBNull(SystemTypeId))
                {
                    property.SystemType = EnumerationOps.ESystemTypeFromValue(rdr.GetInt32(SystemTypeId));
                }

                if (!rdr.IsDBNull(Precision))
                {
                    property.Precision = (Int16)rdr[Precision];
                }

                if (!rdr.IsDBNull(PickListId))
                {
                    property.XListId = rdr.GetGuid(PickListId);
                }

                if (!rdr.IsDBNull(RoleId))
                {
                    property.RoleId = rdr.GetGuid(RoleId);
                }

                if (!rdr.IsDBNull(IsOrdered))
                {
                    property.IsOrdered = (bool)rdr[IsOrdered];
                }

                if (!rdr.IsDBNull(AllowMultiValue))
                {
                    property.AllowMultiValue = (bool)rdr[AllowMultiValue];
                }

                if (!rdr.IsDBNull(Singular))
                {
                    property.Singular = rdr.GetString(Singular);
                }

                if (!rdr.IsDBNull(Plural))
                {
                    property.Plural = rdr.GetString(Plural);
                }

                if (!rdr.IsDBNull(AssetTypeId))
                {
                    property.XObjectTypeId = rdr.GetGuid(AssetTypeId);
                }

                if (!rdr.IsDBNull(AssetTypeIsInstance))
                {
                    property.AssetTypeIsInstance = (bool)rdr[AssetTypeIsInstance];
                }

                property.Created   = rdr.GetDateTime(Created);
                property.CreatedBy = rdr.GetGuid(CreatedBy);

                if (!rdr.IsDBNull(LastModified))
                {
                    property.LastModified = rdr.GetDateTime(LastModified);
                }
                if (!rdr.IsDBNull(LastModifiedBy))
                {
                    property.LastModifiedBy = rdr.GetGuid(LastModifiedBy);
                }

                if (!rdr.IsDBNull(Deleted))
                {
                    property.Deleted = rdr.GetDateTime(Deleted);
                }
                if (!rdr.IsDBNull(DeletedBy))
                {
                    property.DeletedBy = rdr.GetGuid(DeletedBy);
                }

                property.IsNew   = false;
                property.IsDirty = false;
            }

            return(property);
        }
Example #29
0
        public IDictionary <Guid, IXProperty> GetObjectDictionary(IList <Guid> propertyIds)
        {
            string propIds = Helpers.ListOfGuidToCommaDelimString(propertyIds);

            IDictionary <Guid, IXProperty> values = new Dictionary <Guid, IXProperty>();

            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@PropertyIds", propIds));

            using (SqlDataReader rdr = base.OpenDataReader(StoredProcs.Properties_GetObjectDictionary, paramList))
            {
                if ((rdr == null) || (!rdr.HasRows))
                {
                    return(values);
                }

                int Id                  = rdr.GetOrdinal("Id");
                int Name                = rdr.GetOrdinal("Name");
                int DisplayValue        = rdr.GetOrdinal("DisplayValue");
                int Description         = rdr.GetOrdinal("Description");
                int DataTypeId          = rdr.GetOrdinal("DataTypeId");
                int IsSystem            = rdr.GetOrdinal("IsSystem");
                int SystemTypeId        = rdr.GetOrdinal("SystemTypeId");
                int Precision           = rdr.GetOrdinal("Precision");
                int PickListId          = rdr.GetOrdinal("PickListId");
                int RoleId              = rdr.GetOrdinal("RoleId");
                int IsOrdered           = rdr.GetOrdinal("IsOrdered");
                int AllowMultiValue     = rdr.GetOrdinal("AllowMultiValue");
                int Singular            = rdr.GetOrdinal("Singular");
                int Plural              = rdr.GetOrdinal("Plural");
                int AssetTypeId         = rdr.GetOrdinal("AssetTypeId");
                int AssetTypeIsInstance = rdr.GetOrdinal("AssetTypeIsInstance");
                int Created             = rdr.GetOrdinal("Created");
                int CreatedBy           = rdr.GetOrdinal("CreatedBy");
                //int Approved = rdr.GetOrdinal("Approved");
                //int ApprovedBy = rdr.GetOrdinal("ApprovedBy");
                int LastModified   = rdr.GetOrdinal("LastModified");
                int LastModifiedBy = rdr.GetOrdinal("LastModifiedBy");
                int Deleted        = rdr.GetOrdinal("Deleted");
                int DeletedBy      = rdr.GetOrdinal("DeletedBy");

                while (rdr.Read())
                {
                    XProperty property = new XProperty();

                    property.Id = rdr.GetGuid(Id);

                    if (!rdr.IsDBNull(Name))
                    {
                        property.Name = rdr.GetString(Name);
                    }

                    if (!rdr.IsDBNull(DisplayValue))
                    {
                        property.DisplayValue = rdr.GetString(DisplayValue);
                    }

                    if (!rdr.IsDBNull(Description))
                    {
                        property.Description = rdr.GetString(Description);
                    }

                    if (!rdr.IsDBNull(DataTypeId))
                    {
                        property.DataType = EnumerationOps.EDataTypeFromValue((Int16)rdr.GetByte(DataTypeId));
                    }

                    if (!rdr.IsDBNull(IsSystem))
                    {
                        property.IsSystem = (bool)rdr[IsSystem];
                    }

                    if (!rdr.IsDBNull(SystemTypeId))
                    {
                        property.SystemType = EnumerationOps.ESystemTypeFromValue(rdr.GetInt32(SystemTypeId));
                    }

                    if (!rdr.IsDBNull(Precision))
                    {
                        property.Precision = (Int16)rdr[Precision];
                    }

                    if (!rdr.IsDBNull(PickListId))
                    {
                        property.XListId = rdr.GetGuid(PickListId);
                    }

                    if (!rdr.IsDBNull(RoleId))
                    {
                        property.RoleId = rdr.GetGuid(RoleId);
                    }

                    if (!rdr.IsDBNull(IsOrdered))
                    {
                        property.IsOrdered = (bool)rdr[IsOrdered];
                    }

                    if (!rdr.IsDBNull(AllowMultiValue))
                    {
                        property.AllowMultiValue = (bool)rdr[AllowMultiValue];
                    }

                    if (!rdr.IsDBNull(Singular))
                    {
                        property.Singular = rdr.GetString(Singular);
                    }

                    if (!rdr.IsDBNull(Plural))
                    {
                        property.Plural = rdr.GetString(Plural);
                    }

                    if (!rdr.IsDBNull(AssetTypeId))
                    {
                        property.XObjectTypeId = rdr.GetGuid(AssetTypeId);
                    }

                    if (!rdr.IsDBNull(AssetTypeIsInstance))
                    {
                        property.AssetTypeIsInstance = (bool)rdr[AssetTypeIsInstance];
                    }

                    property.Created   = rdr.GetDateTime(Created);
                    property.CreatedBy = rdr.GetGuid(CreatedBy);

                    if (!rdr.IsDBNull(LastModified))
                    {
                        property.LastModified = rdr.GetDateTime(LastModified);
                    }
                    if (!rdr.IsDBNull(LastModifiedBy))
                    {
                        property.LastModifiedBy = rdr.GetGuid(LastModifiedBy);
                    }

                    if (!rdr.IsDBNull(Deleted))
                    {
                        property.Deleted = rdr.GetDateTime(Deleted);
                    }
                    if (!rdr.IsDBNull(DeletedBy))
                    {
                        property.DeletedBy = rdr.GetGuid(DeletedBy);
                    }

                    property.IsNew   = false;
                    property.IsDirty = false;

                    values.Add(property.Id, property);
                }
            }

            return(values);
        }
Example #30
0
        bool generateProperty(XProperty xprop, XClass xclass, StringBuilder sbOut, Chilkat.Log log, bool lowerCaseAlt = false)
        {
            // lets add description...
            IEnumerable <string> chunked = chunkSplit(xprop.Descrip, 100);

            foreach (var chunk in chunked)
            {
                sbOut.Append("\t\t# " + chunk.Trim().Replace("#\t\t", "# ") + "\r\n");
            }
            sbOut.Append("\t\t#\r\n");
            sbOut.Replace("=\r\n\t\t# _", " _");

            // All properties have getters..
            // Types can be emitted using an existing conversion, or you could write your own..
            string klass = m_types.gtToRubyDuck(xprop.m_gt, xprop.GenericType);
            string param = "newval";

            if (!lowerCaseAlt && (!xprop.ReadOnly || xprop.IsBaseEntry))
            {
                switch (xprop.GenericType)
                {
                case "string":
                    klass = "CkString";
                    param = "ckStr";
                    break;

                case "bytes":
                    klass = "CkByteData";
                    param = "ckByteData";
                    break;

                default:
                    // do nothing.
                    break;
                }
            }

            //if (!lowerCaseAlt && xprop.HasCppOutputArg && (!xprop.ReadOnly || xprop.IsBaseEntry))
            //    sbOut.Append("\t\t# +" + param + "+ - [" + klass + "]\r\n");

            //if (!xprop.ReadOnly)
            //    sbOut.Append("\t\t# returns " + ChilkatTypes.genericToRubyPrimitive(xprop.m_gt) + "\r\n\t\t#\r\n");
            //if (xprop.Deprecated)
            //    sbOut.Append("\t\t# This method has been deprecated. Do not use it.\r\n");

            if (!lowerCaseAlt && xprop.HasCppOutputArg && (!xprop.ReadOnly || xprop.IsBaseEntry))
            {
                sbOut.Append("\t\t# @param " + param + " [" + klass + "]\r\n\t\t#\r\n");
            }



            sbOut.Append("\t\t# @return [" + ChilkatTypes.genericToRubyPrimitive(xprop.m_gt) + "]\r\n");
            if (xprop.Deprecated)
            {
                sbOut.Append("\t\t# @deprecated This method has been deprecated. Do not use it.\r\n");
            }

            if (xprop.IsEventRelated())
            {
                sbOut.Append("\t\t#\r\n\t\t# @event\r\n");
            }

            if (lowerCaseAlt)
            {
                sbOut.Append("\t\tdef " + xprop.EntryNameLowercaseNoCk + "() end\r\n\r\n");
            }
            else
            {
                if ((!xprop.ReadOnly || xprop.IsBaseEntry) && xprop.HasCppOutputArg)
                {
                    //MessageBox.Show(xprop.NumArgs.ToString());
                    sbOut.Append("\t\tdef get_" + xprop.EntryName + "(" + param + ") end\r\n\r\n");
                }
                else
                {
                    sbOut.Append("\t\tdef get_" + xprop.EntryName + "() end\r\n\r\n");
                }
            }

            // If the property is not read-only, generate the setter.
            if (!xprop.ReadOnly)
            {
                /*sbOut.Append("\t\t# ==== Attributes\r\n");
                 * sbOut.Append("\t\t# +newval+ - " + ChilkatTypes.genericToRubyPrimitive(xprop.m_gt) + "\r\n");
                 * if (xprop.Deprecated)
                 *  sbOut.Append("\t\t# This method has been deprecated. Do not use it.\r\n");
                 * sbOut.Append("\t\t#\r\n");*/
                // lets add description...
                chunked = chunkSplit(xprop.Descrip, 100);

                foreach (var chunk in chunked)
                {
                    sbOut.Append("\t\t# " + chunk.Trim().Replace("#\t\t", "# ") + "\r\n");
                }
                sbOut.Append("\t\t#\r\n");
                sbOut.Replace("=\r\n\t\t# _", " _");
                sbOut.Append("\t\t# @param newval [" + ChilkatTypes.genericToRubyPrimitive(xprop.m_gt) + "]\r\n");

                if (xprop.IsEventRelated())
                {
                    sbOut.Append("\t\t#\r\n\t\t# @event\r\n");
                    sbOut.Append("\t\t#\r\n\t\t# @!method\r\n");
                }
                if (xprop.Deprecated)
                {
                    sbOut.Append("\t\t#\r\n\t\t# @deprecated This method has been deprecated. Do not use it.\r\n");
                }
                if (lowerCaseAlt && xprop.ReadOnly)
                {
                    sbOut.Append("\t\tdef " + xprop.EntryNameLowercaseNoCk + "() end\r\n\r\n");
                }
                else
                {
                    sbOut.Append("\t\tdef put_" + xprop.EntryName + "(newval) end\r\n\r\n");
                }
            }

            if (!lowerCaseAlt && xprop.ToLowerCaseStringMethod() != null)
            {
                generateProperty(xprop, xclass, sbOut, log, true);
            }
            return(true);
        }
Example #31
0
        public MemorySetVertical()
        {
            base.Database = new List <KeyValuePair <string, IProperty> >();
            base.Shapes   = new List <IShape>();
            base.Pins     = new List <XPin>();

            base.Name = "SR-SET-V";

            IProperty setProperty = new XProperty("S");

            base.Database.Add(new KeyValuePair <string, IProperty>("Set", setProperty));

            IProperty resetProperty = new XProperty("R");

            base.Database.Add(new KeyValuePair <string, IProperty>("Reset", resetProperty));

            base.Shapes.Add(
                new XText()
            {
                X          = 0.0,
                Y          = 0.0,
                Width      = 20.0,
                Height     = 30.0,
                HAlignment = HAlignment.Center,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 14.0,
                Text       = "{0}",
                Properties = new[] { resetProperty }
            });
            base.Shapes.Add(
                new XText()
            {
                X          = 0.0,
                Y          = 30.0,
                Width      = 20.0,
                Height     = 30.0,
                HAlignment = HAlignment.Center,
                VAlignment = VAlignment.Center,
                FontName   = "Consolas",
                FontSize   = 14.0,
                Text       = "{0}",
                Properties = new[] { setProperty }
            });
            base.Shapes.Add(new XRectangle()
            {
                X = 0.0, Y = 0.0, Width = 30.0, Height = 60.0, IsFilled = false
            });
            base.Shapes.Add(new XLine()
            {
                X1 = 0.0, Y1 = 30.0, X2 = 30.0, Y2 = 30.0
            });
            base.Shapes.Add(new XRectangle()
            {
                X = 20.0, Y = 30.0, Width = 10.0, Height = 30.0, IsFilled = true
            });
            base.Pins.Add(new XPin()
            {
                Name = "R", X = 0.0, Y = 15.0, PinType = PinType.Input, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "S", X = 0.0, Y = 45.0, PinType = PinType.Input, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "Q", X = 30.0, Y = 15.0, PinType = PinType.Output, Owner = null
            });
            base.Pins.Add(new XPin()
            {
                Name = "NQ", X = 30.0, Y = 45.0, PinType = PinType.Output, Owner = null
            });
        }
Example #32
0
 set => SetValue(XProperty, value);
Example #33
0
        public void ToString_Should_Return_Value_String()
        {
            var target = XProperty.Create(null, "Property1", "Value1");

            Assert.Equal("Value1", target.ToString());
        }