public PropertyBaseClipboardFormat(PropertyBase property)
     : base(property)
 {
     _propertyName = property.LocalName.Value;
     _setter = property.Setter.IsDefaulted ? String.Empty : property.Setter.Value;
     _getter = property.Getter.IsDefaulted ? String.Empty : property.Getter.Value;
     ValidateAttributes(property);
 }
        private void ValidateAttributes(PropertyBase property)
        {
#if DEBUG
            ICollection<string> attributesCollection = new List<string>();
            foreach (var propertyInfo in GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
            {
                var attributes =
                    propertyInfo.GetCustomAttributes(typeof(ClipboardPropertyMapAttribute), false) as ClipboardPropertyMapAttribute[];
                if (attributes != null
                    && attributes.Length > 0)
                {
                    Debug.Assert(
                        attributes.Length == 1,
                        String.Format(
                            CultureInfo.CurrentCulture, "There exist more than 1 instance of {0} for {1}", "ClipboardPropertyMapAttribute",
                            propertyInfo.Name));
                    Debug.Assert(
                        !attributes[0].IsExcluded,
                        String.Format(CultureInfo.CurrentCulture, "Attribute {0} is misplaced.", attributes[0].AttributeName));
                    attributesCollection.Add(attributes[0].AttributeName);
                }
            }

            var excludedAttributes =
                GetType().GetCustomAttributes(typeof(ClipboardPropertyMapAttribute), false) as ClipboardPropertyMapAttribute[];
            if (excludedAttributes != null)
            {
                foreach (var excludedAttribute in excludedAttributes)
                {
                    Debug.Assert(
                        excludedAttribute.IsExcluded,
                        String.Format(CultureInfo.CurrentCulture, "Attribute {0} is misplaced.", excludedAttribute.AttributeName));
                    attributesCollection.Add(excludedAttribute.AttributeName);
                }
            }

            foreach (var attributeName in property.MyAttributeNames())
            {
                Debug.Assert(
                    attributesCollection.Contains(attributeName),
                    String.Format(CultureInfo.CurrentCulture, "Clipboard format for {0} does not exist", attributeName));
            }
#endif
        }
        /// <summary>
        ///     Return the number of steps in which the property will be moved.
        ///     The logic is to return the Math.Min of the # of steps passed in to the command and the # of steps from the property to the previously moved property.
        ///     If previously moved property is null, just return the # of steps passed in to the command.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="previouslyMovedProperty"></param>
        /// <returns></returns>
        private uint GetNumberOfMoveStep(PropertyBase property, PropertyBase previouslyMovedProperty)
        {
            if (previouslyMovedProperty == null)
            {
                return _step;
            }

            uint numberOfSteps = 0;
            var insertLocation = _moveDirection == MoveDirection.Up
                                     ? property.PreviousSiblingInPropertyXElementOrder
                                     : property.NextSiblingInPropertyXElementOrder;
            for (; numberOfSteps < _step && insertLocation != null && insertLocation != previouslyMovedProperty; numberOfSteps++)
            {
                insertLocation = _moveDirection == MoveDirection.Up
                                     ? insertLocation.PreviousSiblingInPropertyXElementOrder
                                     : insertLocation.NextSiblingInPropertyXElementOrder;
            }
            return numberOfSteps;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Return the number of steps in which the property will be moved.
        ///     The logic is to return the Math.Min of the # of steps passed in to the command and the # of steps from the property to the previously moved property.
        ///     If previously moved property is null, just return the # of steps passed in to the command.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="previouslyMovedProperty"></param>
        /// <returns></returns>
        private uint GetNumberOfMoveStep(PropertyBase property, PropertyBase previouslyMovedProperty)
        {
            if (previouslyMovedProperty == null)
            {
                return(_step);
            }

            uint numberOfSteps  = 0;
            var  insertLocation = _moveDirection == MoveDirection.Up
                                     ? property.PreviousSiblingInPropertyXElementOrder
                                     : property.NextSiblingInPropertyXElementOrder;

            for (; numberOfSteps < _step && insertLocation != null && insertLocation != previouslyMovedProperty; numberOfSteps++)
            {
                insertLocation = _moveDirection == MoveDirection.Up
                                     ? insertLocation.PreviousSiblingInPropertyXElementOrder
                                     : insertLocation.NextSiblingInPropertyXElementOrder;
            }
            return(numberOfSteps);
        }
        public bool IsDefaultValue(IBusinessObject obj, PropertyBase property)
        {
            var domainObject = ArgumentUtility.CheckNotNullAndType <IDomainObject> ("obj", obj);

            ArgumentUtility.CheckNotNull("property", property);

            if (domainObject.GetState() != StateType.New)
            {
                return(false);
            }

            var propertyDefinition = domainObject.ID.ClassDefinition.ResolveProperty(property.PropertyInfo);

            if (propertyDefinition != null)
            {
                var properties = new PropertyIndexer(domainObject);
                return(!properties[propertyDefinition.PropertyName].HasBeenTouched);
            }

            return(_innerDefaultValueStrategy.IsDefaultValue(obj, property));
        }
Ejemplo n.º 6
0
 public void CullDisassociatedProperties()
 {
     for (int index = this.basicProperties.Count - 1; index >= 0; --index)
     {
         PropertyBase propertyBase = (PropertyBase)this.basicProperties[index];
         if (!propertyBase.Associated && propertyBase.RemoveFromCategoryWhenDisassociated)
         {
             propertyBase.OnRemoveFromCategory();
             this.basicProperties.RemoveAt(index);
         }
     }
     for (int index = this.advancedProperties.Count - 1; index >= 0; --index)
     {
         PropertyBase propertyBase = (PropertyBase)this.advancedProperties[index];
         if (!propertyBase.Associated && propertyBase.RemoveFromCategoryWhenDisassociated)
         {
             propertyBase.OnRemoveFromCategory();
             this.advancedProperties.RemoveAt(index);
         }
     }
 }
    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    public virtual bool CanSetField(string?fieldName, ConfigurationSource?configurationSource)
    {
        if (configurationSource.Overrides(Metadata.GetFieldInfoConfigurationSource()))
        {
            if (fieldName == null)
            {
                return(true);
            }

            var fieldInfo = PropertyBase.GetFieldInfo(
                fieldName, Metadata.DeclaringType, Metadata.Name,
                shouldThrow: configurationSource == ConfigurationSource.Explicit);

            return(fieldInfo != null &&
                   PropertyBase.IsCompatible(
                       fieldInfo, Metadata.ClrType, Metadata.DeclaringType.ClrType, Metadata.Name,
                       shouldThrow: configurationSource == ConfigurationSource.Explicit));
        }

        return(Metadata.FieldInfo?.GetSimpleMemberName() == fieldName);
    }
Ejemplo n.º 8
0
        // is the property key a textCode?
        private bool IsKeyMatchProperty(PropertyBase property, string key, TextCode tcKey)
        {
            PropertyKeyTextCode keyTextCode = property.Key as PropertyKeyTextCode;

            if (keyTextCode != null)
            {
                if (tcKey != null)
                {
                    // the key to find is a TextCode
                    if (keyTextCode.TextCodeId.Equals(tcKey.Id))
                    {
                        return(true);
                    }
                }
                else
                {
                    // the property key is a textCode, load it to get the code, because the key is a string
                    TextCode tcPropKey = _reposit.Finder.FindTextCodeById(keyTextCode.TextCodeId);
                    if (tcPropKey.Code.Equals(key))
                    {
                        return(true);
                    }
                }
            }

            // is the property key a string?
            PropertyKeyString keyString = property.Key as PropertyKeyString;

            if (keyString != null)
            {
                // compare strings
                if (keyString.Key.Equals(key))
                {
                    return(true);
                }
            }

            // the property doesn't match the key (string or TextCode)
            return(false);
        }
        public void EntOneProp_KTextCode_VTextCode()
        {
            EtagairCore core = Common.CreateCore(RepositConfig);

            TextCode tcKeyType   = core.Editor.CreateTextCode("Type");
            TextCode tcValueType = core.Editor.CreateTextCode("Computer");

            // create an entity template to instantiate
            EntityTempl templComputer = core.EditorTempl.CreateEntityTempl("TemplComputer");

            // add property
            core.EditorTempl.CreatePropTempl(templComputer, tcKeyType, tcValueType);

            //====Instanciate the template, create an entity, under the root folder
            EntityTemplToInst templToInst = core.ProcessTempl.CreateEntity(templComputer);

            // check that the execution finishes with success
            Assert.AreEqual(TemplToInstState.Success, templToInst.State, "the state should be sucess");
            Assert.AreEqual(TemplToInstStep.Ends, templToInst.NextStep, "the next step should be ends");

            // check, get the property: Type=Computer
            PropertyBase propBase = core.Searcher.FindPropertyByKey(templToInst.Entity, templToInst.Entity.PropertyRoot, "Type", false);

            Assert.IsNotNull(propBase, "the propBase Type=Computer should exists");
            Property prop = propBase as Property;

            Assert.IsNotNull(prop, "the prop Type=Computer should exists");

            //----check the prop key
            PropertyKeyTextCode propKeyTextCode = prop.Key as PropertyKeyTextCode;

            Assert.IsNotNull(propKeyTextCode, "the prop key string Type should exists");
            Assert.AreEqual(tcKeyType.Id, propKeyTextCode.TextCodeId, "the prop value should be the textCode id of the text Name");

            //----check the prop value
            ValTextCodeId propValueTextCode = prop.Value as ValTextCodeId;

            Assert.IsNotNull(propValueTextCode, "the prop key string Typeshould exists");
            Assert.AreEqual(tcValueType.Id, propValueTextCode.TextCodeId, "the prop value should be the textCode id of text Toshiba");
        }
Ejemplo n.º 10
0
        private bool PropertyBase_ReadPropertiesFromAttributes(SerializationContext serializationContext,
                                                               PropertyBase propertyBase, XmlReader reader)
        {
            // Access
            if (!serializationContext.Result.Failed)
            {
                string attribAccess = DONetEntityModelDesignerSerializationHelper.Instance.ReadAttribute(serializationContext, propertyBase, reader, "access");
                if (attribAccess != null)
                {
                    AccessModifier valueOfAccess;
                    if (SerializationUtilities.TryGetValue <AccessModifier>(serializationContext, attribAccess, out valueOfAccess))
                    {
                        propertyBase.PropertyAccess = new PropertyAccessModifiers();
                        PropertyAccessModifier modifier = valueOfAccess == AccessModifier.Public
                                                              ? PropertyAccessModifier.Public
                                                              : PropertyAccessModifier.Internal;
                        propertyBase.PropertyAccess.Getter = modifier;
                        propertyBase.PropertyAccess.Setter = modifier;

                        return(true);
                    }
                    else
                    {   // Invalid property value, ignored.
                        EntityModelDesignerSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "access", typeof(AccessModifier), attribAccess);
                    }
                }
                else
                {
                    propertyBase.PropertyAccess        = new PropertyAccessModifiers();
                    propertyBase.PropertyAccess.Getter = PropertyAccessModifier.Public;
                    propertyBase.PropertyAccess.Setter = PropertyAccessModifier.Public;

                    return(false);
                }
            }

            return(false);
        }
        public void EntOneProp_KString_VString()
        {
            EtagairCore core = Common.CreateCore(RepositConfig);

            // create an entity template to instantiate
            EntityTempl templComputer = core.EditorTempl.CreateEntityTempl("TemplComputer");

            // add property
            core.EditorTempl.CreatePropTempl(templComputer, "Type", "Computer");

            //====Instanciate the template, create an entity, under the root folder
            EntityTemplToInst templToInst = core.ProcessTempl.CreateEntity(templComputer);

            //====check that the execution finishes with success
            Assert.AreEqual(TemplToInstState.Success, templToInst.State, "the state should be sucess");
            Assert.AreEqual(TemplToInstStep.Ends, templToInst.NextStep, "the next step should be ends");

            // check, get the property: Type=Computer
            PropertyBase propBase = core.Searcher.FindPropertyByKey(templToInst.Entity, templToInst.Entity.PropertyRoot, "Type", false);

            Assert.IsNotNull(propBase, "the propBase Type=Computer should exists");
            Property prop = propBase as Property;

            Assert.IsNotNull(prop, "the prop Type=Computer should exists");

            // check the key prop
            PropertyKeyString propKeyString = prop.Key as PropertyKeyString;

            Assert.IsNotNull(propKeyString, "the prop key string Type should exists");
            Assert.AreEqual("Type", propKeyString.Key, "the key should be Type");

            // check the prop value
            //PropertyValueString propValueString = prop.Value as PropertyValueString;
            ValString propValueString = prop.Value as ValString;

            Assert.IsNotNull(propValueString, "the prop key string Typeshould exists");
            Assert.AreEqual("Computer", propValueString.Value, "the value should be Computer");
        }
Ejemplo n.º 12
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method adds this item to the parent, if not found.</summary>
        ///--------------------------------------------------------------------------------
        public void AddToParent()
        {
            PropertyBase propertyBase = Solution.PropertyBaseList.Find(i => i.PropertyID == PropertyID);

            if (propertyBase != null)
            {
                PropertyBase = propertyBase;
                SetID();                  // id (from saved ids) may change based on parent info
                PropertyRelationship propertyRelationship = propertyBase.PropertyRelationshipList.Find(i => i.PropertyRelationshipID == PropertyRelationshipID);
                if (propertyRelationship != null)
                {
                    if (propertyRelationship != this)
                    {
                        propertyBase.PropertyRelationshipList.Remove(propertyRelationship);
                        propertyBase.PropertyRelationshipList.Add(this);
                    }
                }
                else
                {
                    propertyBase.PropertyRelationshipList.Add(this);
                }
            }
        }
Ejemplo n.º 13
0
        private void UnPackProperty(ByteBuffer buf)
        {
            if (buf.ReadableBytes() < 2)
            {
                return;
            }
            int index = buf.ReadUshort();

            if (index == MESSAGE_OVER_MASK)
            {
                return;
            }

            if (index < 0 || index >= properties.Count)
            {
                throw new Exception("proto index is invalid->" + index);
            }
            PropertyBase pb = properties[index];

            pb.UnPack(buf);

            UnPackProperty(buf);
        }
Ejemplo n.º 14
0
        public bool IsPropertyAccessException(
            IBusinessObject businessObject,
            PropertyBase bindableProperty,
            Exception exception,
            out BusinessObjectPropertyAccessException propertyAccessException)
        {
            ArgumentUtility.DebugCheckNotNull("businessObject", businessObject);
            ArgumentUtility.DebugCheckNotNull("bindableProperty", bindableProperty);
            ArgumentUtility.DebugCheckNotNull("exception", exception);

            // This section does represent an inherrent hot-path but the for-loop is chosen for symmetry with the CanRead()-method.
            // ReSharper disable once ForCanBeConvertedToForeach
            for (int i = 0; i < _bindablePropertyReadAccessStrategies.Length; i++)
            {
                var bindablePropertyReadAccessStrategy = _bindablePropertyReadAccessStrategies[i];
                if (bindablePropertyReadAccessStrategy.IsPropertyAccessException(businessObject, bindableProperty, exception, out propertyAccessException))
                {
                    return(true);
                }
            }
            propertyAccessException = null;
            return(false);
        }
Ejemplo n.º 15
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets the current model context for the item.</summary>
        ///
        /// <param name="parentModelContext">The parent model context from which to get current model context.</param>
        /// <param name="isValidContext">Output flag, signifying whether context returned is a valid one.</param>
        ///--------------------------------------------------------------------------------
        public static IDomainEnterpriseObject GetModelContext(Solution solutionContext, IDomainEnterpriseObject parentModelContext, out bool isValidContext)
        {
            isValidContext = true;
            IDomainEnterpriseObject modelContext = parentModelContext;

            while (modelContext != null)
            {
                if (modelContext is PropertyRelationship)
                {
                    return(modelContext);
                }
                else if (solutionContext.IsSampleMode == true && solutionContext.NeedsSample == true && modelContext is PropertyBase)
                {
                    solutionContext.NeedsSample = false;
                    PropertyBase parent = modelContext as PropertyBase;
                    if (parent.PropertyRelationshipList.Count > 0)
                    {
                        return(parent.PropertyRelationshipList[DataHelper.GetRandomInt(0, parent.PropertyRelationshipList.Count - 1)]);
                    }
                }
                #region protected
                #endregion protected

                if (modelContext is Solution)
                {
                    break;
                }
                modelContext = modelContext.GetParentItem();
            }
            if (solutionContext.IsSampleMode == true && solutionContext.NeedsSample == true && solutionContext.PropertyRelationshipList.Count > 0)
            {
                solutionContext.NeedsSample = false;
                return(solutionContext.PropertyRelationshipList[DataHelper.GetRandomInt(0, solutionContext.PropertyRelationshipList.Count - 1)]);
            }
            isValidContext = false;
            return(null);
        }
Ejemplo n.º 16
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(PropertyBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_GetDetail, serviceImpl.GetDetail)
            .AddMethod(__Method_GetDetailByName, serviceImpl.GetDetailByName).Build());
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Tries the parse value.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="item">The item.</param>
 /// <param name="entry">The entry.</param>
 /// <param name="value">The value.</param>
 /// <param name="accountDisabled">if set to <c>true</c> [account disabled].</param>
 /// <param name="attr">The attribute.</param>
 /// <returns></returns>
 protected virtual bool TryParseValue(PropertyBase item, CsvRow entry, string value, bool accountDisabled, DirectoryAttribute attr, SearchResultEntry sre) => false;
Ejemplo n.º 18
0
 public DatabaseProperty(PropertyBase propertyBase)
 {
     Name = propertyBase.Name ?? "default";
     Type = DatabaseType.GetOrAdd(propertyBase.Type);
 }
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public static bool IsIndexerProperty(this PropertyBase propertyBase)
 => ((IReadOnlyPropertyBase)propertyBase).IsIndexerProperty();
Ejemplo n.º 20
0
 protected void Add(PropertyBase property)
 {
     property.OnValueChanged += OnPropertyValueChanged;
     properties.Add(property);
 }
        /// <summary>
        ///     Given a DSL Property return the previous sibling.
        ///     The method will do the following:
        ///     - Given the DSL Property get its model property from Model XRef.
        ///     - Loop model property's previous siblings.
        ///     - For each model property's previous sibling, get the corresponding DSL property from Model XRef.
        ///     - If the DSL property is not null, return immediately.
        ///     - If the DSL property is null, check its previous sibling.
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        private PropertyBase FindPreviousProperty(PropertyBase property)
        {
            var modelProperty = ModelXRef.GetExisting(property) as Model.Entity.PropertyBase;
            Debug.Assert(modelProperty != null, "Unable to get Entity Designer Model for :" + property.Name + " from model xref.");
            if (modelProperty != null)
            {
                var previousModelProperty = modelProperty.PreviousSiblingInPropertyXElementOrder;

                while (previousModelProperty != null)
                {
                    var previousProperty = ModelXRef.GetExisting(previousModelProperty) as PropertyBase;
                    if (previousProperty != null)
                    {
                        return previousProperty;
                    }
                    previousModelProperty = previousModelProperty.PreviousSiblingInPropertyXElementOrder;
                }
            }
            return null;
        }
    private static Func <IUpdateEntry, TProperty> CreateCurrentValueGetter <TProperty>(
        IPropertyBase propertyBase,
        bool useStoreGeneratedValues)
    {
        var entityClrType   = propertyBase.DeclaringType.ClrType;
        var updateParameter = Expression.Parameter(typeof(IUpdateEntry), "entry");
        var entryParameter  = Expression.Convert(updateParameter, typeof(InternalEntityEntry));

        var        shadowIndex = propertyBase.GetShadowIndex();
        Expression currentValueExpression;

        if (shadowIndex >= 0)
        {
            currentValueExpression = Expression.Call(
                entryParameter,
                InternalEntityEntry.ReadShadowValueMethod.MakeGenericMethod(typeof(TProperty)),
                Expression.Constant(shadowIndex));
        }
        else
        {
            var convertedExpression = Expression.Convert(
                Expression.Property(entryParameter, "Entity"),
                entityClrType);

            var memberInfo = propertyBase.GetMemberInfo(forMaterialization: false, forSet: false);
            currentValueExpression = PropertyBase.CreateMemberAccess(propertyBase, convertedExpression, memberInfo);

            if (currentValueExpression.Type != typeof(TProperty))
            {
                currentValueExpression = Expression.Condition(
                    currentValueExpression.MakeHasDefaultValue(propertyBase),
                    Expression.Constant(default(TProperty), typeof(TProperty)),
                    Expression.Convert(currentValueExpression, typeof(TProperty)));
            }
        }

        var storeGeneratedIndex = propertyBase.GetStoreGeneratedIndex();

        if (storeGeneratedIndex >= 0)
        {
            if (useStoreGeneratedValues)
            {
                currentValueExpression = Expression.Condition(
                    Expression.Equal(
                        currentValueExpression,
                        Expression.Constant(default(TProperty), typeof(TProperty))),
                    Expression.Call(
                        entryParameter,
                        InternalEntityEntry.ReadStoreGeneratedValueMethod.MakeGenericMethod(typeof(TProperty)),
                        Expression.Constant(storeGeneratedIndex)),
                    currentValueExpression);
            }

            currentValueExpression = Expression.Condition(
                Expression.Equal(
                    currentValueExpression,
                    Expression.Constant(default(TProperty), typeof(TProperty))),
                Expression.Call(
                    entryParameter,
                    InternalEntityEntry.ReadTemporaryValueMethod.MakeGenericMethod(typeof(TProperty)),
                    Expression.Constant(storeGeneratedIndex)),
                currentValueExpression);
        }

        return(Expression.Lambda <Func <IUpdateEntry, TProperty> >(
                   currentValueExpression,
                   updateParameter)
               .Compile());
    }
        public SaveWindow(Gwen.Controls.ControlBase parent, MainWindow glgame) : base(parent, "Save Track")
        {
            game = glgame;
            game.Track.Stop();
            MakeModal(true);
            Label l = new Label(this);

            l.Text = "Tracks are saved to\r\nDocuments/LRA/Tracks";

            var bottom = new PropertyBase(this)
            {
                Name = "bottom", Margin = new Margin(0, 10, 0, 5), Height = 30
            };
            var cb = new ComboBox(this);

            cb.ItemSelected += (o, e) =>
            {
                var snd = ((ComboBox)o);
                var txt = snd.SelectedItem.Text;
                this.UserData = txt;
            };
            var tb = new TextBox(bottom)
            {
                Name = "tb"
            };

            tb.Dock     = Pos.Left;
            bottom.Dock = Pos.Bottom;
            cb.Dock     = Pos.Bottom;
            cb.Margin   = new Margin(0, 0, 0, 0);
            this.Width  = 200;
            this.Height = 130;
            var dir = Program.UserDirectory + "Tracks";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            var folders = Directory.GetDirectories(Program.UserDirectory + "Tracks");

            cb.AddItem("<create new track>"); //< used as it cant be used as a file character
            cb.SelectByText("<create new track>");
            foreach (var folder in folders)
            {
                var trackname = Path.GetFileName(folder);
                if (trackname != Utils.Constants.DefaultTrackName)
                {
                    cb.AddItem(trackname);
                }
            }
            cb.SelectByText(game.Track.Name);
            var btn = new Button(bottom)
            {
                Name = "savebtn"
            };

            btn.Width    = 50;
            btn.Text     = "Save";
            btn.Dock     = Pos.Right;
            btn.Clicked += savebtn_Clicked;
            DisableResizing();
            game.Cursor = game.Cursors["default"];
        }
 public override bool ValueEquals(PropertyBase <char> other) => other.Value == Value;
Ejemplo n.º 25
0
        /// <summary>
        /// Find a property by the key "raw" string (can be a textCode).
        /// From a property parent.
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public PropertyBase FindPropertyByKey(Entity entity, PropertyGroup propertyParent, string key, bool goInsideChilds)
        {
            if (entity == null)
            {
                return(null);
            }
            if (propertyParent == null)
            {
                return(null);
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                return(null);
            }

            // load the textCode of the key, if exists
            TextCode tcKey = _reposit.Finder.FindTextCodeByCode(key);

            List <PropertyGroup> listPropGroup = new List <PropertyGroup>();

            // the key can be a string or a textCode
            foreach (var propertyBase in propertyParent.ListProperty)
            {
                // is it a final property?
                Property property = propertyBase as Property;
                if (property != null)
                {
                    // is the property key a textCode?
                    if (IsKeyMatchProperty(property, key, tcKey))
                    {
                        return(property);
                    }

                    // next property
                    continue;
                }

                // is it a group property?
                PropertyGroup propertyGroup = propertyBase as PropertyGroup;
                if (propertyGroup != null)
                {
                    // is the property key a textCode?
                    if (IsKeyMatchProperty(propertyGroup, key, tcKey))
                    {
                        return(propertyGroup);
                    }

                    // save the prop Group
                    listPropGroup.Add(propertyGroup);

                    // next property
                    continue;
                }
            }

            if (!goInsideChilds)
            {
                // not found
                return(null);
            }

            // now scan props in childs
            foreach (PropertyGroup propertyGroup in listPropGroup)
            {
                PropertyBase propFound = FindPropertyByKey(entity, propertyGroup, key, goInsideChilds);
                if (propFound != null)
                {
                    return(propFound);
                }
            }

            // not found
            return(null);
        }
Ejemplo n.º 26
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, PropertyBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_GetDetail, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::LocationProxy.Point, global::LocationProxy.Detail>(serviceImpl.GetDetail));
     serviceBinder.AddMethod(__Method_GetDetailByName, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::LocationProxy.DetailRequest, global::LocationProxy.Detail>(serviceImpl.GetDetailByName));
 }
Ejemplo n.º 27
0
 public PropertySerializationModel(PropertyBase baseProperty)
 {
     this.Name = baseProperty.Name;
     this.Type = TypeSerializationModel.GetOrAdd(baseProperty.Type);
 }
Ejemplo n.º 28
0
 internal MovePropertyCommand(PropertyBase property, MoveDirection dir, uint step)
 {
     _property      = property;
     _moveDirection = dir;
     _step          = step;
 }
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public static bool IsShadowProperty(this PropertyBase propertyBase)
 => ((IReadOnlyPropertyBase)propertyBase).IsShadowProperty();
Ejemplo n.º 30
0
 public UIRelatedProperty(IUIType parentType, PropertyBase property)
     : base(parentType, property)
 {
 }
Ejemplo n.º 31
0
 public string PropertyOutputTypeName(PropertyBase property) => OutputTypeName(property.Type);
Ejemplo n.º 32
0
 public string PropertyFieldName(PropertyBase property)
 {
     return("_" + Utils.PascalCaseToCamelCase(property.Name));
 }
 public static string GetFullyQualifiedName(PropertyBase propertyBase)
 {
     var qName = propertyBase.QName;
     return qName.Namespace + "#" + qName.Name;
 }
Ejemplo n.º 34
0
        public string DefaultValue(PropertyBase property)
        {
            ITypeSymbol propertyType = property.Type;
            string      typeFullName = Utils.GetTypeFullName(propertyType);

            if (property.SpecifiedDefaultValue != null)
            {
                TypedConstant specifiedDefaultValue = property.SpecifiedDefaultValue.Value;

                if (specifiedDefaultValue.IsNull)
                {
                    return("null");
                }

                var    kind  = specifiedDefaultValue.Kind;
                object value = specifiedDefaultValue.Value !;

                if (kind == TypedConstantKind.Primitive)
                {
                    if (value is string stringArgumentValue)
                    {
                        if (typeFullName == "Microsoft.StandardUI.Point" && stringArgumentValue == "0.5,0.5")
                        {
                            return($"{OutputTypeName(propertyType)}.CenterDefault");
                        }
                        else if (stringArgumentValue == "")
                        {
                            return("\"\"");
                        }
                        else
                        {
                            new UserViewableException($"Unknown string literal based default value: {stringArgumentValue}");
                        }
                    }
                    else if (value is double doubleArgumentValue)
                    {
                        if (double.IsPositiveInfinity(doubleArgumentValue))
                        {
                            return("double.PositiveInfinity");
                        }
                        else if (double.IsNegativeInfinity(doubleArgumentValue))
                        {
                            return("double.NegativeInfinity");
                        }
                        else if (double.IsNaN(doubleArgumentValue))
                        {
                            return("double.NaN");
                        }
                        else if (doubleArgumentValue - Math.Truncate(doubleArgumentValue) == 0)
                        {
                            return(doubleArgumentValue.ToString("F1", CultureInfo.InvariantCulture));
                        }
                        else
                        {
                            return(doubleArgumentValue.ToString(CultureInfo.InvariantCulture));
                        }
                    }
                    else if (value is int intArgumentValue)
                    {
                        return(intArgumentValue.ToString(CultureInfo.InvariantCulture));
                    }
                    else if (value is bool boolArgumentValue)
                    {
                        return(boolArgumentValue ? "true" : "false");
                    }

                    throw new UserViewableException($"{property.FullPropertyName} default value {value.ToString()} not yet supported");
                }
                else if (kind == TypedConstantKind.Enum)
                {
                    object      enumValue = value;
                    ITypeSymbol type      = specifiedDefaultValue.Type !;
                    ImmutableArray <ISymbol> enumMembers = type.GetMembers();

                    foreach (IFieldSymbol enumFieldMember in enumMembers)
                    {
                        object?enumFieldValue = enumFieldMember.ConstantValue;
                        if (enumFieldValue != null && enumFieldValue.Equals(value))
                        {
                            return($"{type.Name}.{enumFieldMember.Name}");
                        }
                    }

                    throw new UserViewableException($"No symbol found in enum {type.Name} for value {enumValue}");
                }

                // TODO: add explicit checks for different expression types
                return(value.ToString());
                // throw new UserViewableException($"Default value type {argument} not yet supported");
            }

            if (typeFullName == "System.Collections.Generic.IEnumerable")
            {
                return("null");
            }

            if (Utils.IsUICollectionType(propertyType))
            {
                return("null");
            }

            if (typeFullName == "Microsoft.StandardUI.Color" ||
                typeFullName == "Microsoft.StandardUI.Point" ||
                typeFullName == "Microsoft.StandardUI.Points" ||
                typeFullName == "Microsoft.StandardUI.Size" ||
                typeFullName == "Microsoft.StandardUI.Thickness" ||
                typeFullName == "Microsoft.StandardUI.CornerRadius" ||
                typeFullName == "Microsoft.StandardUI.Text.FontWeight" ||
                typeFullName == "Microsoft.StandardUI.GridLength")
            {
                return($"{GetTypeNameWrapIfNeeded(propertyType)}.Default");
            }

            if (typeFullName == "Microsoft.StandardUI.Media.FontFamily")
            {
                return(FontFamilyDefaultValue);
            }

            // TODO: Implement this
#if false
            else if (propertyType is IArrayTypeSymbol arrayTypeSymbol)
            {
                return
                    (InvocationExpression(
                         MemberAccessExpression(
                             SyntaxKind.SimpleMemberAccessExpression,
                             IdentifierName("Array"),
                             GenericName(
                                 Identifier("Empty"))
                             .WithTypeArgumentList(
                                 TypeArgumentList(
                                     SingletonSeparatedList <TypeSyntax>(arrayType.ElementType))))));
            }
#endif

            throw new UserViewableException($"Property {property.FullPropertyName} has no [DefaultValue] attribute nor hardcoded default");
        }
Ejemplo n.º 35
0
 static XmlCompleteValidator()
 {
     XmlCompleteValidator._documentSpecNameProperty = new DocumentSpecName();
 }
Ejemplo n.º 36
0
 internal MovePropertyCommand(PropertyBase property, MoveDirection dir, uint step)
 {
     _property = property;
     _moveDirection = dir;
     _step = step;
 }