Beispiel #1
0
        public override void Evaluate()
        {
            targetVariable = ParentContext.FindOrCreateVariable(RegexMatch.Groups[1].Value);
            targetCommand  = Get(RegexMatch.Groups[2].Value, ParentContext);

            if (!ObjToBool(targetVariable.Value, out originalValue))
            {
                throw new Exception("Value type error");
            }

            ParentContext.Lock(this);

            State = ExecutionState.DONE;
        }
Beispiel #2
0
        private void RunBlock(IEnumerable <string> block)
        {
            foreach (var line in block.Select(StripComment))
            {
                commandBuffer += line + "\n";
            }

            string cmd;
            var    lineNumber = 0;
            int    commandLineStart;

            while (ParseNext(ref commandBuffer, out cmd, ref lineNumber, out commandLineStart))
            {
                try
                {
                    Line = commandLineStart;
                    var cmdObj = Command.Command.Get(cmd, this, commandLineStart);
                    commands.Add(cmdObj);
                }
                catch (KOSException e)
                {
                    if (ParentContext.FindClosestParentOfType <IContextRunProgram>() != null)
                    {
                        // Error occurs in a child of another running program
                        StdOut("Error in '" + e.Program.Filename + "' on line " + e.LineNumber + ": " + e.Message);
                        State = ExecutionState.DONE;
                        return;
                    }
                    // Error occurs in the top level program
                    StdOut("Error on line " + e.LineNumber + ": " + e.Message);
                    State = ExecutionState.DONE;
                    return;
                }
                catch (Exception e)
                {
                    // Non-kos exception! This is a bug, but no reason to kill the OS
                    StdOut("Flagrant error on line " + lineNumber);
                    UnityEngine.Debug.Log("Program error");
                    UnityEngine.Debug.Log(e);
                    State = ExecutionState.DONE;
                    return;
                }
            }

            if (commandBuffer.Trim() != "")
            {
                StdOut("End of file reached inside unterminated statement");
                State = ExecutionState.DONE;
            }
        }
Beispiel #3
0
 internal override void SetXML(XmlElement xml, BaseClassIfc host, Dictionary <int, XmlElement> processed)
 {
     base.SetXML(xml, host, processed);
     if (host.StepId != ParentContext.StepId)
     {
         xml.AppendChild(ParentContext.GetXML(xml.OwnerDocument, "ParentContext", this, processed));
     }
     if (!double.IsNaN(mTargetScale))
     {
         xml.SetAttribute("TargetScale", mTargetScale.ToString());
     }
     xml.SetAttribute("TargetView", mTargetView.ToString().ToLower());
     setAttribute(xml, "UserDefinedTargetView", UserDefinedTargetView);
 }
Beispiel #4
0
        public override void Evaluate()
        {
            String varname = RegexMatch.Groups[1].Value;

            if (varname.ToUpper() == "ALL")
            {
                ParentContext.UnlockAll();
            }
            else
            {
                ParentContext.Unlock(varname);
            }

            State = ExecutionState.DONE;
        }
Beispiel #5
0
        private void ObjectDifferenceFound(object expectedValue, object actualValue, ParentContext parent)
        {
            var result = new MatchResult
            {
                Success  = false,
                Expected = expectedValue ?? SpecialValues.Null,
                Actual   = actualValue ?? SpecialValues.Null
            };

            if (parent != null)
            {
                result.Parent = parent;
            }
            matchResults.Add(result);
        }
        public MatchResult Validate(PropertyInfo propertyInfo, object actualObj,
                                    ParentContext parentContext = null)
        {
            var actual = GetPropertyValue(propertyInfo, actualObj);

            if (parentContext != null)
            {
                if (parentContext.IsRecursive(actual))
                {
                    return(new MatchResult());
                }
                parentContext.ActualObj = actual;
            }
            return(InternalValidate(propertyInfo, actualObj, parentContext));
        }
Beispiel #7
0
        /// <summary>
        /// Create a new ContextRuntime.
        /// </summary>
        /// <param name="serviceInjector"></param>
        /// <param name="contextConfiguration">the Configuration for this context.</param>
        /// <param name="parentContext"></param>
        public ContextRuntime(
            IInjector serviceInjector,
            IConfiguration contextConfiguration,
            Optional <ContextRuntime> parentContext)
        {
            _serviceInjector = serviceInjector;

            // Note that for Service objects and handlers, we are not merging them into a separate
            // class (e.g. ServiceContainer) due to the inability to allow service stacking if an instance
            // of such a class were to be materialized. i.e. if a ServiceContainer object were initialized
            // and a child ServiceConfiguration is submitted, when the child service injector tries to
            // get the relevant handlers and services set, it will get the same set of handlers as
            // previously instantiated by the parent injector, and thus will not allow the stacking
            // of ServiceConfigurations.
            _injectedServices = serviceInjector.GetNamedInstance <ServicesSet, ISet <object> >();

            _serviceContextStartHandlers =
                serviceInjector.GetNamedInstance <ContextConfigurationOptions.StartHandlers, ISet <IObserver <IContextStart> > >();

            _serviceContextStopHandlers =
                serviceInjector.GetNamedInstance <ContextConfigurationOptions.StopHandlers, ISet <IObserver <IContextStop> > >();

            _serviceTaskStartHandlers =
                serviceInjector.GetNamedInstance <TaskConfigurationOptions.StartHandlers, ISet <IObserver <ITaskStart> > >();

            _serviceTaskStopHandlers =
                serviceInjector.GetNamedInstance <TaskConfigurationOptions.StopHandlers, ISet <IObserver <ITaskStop> > >();

            _contextInjector  = serviceInjector.ForkInjector(contextConfiguration);
            _contextLifeCycle = _contextInjector.GetInstance <ContextLifeCycle>();
            _parentContext    = parentContext;

            try
            {
                _contextLifeCycle.Start();
            }
            catch (Exception e)
            {
                const string message = "Encountered Exception in ContextStartHandler.";
                if (ParentContext.IsPresent())
                {
                    throw new ContextStartHandlerException(
                              Id, Optional <string> .Of(ParentContext.Value.Id), message, e);
                }

                throw new ContextStartHandlerException(Id, Optional <string> .Empty(), message, e);
            }
        }
Beispiel #8
0
 protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
 {
     if (options.Style == SetJsonOptions.JsonStyle.Repository && string.IsNullOrEmpty(mGlobalId))
     {
         setGlobalId(ParserIfc.EncodeGuid(Guid.NewGuid()));
         options.Encountered.Add(mGlobalId);
     }
     base.setJSON(obj, host, options);
     obj["ParentContext"] = ParentContext.getJson(this, options);
     if (!double.IsNaN(mTargetScale))
     {
         obj["TargetScale"] = mTargetScale.ToString();
     }
     obj["TargetView"] = TargetView.ToString();
     setAttribute(obj, "UserDefinedTargetView", UserDefinedTargetView);
 }
Beispiel #9
0
        private DeveelDbProvider CreateProvider()
        {
            if (Provider == null)
            {
                // TODO: Get all other settings as metadata

                var mappingContext = new MappingContext();
                OnBuildMap(mappingContext);

                var model = mappingContext.CreateModel();

                Provider = ParentContext.GetQueryProvider(model);
            }

            return((DeveelDbProvider)Provider);
        }
Beispiel #10
0
 public override void Update(float time)
 {
     if (triggered)
     {
         targetCommand.Update(time);
         if (targetCommand.State == ExecutionState.DONE)
         {
             ParentContext.Unlock(this);
         }
     }
     else if (expression.IsTrue())
     {
         triggered = true;
         targetCommand.Evaluate();
     }
 }
Beispiel #11
0
        /// <summary>
        /// 获取本地变量值
        /// </summary>
        /// <param name="name">变量名</param>
        /// <param name="value">输出变量值</param>
        /// <returns>是否找到本地变量</returns>
        protected bool FirstLocalVariableValue(string name, out object value)
        {
            value = null;
            var result = false;
            if (LocalVariables.ContainsKey(name))
            {
                value = LocalVariables[name];
                result = true;
            }
            else if (ParentContext != null)
            {
                result = ParentContext.FirstLocalVariableValue(name, out value);
            }

            return result;
        }
Beispiel #12
0
        public virtual void UnsetAll()
        {
            for (var i = 0; i < Variables.Count; i++)
            {
                var currvar = Variables.ElementAt(i);

                if (!(currvar.Value is BoundVariable))
                {
                    Variables.Remove(currvar.Key);
                }
            }
            if (ParentContext != null)
            {
                ParentContext.UnsetAll();
            }
        }
        private void ValidateActualConstraints(PropertyInfo property, object actual, ParentContext parent,
                                               ObjectPropertyValidationModel rule)
        {
            var strategy = rule.GetValidationStrategy(property);

            if (strategy == null)
            {
                return;
            }

            var result = strategy.Validate(property, actual, parent);

            if (!result.Success)
            {
                PropertyDifferenceFound(result.Expected, result.Actual, result.Parent); //, result.PropertyName);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Similar to <see cref="GetOrAddSharedExpression(Type, string, Func{Type, string, Expression}, Type)" />, except this is used when expression
        /// builders want to use local variables in block expressions to store the result of some operation in the expression tree built
        /// for a particular target.  Reusing one local variable is more efficient than declaring the same local multiple times.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="name">The name.</param>
        /// <param name="requestingType">Optional - the type of the object requesting this shared expression.  If this is provided,
        /// then the search for an existing shared expression will only work if the same requesting type was passed previously.</param>
        /// <exception cref="InvalidOperationException">Cannot add ParameterExpression: A shared expression of a different type has already been added with the same type and name.</exception>
        /// <remarks>When multiple expression trees from multiple targets are brought together into one lambda, there will
        /// often be many duplicate variables which could be shared.  So, if an <see cref="IExpressionBuilder" /> needs a local variable
        /// for a block, instead of simply declaring it directly through the <see cref="Expression.Parameter(Type, string)" /> function,
        /// it can use this function instead, which will return a previously created one if available.</remarks>
        public ParameterExpression GetOrAddSharedLocal(Type type, string name, Type requestingType = null)
        {
            // if no sharedExpressions dictionary, then we have a parent which will handle the call for us.
            if (this._sharedExpressions == null)
            {
                return(ParentContext.GetOrAddSharedLocal(type, name, requestingType));
            }

            try
            {
                return((ParameterExpression)GetOrAddSharedExpression(type, name, (t, s) => Expression.Parameter(t, s), requestingType));
            }
            catch (InvalidCastException)
            {
                throw new InvalidOperationException("Cannot add ParameterExpression: A shared expression of a different type has already been added with the same type and name.");
            }
        }
        public List <MatchResult> Validate(PropertyInfo actualProperty, object actualObj, object expectedObj,
                                           ParentContext parentContext = null)
        {
            var expectedProp = GetExpectedProperty(expectedObj, actualProperty);

            if (StartConditions.Any() &&
                StartConditions.Any(x => x.CanStrategyStart(actualProperty, actualObj, expectedObj)) ==
                false)
            {
                return(new List <MatchResult>());
            }
            var expected = GetPropertyValue(expectedProp, expectedObj);
            var actual   = GetPropertyValue(actualProperty, actualObj);


            if ((expected == null && actual != null) || (expected != null && actual == null))
            {
                var result = new List <MatchResult>();
                var fail   = new MatchResult
                {
                    Success  = false,
                    Expected = expected ?? SpecialValues.Null,
                    Actual   = actual ?? SpecialValues.Null
                };

                if (parentContext != null)
                {
                    fail.Parent = parentContext;
                }
                result.Add(fail);
                return(result);
            }
            if (expected == null)
            {
                return(new List <MatchResult>());
            }
            if (parentContext != null)
            {
                if (parentContext.IsRecursive(actual))
                {
                    return(new List <MatchResult>());
                }
                parentContext.ActualObj = actual;
            }
            return(InternalValidate(actualProperty, actualObj, expectedObj, parentContext));
        }
Beispiel #16
0
        protected override List <MatchResult> InternalValidate(PropertyInfo actualProperty, object actualObj,
                                                               object expectedObj,
                                                               ParentContext parentContext = null)
        {
            var expectedValue = GetPropertyValue(GetExpectedProperty(expectedObj, actualProperty), expectedObj);
            var actualValue   = GetPropertyValue(actualProperty, actualObj);

            var listMatcher = new EntityListMatchingStrategy(parentContext);

            listMatcher.PositionComparison = PositionComparison;
            listMatcher.ValuesComparison   = ValuesComparison;
            var entityListResult = listMatcher.Compare((IList)actualValue, (IList)expectedValue);
            var resultList       = entityListResult.ListMatchResults;

            resultList.AddRange(entityListResult.EntityMatchResults.SelectMany(x => x.MemberResults).ToList());
            return(resultList);
        }
Beispiel #17
0
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(ContextIdentifier != null ? ContextIdentifier.ToStepValue() : "$");
            parameters.Add(ContextType != null ? ContextType.ToStepValue() : "$");
            parameters.Add("*");
            parameters.Add("*");
            parameters.Add("*");
            parameters.Add("*");
            parameters.Add(ParentContext != null ? ParentContext.ToStepValue() : "$");
            parameters.Add(TargetScale != null ? TargetScale.ToStepValue() : "$");
            parameters.Add(TargetView.ToStepValue());
            parameters.Add(UserDefinedTargetView != null ? UserDefinedTargetView.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
Beispiel #18
0
        private void Flush()
        {
            Assert.That(Shader != null);
            Assert.That(_lastTexture != null);

            unsafe
            {
                fixed(VertexPosition2TextureColor *vertexPtr = &_vertexData[0])
                fixed(ushort *indexPtr = &_indexData[0])
                {
                    //_vertexBuffer.SubData(new Span<VertexPosition2TextureColor>(vertexPtr, _count * 4), 0);
                    _vertexBuffer.SubData <VertexPosition2TextureColor>((IntPtr)vertexPtr, 0, _count * 4);
                    //_indexBuffer.SubData(new Span<ushort>(indexPtr, _count * 6), 0);
                    _indexBuffer.SubData <ushort>((IntPtr)indexPtr, 0, _count * 6);
                }
            }

            ParentContext.BindVertexBuffer(_vertexBuffer);
            ParentContext.BindIndexBuffer(_indexBuffer);
            ParentContext.BindShaderProgram(Shader);
            ParentContext.BindTexture(0, _lastTexture);

            _vertexBuffer.VertexTypeInfo.Apply(Shader);

            bool prevDepthTest = ParentContext.DepthTest;

            ParentContext.DepthTest = false;

            GL.DrawRangeElements(PrimitiveType.Triangles,
                                 0,
                                 _count * 4,
                                 _count * 6,
                                 DrawElementsType.UnsignedShort,
                                 IntPtr.Zero);

            ParentContext.DepthTest = prevDepthTest;

            unchecked
            {
                // Metrics._drawCalls++;
                // Metrics._primitiveCount += _count * 6;
            }

            _count = 0;
        }
Beispiel #19
0
        /// <summary>
        /// Close this context. If there is a child context, this recursively closes it before closing this context. If
        /// there is an Task currently running, that will be closed.
        /// </summary>
        public void Dispose()
        {
            lock (_contextLifeCycle)
            {
                _contextState = ContextStatusProto.State.DONE;
                if (_task.IsPresent())
                {
                    LOGGER.Log(Level.Warning, "Shutting down an task because the underlying context is being closed.");
                    _task.Value.Close(null);
                }
                if (_childContext.IsPresent())
                {
                    LOGGER.Log(Level.Warning, "Closing a context because its parent context is being closed.");
                    _childContext.Value.Dispose();
                }

                try
                {
                    _contextLifeCycle.Close();
                }
                catch (Exception e)
                {
                    const string message = "Encountered Exception in ContextStopHandler.";
                    if (ParentContext.IsPresent())
                    {
                        throw new ContextStopHandlerException(
                                  Id, Optional <string> .Of(ParentContext.Value.Id), message, e);
                    }

                    throw new ContextStopHandlerException(Id, Optional <string> .Empty(), message, e);
                }
                finally
                {
                    if (_parentContext.IsPresent())
                    {
                        ParentContext.Value.ResetChildContext();
                    }

                    foreach (var injectedService in _injectedServices.OfType <IDisposable>())
                    {
                        injectedService.Dispose();
                    }
                }
            }
        }
Beispiel #20
0
        public Variable FindVariable(string varName)
        {
            varName = varName.ToLower();

            var v = Variables.ContainsKey(varName) ? Variables[varName] : null;

            if (v == null && ParentContext != null)
            {
                v = ParentContext.FindVariable(varName);
            }

            if (v != null && Locks.ContainsKey(varName.ToUpper()))
            {
                v.Value = Locks[varName.ToUpper()].GetValue();
            }

            return(v);
        }
Beispiel #21
0
        internal List <GremlinPathStepVariable> GetGremlinStepList(GremlinVariable stopVariable = null)
        {
            List <GremlinPathStepVariable> gremlinStepList = ParentContext?.GetGremlinStepList(HomeVariable);

            if (gremlinStepList == null)
            {
                gremlinStepList = new List <GremlinPathStepVariable>();
            }
            foreach (var step in StepList)
            {
                if (step == stopVariable)
                {
                    break;
                }
                gremlinStepList.Add(step.GetAndPopulatePath());
            }
            return(gremlinStepList);
        }
Beispiel #22
0
        public override void Update(float time)
        {
            bool newValue;

            if (!objToBool(targetVariable.Value, out newValue))
            {
                ParentContext.Unlock(this);

                throw new Exception("Value type error");
            }

            if (originalValue != newValue)
            {
                ParentContext.Unlock(this);

                targetCommand.Evaluate();
                ParentContext.Push(targetCommand);
            }
        }
Beispiel #23
0
        internal List <GremlinVariable> Select(string label, GremlinVariable stopVariable = null)
        {
            List <GremlinVariable> taggedVariableList = ParentContext?.Select(label, HomeVariable);

            if (taggedVariableList == null)
            {
                taggedVariableList = new List <GremlinVariable>();
            }

            var stopIndex = stopVariable == null ? VariableList.Count : VariableList.IndexOf(stopVariable);

            for (var i = 0; i < stopIndex; i++)
            {
                if (VariableList[i].Labels.Contains(label))
                {
                    taggedVariableList.Add(new GremlinContextVariable(VariableList[i]));
                }
                else
                {
                    if (VariableList[i].ContainsLabel(label))
                    {
                        List <GremlinVariable> subContextVariableList = VariableList[i].PopulateAllTaggedVariable(label);
                        foreach (var subContextVar in subContextVariableList)
                        {
                            if (subContextVar is GremlinGhostVariable)
                            {
                                var ghostVar    = subContextVar as GremlinGhostVariable;
                                var newGhostVar = GremlinGhostVariable.Create(ghostVar.RealVariable,
                                                                              ghostVar.AttachedVariable, label);
                                taggedVariableList.Add(newGhostVar);
                            }
                            else
                            {
                                GremlinGhostVariable newVariable = GremlinGhostVariable.Create(subContextVar,
                                                                                               VariableList[i], label);
                                taggedVariableList.Add(newVariable);
                            }
                        }
                    }
                }
            }
            return(taggedVariableList);
        }
Beispiel #24
0
        protected override List <MatchResult> InternalValidate(PropertyInfo actualProperty, object actualObj,
                                                               object expectedObj,
                                                               ParentContext parentContext = null)
        {
            var result        = new List <MatchResult>();
            var actualValue   = GetPropertyValue(actualProperty, actualObj);
            var expectedValue = GetPropertyValue(GetExpectedProperty(expectedObj, actualProperty), expectedObj);

            if (!expectedValue.Equals(actualValue))
            {
                result.Add(new MatchResult
                {
                    Success  = false,
                    Expected = expectedValue,
                    Actual   = actualValue,
                    Parent   = parentContext
                });
            }
            return(result);
        }
Beispiel #25
0
 public override void Update(float time)
 {
     try
     {
         base.Update(time);
         if (SelectedVolume.CheckRange())
         {
             EvaluateNextCommand();
             signalLossWarning = false;
         }
         else
         if (!signalLossWarning)
         {
             StdOut("Selected Volume has gone out of range.");
             signalLossWarning = true;
         }
     }
     catch (KOSException e)
     {
         if (ParentContext.FindClosestParentOfType <IContextRunProgram>() != null)
         {
             // Error occurs in a child of another running program
             StdOut("Error in '" + e.Program.Filename + "' on line " + e.LineNumber + ": " + e.Message);
             State = ExecutionState.DONE;
         }
         else
         {
             // Error occurs in the top level program
             StdOut("Error on line " + e.LineNumber + ": " + e.Message);
             State = ExecutionState.DONE;
         }
     }
     catch (Exception e)
     {
         // Non-kos exception! This is a bug, but no reason to kill the OS
         StdOut("Flagrant error on line " + EXECUTION_LINE);
         UnityEngine.Debug.Log("Program error");
         UnityEngine.Debug.Log(e);
         State = ExecutionState.DONE;
     }
 }
 protected override MatchResult InternalValidate(PropertyInfo propertyInfo, object actualObj,
                                                 ParentContext messagePropertyPrefix = null)
 {
     if (!IsDefault(GetPropertyValue(propertyInfo, actualObj)))
     {
         return new MatchResult
                {
                    Success  = false,
                    Actual   = SpecialValues.Null,
                    Expected = SpecialValues.NotNull,
                    Parent   = new ParentContext(messagePropertyPrefix)
                    {
                        ParentName = propertyInfo.Name
                    }
                }
     }
     ;
     return(new MatchResult {
         Success = true
     });
 }
Beispiel #27
0
        public override void Evaluate()
        {
            String targetVolume = RegexMatch.Groups[1].Value.Trim();
            int    volID;

            if (int.TryParse(targetVolume, out volID))
            {
                if (!ParentContext.SwitchToVolume(volID))
                {
                    throw new kOSException("Volume " + volID + " not found");
                }
            }
            else
            {
                if (!ParentContext.SwitchToVolume(targetVolume))
                {
                    throw new kOSException("Volume '" + targetVolume + "' not found");
                }
            }

            State = ExecutionState.DONE;
        }
Beispiel #28
0
        /// <summary>
        ///  Spawns a new context.
        ///  The new context will have a serviceInjector that is created by forking the one in this object with the given
        ///  serviceConfiguration. The contextConfiguration is used to fork the contextInjector from that new serviceInjector.
        /// </summary>
        /// <param name="childContextConfiguration">the new context's context (local) Configuration.</param>
        /// <param name="childServiceConfiguration">the new context's service Configuration.</param>
        /// <returns>a child context.</returns>
        public ContextRuntime SpawnChildContext(IConfiguration childContextConfiguration, IConfiguration childServiceConfiguration)
        {
            lock (_contextLifeCycle)
            {
                if (_task.IsPresent())
                {
                    var message =
                        string.Format(CultureInfo.InvariantCulture, "Attempting to spawn a child context when an Task with id '{0}' is running", _task.Value.TaskId);

                    var e = new InvalidOperationException(message);
                    Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
                }

                AssertChildContextNotPresent("Attempting to instantiate a child context on a context that is not the topmost active context.");

                try
                {
                    var childServiceInjector = _serviceInjector.ForkInjector(childServiceConfiguration);
                    var childContext         = new ContextRuntime(childServiceInjector, childContextConfiguration, Optional <ContextRuntime> .Of(this));

                    _childContext = Optional <ContextRuntime> .Of(childContext);

                    return(childContext);
                }
                catch (Exception e)
                {
                    Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);

                    Optional <string> parentId = ParentContext.IsPresent() ?
                                                 Optional <string> .Of(ParentContext.Value.Id) :
                                                 Optional <string> .Empty();

                    ContextClientCodeException ex = new ContextClientCodeException(ContextClientCodeException.GetId(childContextConfiguration), parentId, "Unable to spawn context", e);

                    Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER);
                }
            }
            return(null);
        }
Beispiel #29
0
        protected override MatchResult InternalValidate(PropertyInfo propertyInfo, object actualObj,
                                                        ParentContext messagePropertyPrefix = null)
        {
            var propertyValue = GetPropertyValue(propertyInfo, actualObj);


            if (propertyValue == null)
            {
                throw new ImproperAttributeUsageException(
                          "ValidateActualGreaterThanAttribute should be defined only on numeric properties");
            }
            var result = new MatchResult
            {
                Success  = true,
                Expected = "Greater than " + number,
                Actual   = propertyValue,
                Parent   = new ParentContext(messagePropertyPrefix)
                {
                    ParentName = propertyInfo.Name
                }
            };

            try
            {
                var doubleValue = (int)propertyValue;

                if (doubleValue <= number)
                {
                    result.Success = false;
                }
            }
            catch (Exception e)
            {
                throw new ImproperAttributeUsageException(e,
                                                          "ValidateActualGreaterThanAttribute should be defined only on numeric properties");
            }
            return(result);
        }
Beispiel #30
0
 /// <summary>
 /// Retourne le préfixe représentant ce contexte.
 /// Il sera associé au nom des types dans la table des types.
 /// </summary>
 public string GetContextPrefix()
 {
     if (ParentContext == null)
     {
         if (Container == null)
         {
             return("");
         }
         else
         {
             return(Container.Name);
         }
     }
     else
     if (ParentContext.Container == Container || (Container.Name == Language.SemanticConstants.StateClass))     // TODO : fix crade à rendre propre.
     {
         return(ParentContext.GetContextPrefix());
     }
     else
     {
         return(ParentContext.GetContextPrefix() + Container.Name + ".");
     }
 }