コード例 #1
0
ファイル: DeleteFunctionCommand.cs プロジェクト: Howdown/Labs
        public override CommandResult InnerApply(IFunctionsStorage storage)
        {
            if (!storage.ContainsFunctions(this.name))
            {
                return(this.Failure("Function with this name is missing"));
            }

            storage.DeleteFunction(this.name);
            return(this.Success());
        }
コード例 #2
0
        public override CommandResult Apply(IFunctionsStorage storage)
        {
            if (storage.ContainsFunctions(this.nameFunction))
            {
                return(this.Failure("Function with the same name already exists"));
            }

            storage.AddFunction(this.nameFunction, this.function);
            return(this.Success());
        }
コード例 #3
0
 public CommandResult Apply(IFunctionsStorage storage)
 {
     try
     {
         return(InnerApply(storage));
     }
     catch (Exception e)
     {
         return(Failure(e.Message + e.TargetSite));
     }
 }
コード例 #4
0
 public override CommandResult Apply(IFunctionsStorage storage)
 {
     try
     {
         if (!storage.ContainsFunctions(this.name))
         {
             return(this.Failure("Function with this name is missing"));
         }
         storage.DeleteFunction(this.name);
         return(this.Success());
     }
     catch (Exception e)
     {
         return(Failure(e.Message + e.TargetSite));
     }
 }
コード例 #5
0
        public override CommandResult InnerApply(IFunctionsStorage storage)
        {
            if (!storage.ContainsFunctions(this.nameFunction))
            {
                return(this.Failure("Function with this name is missing"));
            }

            if (storage.ContainsFunctions(this.nameDerivative))
            {
                return(this.Failure("Function with the same name already exists"));
            }
            var derivative = storage.GetDerivativeFunction(this.nameFunction);

            storage.AddFunction(this.nameDerivative, derivative);
            return(this.Success());
        }
コード例 #6
0
 public abstract CommandResult Apply(IFunctionsStorage storage);
コード例 #7
0
 public override CommandResult Apply(IFunctionsStorage storage)
 {
     return(storage.ContainsFunctions(this.name) ? new CommandResult(true, storage.CalculateFunction(this.name, this.argument).ToString())
                : new CommandResult(false, "Function with this name is missing"));
 }
コード例 #8
0
ファイル: Interpreter.cs プロジェクト: Howdown/Labs
 public Interpreter(IFunctionsStorage storage, Dictionary <string, Func <ICommandBuilder> > builders)
 {
     this.storage  = storage;
     this.builders = builders;
 }
コード例 #9
0
ファイル: PrintFunctionCommand.cs プロジェクト: Howdown/Labs
 public override CommandResult InnerApply(IFunctionsStorage storage)
 {
     return(storage.ContainsFunctions(this.name) ? this.Success(storage.GetFunction(this.name).ToString())
         : this.Failure("Function with this name is missing"));
 }