private void AddDataItem(Field field, IEnumerable <ObjectData> items)
        {
            foreach (Control ctrl in this.controls)
            {
                Field f = ctrl.Tag as Field;
                if (f != null && f != field)
                {
                    foreach (ObjectData d in items)
                    {
                        switch (f.FieldType)
                        {
                        case FieldType.Reference:
                            if (ReferenceProperty.Get(f).Reference == d.ObjectClass)
                            {
                                KryptonComboBox box = (KryptonComboBox)ctrl;
                                if (!box.Items.Contains(d))
                                {
                                    box.Items.Add(d);
                                }
                            }

                            break;

                        case FieldType.Table:
                            TableControl table = (TableControl)ctrl;
                            table.AddDataItem(d);
                            break;
                        }
                    }
                }
            }
        }
示例#2
0
 public NatGateway(ElasticIp elasticIp, Subnet subnet) : base(ResourceType.AwsEc2NatGateway)
 {
     AllocationId = new ReferenceProperty(elasticIp);
     SubnetId     = new ReferenceProperty(subnet);
     this.DependsOn.Add(elasticIp.LogicalId);
     this.DependsOn.Add(subnet.LogicalId);
 }
        public void UseBindableObjectProvider_WithBaseClass()
        {
            IBusinessObjectReferenceProperty property = new ReferenceProperty(
                new PropertyBase.Parameters(
                    _bindableObjectProvider,
                    GetPropertyInfo(typeof(ClassWithReferenceToClassDerivedFromBindableObjectBase), "ScalarReference"),
                    typeof(ClassDerivedFromBindableObjectBase),
                    new Lazy <Type> (() => typeof(ClassDerivedFromBindableObjectBase)),
                    null,
                    false,
                    false,
                    new BindableObjectDefaultValueStrategy(),
                    MockRepository.GenerateStub <IBindablePropertyReadAccessStrategy>(),
                    MockRepository.GenerateStub <IBindablePropertyWriteAccessStrategy>(),
                    SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>()));

            Assert.That(property.ReferenceClass, Is.SameAs(BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(ClassDerivedFromBindableObjectBase))));
            Assert.That(
                property.BusinessObjectProvider,
                Is.SameAs(BindableObjectProvider.GetProviderForBindableObjectType(typeof(ClassWithReferenceToClassDerivedFromBindableObjectBase))));
            Assert.That(
                property.ReferenceClass.BusinessObjectProvider,
                Is.SameAs(BindableObjectProvider.GetProviderForBindableObjectType(typeof(ClassDerivedFromBindableObjectBase))));
            Assert.That(property.ReferenceClass.BusinessObjectProvider, Is.SameAs(property.BusinessObjectProvider));
        }
示例#4
0
        /// <summary>
        ///   Loads the <see cref="BusinessObject"/> from the <see cref="ReferencedDataSource"/> using
        ///   <see cref="ReferenceProperty"/> and populates the bound controls using
        ///   <see cref="BusinessObjectDataSource.LoadValues"/>.
        /// </summary>
        /// <param name="interim"> Specifies whether this is the initial loading, or an interim loading. </param>
        /// <remarks>
        ///   For details on <see cref="LoadValue"/>,
        ///   see <see cref="IBusinessObjectDataSource.LoadValues">IBusinessObjectDataSource.LoadValues</see>.
        /// </remarks>
        /// <seealso cref="IBusinessObjectBoundControl.LoadValue">IBusinessObjectBoundControl.LoadValue</seealso>
        public void LoadValue(bool interim)
        {
            // load value from "parent" data source
            if (HasValidBinding)
            {
                if (interim && HasBusinessObjectCreated)
                {
                    // NOP
                }
                else
                {
                    if (HasBusinessObjectCreated)
                    {
                        DeleteBusinessObject();
                        HasBusinessObjectCreated = false;
                    }

                    _businessObject = null;

                    if (ReferencedDataSource.BusinessObject != null)
                    {
                        _businessObject = (IBusinessObject)ReferencedDataSource.BusinessObject.GetProperty(ReferenceProperty);
                        if (_businessObject == null && SupportsDefaultValueSemantics)
                        {
                            _businessObject          = ReferenceProperty.CreateDefaultValue(ReferencedDataSource.BusinessObject);
                            HasBusinessObjectCreated = true;
                        }
                    }
                    HasBusinessObjectChanged = false;
                }
            }

            // load values into "child" controls
            LoadValues(interim);
        }
示例#5
0
 private void DeleteBusinessObject()
 {
     Assertion.IsNotNull(BusinessObject, "The business object of this reference data source cannot be null when invoking DeleteBusinessObject().");
     if (ReferenceProperty.SupportsDelete)
     {
         ReferenceProperty.Delete(ReferencedDataSource.BusinessObject, BusinessObject);
     }
 }
示例#6
0
 public Function(ReferenceProperty role, string handler, Code code, FunctionRuntime runtime, FunctionMemory memory) : base(ResourceType.AwsLambdaFunction)
 {
     this.Code    = code;
     this.Handler = handler;
     this.Memory  = memory;
     this.Role    = role;
     this.Runtime = runtime;
 }
示例#7
0
        private ReferenceProperty CreateProperty(string propertyName)
        {
            PropertyBase.Parameters propertyParameters =
                GetPropertyParameters(GetPropertyInfo(typeof(ClassWithBusinessObjectProperties), propertyName), _bindableObjectProviderForDeclaringType);
            ReferenceProperty property = new ReferenceProperty(propertyParameters);

            property.SetReflectedClass(BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(ClassWithBusinessObjectProperties)));

            return(property);
        }
        public VpcSettings(Vpc vpc, params Subnet[] subnets)
        {
            SubnetIds = new List <object>();

            VpcId = new ReferenceProperty(vpc);

            foreach (var subnet in subnets)
            {
                this.SubnetIds.Add(new ReferenceProperty(subnet));
            }
        }
示例#9
0
 public override void AddUser(LaunchConfiguration instance, string ou, ReferenceProperty user, ReferenceProperty password)
 {
     if (this.Type == ResourceType.AwsDirectoryServiceMicrosoftAd)
     {
         AddUserMicrosoftAd(instance, ou, (object)user, (object)password);
     }
     else
     {
         AddUserSimpleAd(instance, ou, (object)user, (object)password);
     }
 }
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression <Func <ReferenceEntity, OtherEntity> >)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = A.Fake <ISession>();
            A.CallTo(() => session.BeginTransaction()).Returns(A.Dummy <ITransaction>());
            specification = new PersistenceSpecification <PropertyEntity>(session);

            sut = new ReferenceProperty <PropertyEntity, OtherEntity>(property, referencedEntity);
        }
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression<Func<ReferenceEntity, OtherEntity>>)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = MockRepository.GenerateStub<ISession>();
            session.Stub(x => x.BeginTransaction()).Return(MockRepository.GenerateStub<ITransaction>());
            specification = new PersistenceSpecification<PropertyEntity>(session);

            sut = new ReferenceProperty<PropertyEntity, OtherEntity>(property, referencedEntity);
        }
示例#12
0
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression <Func <ReferenceEntity, OtherEntity> >)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = MockRepository.GenerateStub <ISession>();
            session.Stub(x => x.BeginTransaction()).Return(MockRepository.GenerateStub <ITransaction>());
            specification = new PersistenceSpecification <PropertyEntity>(session);

            sut = new ReferenceProperty <PropertyEntity, OtherEntity>(property, referencedEntity);
        }
        public override void establish_context()
        {
            var property = ReflectionHelper.GetAccessor((Expression<Func<ReferenceEntity, OtherEntity>>)(x => x.Reference));

            referencedEntity = new OtherEntity();

            session = A.Fake<ISession>();
            A.CallTo(() => session.BeginTransaction()).Returns(A.Dummy<ITransaction>());
            specification = new PersistenceSpecification<PropertyEntity>(session);

            sut = new ReferenceProperty<PropertyEntity, OtherEntity>(property, referencedEntity);
        }
        private static void AddReferenceData(string path, List <ReferenceData> references, Component component, SerializedProperty p, string dp)
        {
            ReferenceData rd   = null;
            Transform     node = component.transform;

            foreach (ReferenceData trd in references)
            {
                if (trd.node == node)
                {
                    rd = trd;
                    break;
                }
            }
            if (rd == null)
            {
                rd      = new ReferenceData();
                rd.node = node;
                node_path_gen.Clear();
                Transform t = node;
                while (t != null)
                {
                    node_path_gen.Add(t.name); t = t.parent;
                }
                node_path_gen.Reverse();
                rd.nodePath = string.Join("/", node_path_gen.ToArray());
                references.Add(rd);
            }
            ReferenceComponent rc = null;

            foreach (ReferenceComponent trc in rd.components)
            {
                if (trc.component == component)
                {
                    rc = trc;
                    break;
                }
            }
            if (rc == null)
            {
                rc               = new ReferenceComponent();
                rc.component     = component;
                rc.componentName = component.GetType().FullName;
                rd.components.Add(rc);
            }
            ReferenceProperty rp = new ReferenceProperty();

            rp.propertyPath = new GUIContent(p.propertyPath, string.Format("Asset Path :\n  {0}\n\nNode Path :\n  {1}\n\nComponent :\n  {2}\n\nProperty Path :\n  {3}\n\nDependency Asset :\n  {4}",
                                                                           path, rd.nodePath, rc.componentName, p.propertyPath, dp));
            rp.asset   = p.objectReferenceValue;
            rp.comment = AssetComment.GetAssetComment(rp.asset, true, out rp.commentBold, out rp.commentWarning);
            rc.properties.Add(rp);
        }
        public static PersistenceSpecification <T> CheckReference <T, TProperty>(this PersistenceSpecification <T> spec,
                                                                                 Expression <Func <T, TProperty> > expression,
                                                                                 TProperty propertyValue,
                                                                                 IEqualityComparer propertyComparer,
                                                                                 Action <T, TProperty> propertySetter)
        {
            Accessor propertyInfoFromExpression = ReflectionHelper.GetAccessor(expression);

            var property = new ReferenceProperty <T, TProperty>(propertyInfoFromExpression, propertyValue);

            property.ValueSetter = (target, propertyInfo, value) => propertySetter(target, value);

            return(spec.RegisterCheckedProperty(property, propertyComparer));
        }
        private Control CreateReferenceControl(ObjectData obj, Field field)
        {
            KryptonComboBox combo = new KryptonComboBox();

            combo.DropDownStyle = ComboBoxStyle.DropDownList;

            ObjectClass   c = ReferenceProperty.Get(field).Reference;
            ButtonSpecAny item;

            if (!string.IsNullOrEmpty(c.Form))
            {
                item       = new ButtonSpecAny();
                item.Image = Resources.plus;
                item.Edge  = PaletteRelativeEdgeAlign.Near;
                item.Style = PaletteButtonStyle.Standalone;
                //item.Style = PaletteButtonStyle.NavigatorStack;
                item.Click += new EventHandler(this.ComboBoxAddClick);
                combo.ButtonSpecs.Add(item);
            }

            item       = new ButtonSpecAny();
            item.Image = Resources.crest;
            item.Edge  = PaletteRelativeEdgeAlign.Near;
            item.Style = PaletteButtonStyle.Standalone;
            //item.Style = PaletteButtonStyle.NavigatorStack;
            item.Click += new EventHandler(this.ComboBoxClearClick);
            combo.ButtonSpecs.Add(item);

            if (c != null)
            {
                foreach (ObjectData d in Data.Objects.GetData(c))
                {
                    combo.Items.Add(d);
                }

                if (obj[field] is ObjectData)
                {
                    combo.SelectedItem = (ObjectData)obj[field];
                }
                else
                {
                    combo.SelectedIndex = -1;
                }
            }

            /*combo.StateCommon.ComboBox.Border.Rounding = 4;
             * combo.StateCommon.ComboBox.Border.Width = 2;*/
            return(combo);
        }
        private void ComboBoxAddClick(object sender, EventArgs e)
        {
            ButtonSpecAny   item  = (ButtonSpecAny)sender;
            KryptonComboBox combo = (KryptonComboBox)item.Owner;
            Field           field = (Field)combo.Tag;
            ObjectClass     c     = ReferenceProperty.Get(field).Reference;
            ObjectData      d     = collection.Add(c, false);

            if (d != null)
            {
                combo.Items.Add(d);
                combo.SelectedItem = d;
                this.AddDataItem(field, d);
            }
        }
示例#18
0
        private bool IsBusinessObjectSetToDefaultValue()
        {
            if (HasValidBinding && BusinessObject != null && ReferenceProperty.SupportsDefaultValue)
            {
                if (GetBoundControlsWithValidBinding().Any(c => c.HasValue))
                {
                    return(false);
                }

                var properties = GetBoundControlsWithValidBinding().Select(c => c.Property).Distinct().ToArray();
                return(ReferenceProperty.IsDefaultValue(ReferencedDataSource.BusinessObject, BusinessObject, properties));
            }
            else
            {
                return(false);
            }
        }
示例#19
0
        public void Initialize_WithMissmatchedConcreteType_ThrowsInvalidOperationExceptionWhenConcreteTypeIsFirstUsed()
        {
            PropertyBase.Parameters parameters = CreateParameters(
                _businessObjectProvider,
                GetPropertyInfo(typeof(ClassWithReferenceType <SimpleBusinessObjectClass>), "Scalar"),
                typeof(SimpleBusinessObjectClass),
                typeof(ClassWithAllDataTypes),
                null,
                false,
                false);
            var referenceProperty = new ReferenceProperty(parameters);

            Assert.That(
                () => referenceProperty.SupportsSearchAvailableObjects,
                Throws.InvalidOperationException.With.Message.EqualTo(
                    "The concrete type must be assignable to the underlying type 'Remotion.ObjectBinding.UnitTests.TestDomain.SimpleBusinessObjectClass'.\r\n"
                    + "Concrete type: Remotion.ObjectBinding.UnitTests.TestDomain.ClassWithAllDataTypes"));
        }
示例#20
0
        public void Initialize_WithConcreteTypeNotImplementingIBusinessObject_ThrowsInvalidOperationExceptionWhenConcreteTypeIsFirstUsed()
        {
            PropertyBase.Parameters parameters = CreateParameters(
                _businessObjectProvider,
                GetPropertyInfo(typeof(ClassWithReferenceType <SimpleBusinessObjectClass>), "Scalar"),
                typeof(SimpleBusinessObjectClass),
                typeof(SimpleBusinessObjectClass),
                null,
                false,
                false);
            var referenceProperty = new ReferenceProperty(parameters);

            Assert.That(
                () => referenceProperty.SupportsSearchAvailableObjects,
                Throws.InvalidOperationException.With.Message.EqualTo(
                    "The concrete type must implement the IBusinessObject interface.\r\n"
                    + "Concrete type: Remotion.ObjectBinding.UnitTests.TestDomain.SimpleBusinessObjectClass"));
        }
示例#21
0
        public LaunchConfiguration(Subnet subnet,
                                   InstanceTypes instanceType,
                                   string imageId,
                                   OperatingSystem operatingSystem,
                                   ResourceType resourceType,
                                   bool rename)
            : base(resourceType)
        {
            this.Rename       = rename;
            _availableDevices = new List <string>();
            if (subnet != null)
            {
                this.Subnet = subnet;
            }
            this.InstanceType    = instanceType;
            this.OperatingSystem = operatingSystem;
            switch (OperatingSystem)
            {
            case OperatingSystem.Windows:
                RootDeviceId = "/dev/sda1";
                break;

            case OperatingSystem.Linux:
                RootDeviceId = "/dev/xvda";
                break;

            default:
                throw new NotSupportedException(nameof(operatingSystem));
            }
            Packages = new ObservableCollection <PackageBase <ConfigSet> >();
            Packages.CollectionChanged += Packages_CollectionChanged;
            this.ImageId = imageId;
            this.PopulateAvailableDevices();

            KeyName        = new ReferenceProperty(Template.ParameterKeyPairName);
            SecurityGroups = new List <ReferenceProperty>();
        }
示例#22
0
 public Route(VpcPeeringConnection vpcPeeringConnection, string destinationCidrBlock, object routeTable)
     : this(destinationCidrBlock, routeTable)
 {
     VpcPeeringConnectionId = new ReferenceProperty(vpcPeeringConnection);
     this.DependsOn.Add(vpcPeeringConnection.LogicalId);
 }
 public FnJoinPsExecPowershell(ReferenceProperty userId, ReferenceProperty password, params object[] powerShellElements) : this((object)userId, password, powerShellElements)
 {
 }
示例#24
0
        /// <summary>
        /// 注册特殊的实体属性,这类属性为附加自实体间关系的不可持久化的属性。
        /// </summary>
        /// <param name="propertyInfo">属性名称。</param>
        /// <param name="entityType">实体类型。</param>
        /// <param name="referenceProperty">参数或引用的属性。</param>
        /// <param name="options">关联选项。</param>
        /// <returns>一个 <see cref="IProperty"/> 对象。</returns>
        private static IProperty RegisterSupposedProperty(PropertyInfo propertyInfo, Type entityType, IProperty referenceProperty = null, RelationOptions options = null)
        {
            IProperty property;
            var       useAttr = propertyInfo.GetCustomAttributes <RelationshipUseAttribute>().FirstOrDefault();

            if (referenceProperty != null)
            {
                if (referenceProperty.Type.IsEnum)
                {
                    property = new EnumProperty
                    {
                        Name           = propertyInfo.Name,
                        Type           = propertyInfo.PropertyType,
                        EntityType     = entityType,
                        RelationalType = referenceProperty.Type,
                        Reference      = referenceProperty,
                        Info           = InitRelatedPropertyInfo(propertyInfo),
                        Options        = options ?? RelationOptions.Default
                    };
                }
                else
                {
                    //引用属性
                    property = new ReferenceProperty
                    {
                        Name           = propertyInfo.Name,
                        Type           = propertyInfo.PropertyType,
                        EntityType     = entityType,
                        RelationalType = referenceProperty.EntityType,
                        Reference      = referenceProperty,
                        Info           = InitRelatedPropertyInfo(propertyInfo),
                        Options        = options ?? RelationOptions.Default
                    };
                }
            }
            else if (typeof(IEntity).IsAssignableFrom(propertyInfo.PropertyType))
            {
                //实体引用属性
                property = new EntityProperty
                {
                    RelationalType = propertyInfo.PropertyType,
                    Name           = propertyInfo.Name,
                    Type           = propertyInfo.PropertyType,
                    EntityType     = entityType,
                    RelationalKey  = useAttr?.ForeignKey,
                    Info           = InitRelatedPropertyInfo(propertyInfo),
                    Options        = options ?? RelationOptions.Default
                };
            }
            else if (propertyInfo.PropertyType.IsGenericType &&
                     typeof(IEntitySet).IsAssignableFrom(propertyInfo.PropertyType))
            {
                //实体集属性
                property = new EntitySetProperty
                {
                    RelationalType = propertyInfo.PropertyType.GetGenericArguments()[0],
                    Name           = propertyInfo.Name,
                    Type           = propertyInfo.PropertyType,
                    EntityType     = entityType,
                    RelationalKey  = useAttr?.ForeignKey,
                    Info           = InitRelatedPropertyInfo(propertyInfo),
                    Options        = options ?? RelationOptions.Default
                };
            }
            else
            {
                throw new NotImplementedException();
            }

            return(RegisterProperty(entityType, property));
        }
 public Output(string logicalId, ReferenceProperty value) : this(logicalId, (object)value)
 {
 }
示例#26
0
        internal static SqlCommand BuildReferenceQuery(EntityQueryContext context, IEntity entity, ReferenceProperty referenceProperty)
        {
            var relationKey = RelationshipUnity.GetRelationship(referenceProperty);

            if (relationKey == null)
            {
                return(null);
            }
            var query = new EntityQueryBuilder(context, referenceProperty.RelationType)
                        .Select().Single(referenceProperty.Reference).From();

            foreach (var key in relationKey.Keys)
            {
                query = query.And(key.ThisProperty, entity.InternalGetValue(key.OtherProperty));
            }
            return(query.ToSqlCommand());
        }
        private void ImportField(XmlNode fieldNode, ObjectClass obj)
        {
            XmlAttribute attr = null;

            if (fieldNode.Name == "forms")
            {
                obj.Form = this.ConvertXmlToString(fieldNode.InnerXml);
                return;
            }

            if (fieldNode.Name == "fieldname")
            {
                attr = fieldNode.Attributes["expression"];
                if (attr != null)
                {
                    obj[SystemProperty.Name].Evaluated  = true;
                    obj[SystemProperty.Name].Expression = attr.Value;
                }

                return;
            }

            attr = fieldNode.Attributes["name"];
            if (attr == null)
            {
                return;
            }

            string fieldName = attr.Value;

            attr = fieldNode.Attributes["type"];
            if (attr == null)
            {
                return;
            }

            FieldType fieldType = Utils.Parse(attr.Value);
            Field     field     = this.Database.Classes.AddField(obj, fieldName, fieldType);

            attr = fieldNode.Attributes["category"];
            if (attr != null)
            {
                field.Category = attr.Value;
            }

            attr = fieldNode.Attributes["group"];
            if (attr != null)
            {
                field.Group = bool.Parse(attr.Value);
            }

            field.Comment = fieldNode.AttributeValueOrDefault("comment");

            attr = fieldNode.Attributes["expression"];
            if (attr != null && field.FieldType == FieldType.Text)
            {
                field.Evaluated  = true;
                field.Expression = attr.Value;
            }

            attr = fieldNode.Attributes["order"];
            if (attr != null)
            {
                field.Order = int.Parse(attr.Value);
            }

            switch (fieldType)
            {
            case FieldType.Url:
                attr = fieldNode.Attributes["method"];
                if (attr != null)
                {
                    UrlProperty.Get(field).Type = UrlProperty.Parse(attr.Value);
                }

                break;

            case FieldType.Text:
                XmlAttribute xmlTextDef = fieldNode.Attributes["default"];
                if (xmlTextDef != null)
                {
                    field.DefaultValue.AsText = xmlTextDef.Value;
                }

                break;

            case FieldType.Select:
                XmlAttribute xmlValues = fieldNode.Attributes["values"];
                if (xmlValues != null)
                {
                    List <string> sc = (List <string>)field.Data;
                    sc.AddRange(xmlValues.Value.Split(new char[] { ';' }));
                    XmlAttribute xmlValuesDef = fieldNode.Attributes["default"];
                    if (xmlValuesDef != null)
                    {
                        field.DefaultValue.AsInteger = sc.IndexOf(xmlValuesDef.Value);
                    }
                }

                break;

            case FieldType.Number:
                attr = fieldNode.Attributes["default"];
                if (attr != null)
                {
                    field.DefaultValue.AsDecimal = decimal.Parse(attr.Value);
                }

                NumberProperty prop = (NumberProperty)field.Data;
                attr = fieldNode.Attributes["decimal"];
                if (attr != null)
                {
                    prop.DecimalPlaces = int.Parse(attr.Value);
                }

                attr = fieldNode.Attributes["maximum"];
                if (attr != null)
                {
                    prop.Maximum = decimal.Parse(attr.Value);
                    prop.Bounds  = true;
                }

                attr = fieldNode.Attributes["minimum"];
                if (attr != null)
                {
                    prop.Minimum = decimal.Parse(attr.Value);
                    prop.Bounds  = true;
                }

                attr = fieldNode.Attributes["increment"];
                if (attr != null)
                {
                    prop.Increment = decimal.Parse(attr.Value);
                }

                attr = fieldNode.Attributes["thousands"];
                if (attr != null)
                {
                    prop.Thousands = bool.Parse(attr.Value);
                }

                prop.Prefix = fieldNode.AttributeValueOrDefault("prefix");
                prop.Suffix = fieldNode.AttributeValueOrDefault("suffix");

                break;

            case FieldType.List:
                XmlAttribute xmlListRef = fieldNode.Attributes["ref_guid"];
                if (xmlListRef != null)
                {
                    ListProperty.Get(field).Reference = Database.Classes[new Guid(xmlListRef.Value)];
                }
                else
                {
                    xmlListRef = fieldNode.Attributes["reference"];
                    if (xmlListRef != null)
                    {
                        ImportObjectClass ic_list = this[xmlListRef.Value];
                        ListProperty.Get(field).Reference = Database.Classes[ic_list.Identifier];
                    }
                }

                break;

            case FieldType.Boolean:
                XmlAttribute xmlBoolDef = fieldNode.Attributes["default"];
                if (xmlBoolDef != null)
                {
                    field.DefaultValue.AsBoolean = bool.Parse(xmlBoolDef.Value);
                }

                break;

            case FieldType.Date:
                XmlAttribute xmlDateDef = fieldNode.Attributes["default"];
                if (xmlDateDef != null)
                {
                    field.DefaultValue.AsDateTime = DateTime.Parse(xmlDateDef.Value);
                }

                attr = fieldNode.Attributes["time"];
                if (attr != null)
                {
                    DateProperty.Get(field).ViewTime = bool.Parse(attr.Value);
                }

                break;

            case FieldType.Table:
                XmlAttribute          xmlTableCols = fieldNode.Attributes["columns"];
                List <ColumnProperty> list         = new List <ColumnProperty>();
                if (xmlTableCols != null)
                {
                    foreach (string col in xmlTableCols.Value.Split(new char[] { ';' }))
                    {
                        list.Add(new ColumnProperty(col));
                    }
                }
                else
                {
                    foreach (XmlNode xmlColumn in fieldNode.ChildNodes)
                    {
                        XmlAttribute xmlColName = xmlColumn.Attributes["name"];
                        if (xmlColName != null)
                        {
                            string         colName   = xmlColName.Value;
                            ColumnProperty cp        = new ColumnProperty(colName);
                            XmlAttribute   xmlColRef = xmlColumn.Attributes["ref_guid"];
                            if (xmlColRef != null)
                            {
                                cp.Reference = Database.Classes[new Guid(xmlColRef.Value)];
                            }
                            else
                            {
                                xmlColRef = xmlColumn.Attributes["reference"];
                                if (xmlColRef != null)
                                {
                                    ImportObjectClass c_ref = this[xmlColRef.Value];
                                    cp.Reference = Database.Classes[c_ref.Identifier];
                                }
                            }

                            attr = xmlColumn.Attributes["width"];
                            if (attr != null)
                            {
                                cp.Width = int.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["min_width"];
                            if (attr != null)
                            {
                                cp.MinWidth = int.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["visible"];
                            if (attr != null)
                            {
                                cp.Visible = bool.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["resizable"];
                            if (attr != null)
                            {
                                cp.Resizable = bool.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["frozen"];
                            if (attr != null)
                            {
                                cp.Frozen = bool.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["div_width"];
                            if (attr != null)
                            {
                                cp.DividerWidth = int.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["auto_size"];
                            if (attr != null)
                            {
                                cp.AutoSize = bool.Parse(attr.Value);
                            }

                            attr = xmlColumn.Attributes["fill_weight"];
                            if (attr != null)
                            {
                                cp.FillWeight = int.Parse(attr.Value);
                            }

                            list.Add(cp);
                        }
                    }
                }

                ((List <ColumnProperty>)field.Data).AddRange(list);
                break;

            case FieldType.Rating:
                XmlAttribute xmlRaitDef = fieldNode.Attributes["default"];
                if (xmlRaitDef != null)
                {
                    field.DefaultValue.AsDecimal = decimal.Parse(xmlRaitDef.Value);
                }

                break;

            case FieldType.Reference:
                XmlAttribute xmlRef = fieldNode.Attributes["ref_guid"];
                if (xmlRef != null)
                {
                    ReferenceProperty.Get(field).Reference = Database.Classes[new Guid(xmlRef.Value)];
                }
                else
                {
                    xmlRef = fieldNode.Attributes["reference"];
                    if (xmlRef != null)
                    {
                        ImportObjectClass ic_ref = this[xmlRef.Value];
                        ReferenceProperty.Get(field).Reference = Database.Classes[ic_ref.Identifier];
                    }
                }

                break;
            }
        }
        private static void ExportField(XmlDocument doc, XmlElement f, Field field)
        {
            switch (field.FieldType)
            {
            case FieldType.Url:
                UrlProperty uprop = (UrlProperty)field.Data;
                switch (uprop.Type)
                {
                case UrlType.File:
                    doc.AddAttribute(f, new XmlAttributeElement("method", "file"));
                    break;

                case UrlType.Folder:
                    doc.AddAttribute(f, new XmlAttributeElement("method", "folder"));
                    break;

                case UrlType.Url:
                    doc.AddAttribute(f, new XmlAttributeElement("method", "url"));
                    break;
                }

                break;

            case FieldType.Text:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.AsText, string.Empty));
                }

                break;

            case FieldType.Select:
                List <string> sc           = (List <string>)field.Data;
                string        selectValues = string.Empty;
                foreach (string s in sc)
                {
                    if (selectValues.Length != 0)
                    {
                        selectValues += ";";
                    }

                    selectValues += s;
                }

                doc.AddAttribute(f, new XmlAttributeElement("values", selectValues));
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString(), (-1).ToString()));
                }

                break;

            case FieldType.Number:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString(), (0).ToString()));
                }

                NumberProperty prop = field.Data as NumberProperty;
                if (prop != null)
                {
                    doc.AddAttributes(f, new XmlAttributeElement[] {
                        new XmlAttributeElement("decimal", prop.DecimalPlaces.ToString(), (0).ToString()),
                        new XmlAttributeElement("increment", prop.Increment.ToString(), (1).ToString()),
                        new XmlAttributeElement("thousands", prop.Thousands.ToString(), false.ToString()),
                        new XmlAttributeElement("prefix", prop.Prefix, string.Empty),
                        new XmlAttributeElement("suffix", prop.Suffix, string.Empty)
                    });
                    if (prop.Bounds)
                    {
                        doc.AddAttributes(f, new XmlAttributeElement[] {
                            new XmlAttributeElement("maximum", prop.Maximum.ToString()),
                            new XmlAttributeElement("minimum", prop.Minimum.ToString())
                        });
                    }
                }

                break;

            case FieldType.List:
                ListProperty listRef = field.Data as ListProperty;
                if (listRef != null)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("ref_guid", listRef.Reference.Identifier.ToString()));
                }

                break;

            case FieldType.Boolean:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString()));
                }

                break;

            case FieldType.Date:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString(), DateTime.MinValue.ToString()));
                    DateProperty dprop = field.Data as DateProperty;
                    if (dprop != null)
                    {
                        doc.AddAttribute(f, new XmlAttributeElement("time", dprop.ViewTime.ToString(), false.ToString()));
                    }
                }

                break;

            case FieldType.Rating:
                if (field.DefaultValue.Enabled)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("default", field.DefaultValue.Value.ToString(), (0).ToString()));
                }

                break;

            case FieldType.Reference:
                ReferenceProperty reference = field.Data as ReferenceProperty;
                if (reference != null)
                {
                    doc.AddAttribute(f, new XmlAttributeElement("ref_guid", reference.Reference.Identifier.ToString()));
                }

                break;

            case FieldType.Table:
                List <ColumnProperty> list = (List <ColumnProperty>)field.Data;
                foreach (ColumnProperty cp in list)
                {
                    XmlElement c = doc.CreateElement(f, "column", "name", cp.Name);
                    if (cp.Reference != null)
                    {
                        doc.AddAttribute(c, new XmlAttributeElement("ref_guid", cp.Reference.Identifier.ToString()));
                    }
                }

                break;
            }
        }
 public VolumeAttachment(string device, Instance instance, Volume volume)
     : this(device, instance)
 {
     VolumeId = new ReferenceProperty(volume);
     this.LogicalId = $"VolumeAttachment{Instance.LogicalId}{volume.LogicalId}";
 }
示例#30
0
 public abstract void AddUser(LaunchConfiguration instanceRdp, string ou, ReferenceProperty user, ReferenceProperty password);
示例#31
0
 set => SetValue(ReferenceProperty, value);
示例#32
0
 public VpcDhcpOptionsAssociation(ReferenceProperty dhcpOptions, Vpc vpc) : this((object)dhcpOptions, (object)vpc)
 {
 }